Skip to content

docs: add chatbot-backend example showing Vercel Chatbot replacement with Python #44

@shloimy-wiesel

Description

@shloimy-wiesel

Summary

The example/chatbot-backend/ directory now contains a complete, working Python backend that replaces the TypeScript backend of the Vercel Chatbot. This should be documented as a primary showcase of the library's capabilities.

What's included

  • FastAPI backend with StreamContext flowing through routes → services → tools
  • 6 tools: getWeather, createDocument, updateDocument, editDocument, requestSuggestions (+ chat title generation)
  • Redis persistence for chat history and documents (decoupled from the chatbot's Postgres)
  • Delta strategy per artifact kind (text=incremental, code/sheet=full content)
  • OpenAI-compatible LLM via consume_openai_stream + tool loop
  • README.md with setup instructions, architecture, API reference

Verified working features

  • ✅ Basic Q&A text streaming
  • ✅ Weather tool with full widget rendering
  • ✅ Text artifact creation (essays, documents)
  • ✅ Code artifact creation (algorithms with syntax highlighting)
  • ✅ Document update (full content replacement)
  • ✅ Document edit (search-and-replace with replace_all)
  • ✅ Request suggestions on text documents
  • ✅ Multi-turn tool context (assistant messages persisted to Redis)
  • ✅ Chat title generation on first message

Key takeaway

The entire backend is ~600 LOC across 10 files. The library's StreamContext + consume_openai_stream pattern makes the implementation straightforward — no raw SSE string building anywhere.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions