Overview
The Pope Bot framework provides two chat-related exports:- thepopebot/chat - React UI components
- thepopebot/chat/api - Streaming route handler
- thepopebot/chat/actions - Server actions for chat operations
thepopebot/chat
React components for chat interface.Import
Components
Exports fromlib/chat/components/index.js:
ChatInterface- Full chat UI (message list + input)MessageList- Display conversation historyChatInput- User message input with file uploadMessageBubble- Individual message renderingToolCallDisplay- Show tool invocations
thepopebot/chat/api
Streaming chat route handler with session authentication.Import
Route Handler
Stream chat responses using AI SDK’s
createUIMessageStreamapp/stream/chat/route.js:
How It Works
- Validates session via
auth() - Extracts user message from AI SDK v5 message format
- Processes file attachments (images, PDFs, text files)
- Calls
chatStream()to invoke LLM - Streams response chunks back to browser
- Saves messages to database
Request Body
AI SDK message array with
role, parts, and content fieldsThread ID (generated if not provided)
Action trigger:
regenerate-message skips user message persistenceEnable code workspace context
Repository name for code mode
Branch name for code mode
Code workspace ID
File Attachments
Supports:- Images (
image/*) - Passed to LLM for vision analysis - PDFs (
application/pdf) - Passed to LLM for document analysis - Text files (
text/*,application/json) - Decoded and inlined into message
Streaming Format
Uses AI SDK v5 streaming protocol:thepopebot/chat/actions
Server actions for chat operations.Import
Functions
Fetch user’s chat threads with metadata
Delete a chat thread and all messages
Rename a chat thread
Authentication
Environment Variables
LLM provider:
anthropic, openai, google, custom (default: anthropic)Model name (default:
claude-sonnet-4-20250514)Max output tokens (default:
4096)Required for
anthropic providerRequired for
openai providerRequired for
google providerRelated
- thepopebot/auth - Session authentication
- POST /api/create-job - Create agent jobs (different from chat)