Chatbot
Chatbot
api/views/chatbot_view.py exposes the public chat endpoint used by the frontend widget.
Endpoint
POST /api/v1/chatbot/
Responsibilities
The chatbot view:
- accepts unauthenticated messages
- resolves the client IP and optional session ID
- builds a system prompt that constrains the assistant to DeepAI OCR support
- pulls recent conversation history for the session
- calls
LiteLLMAPIClientand parses the response withResponseParser - stores the turn in
ChatbotHistory - returns a reply under multiple keys for frontend compatibility
Prompt and response contract
The system prompt forces a narrow product-support scope and requests a one-sentence JSON response. That prompt is not decorative; the downstream parser and frontend both rely on the compact response shape.
History semantics
If a session_id is present, the last ten turns are loaded in chronological order and appended to the LLM message list. That means conversation continuity is session-based rather than user-account-based.
Dependencies
api.models.chatbot_history.ChatbotHistoryapi.services.litellm.litellm_api_client.LiteLLMAPIClientapi.services.litellm.litellm_response_parser.ResponseParser
Validation
tests/integration/test_chatbot.pytests/unit/services/test_litellm_response_parser.py
Scope boundary
This page covers the public chatbot widget only. For the LLM routing service that powers it, read Services.