cloud-pipeline icon indicating copy to clipboard operation
cloud-pipeline copied to clipboard

Backend for Chatbot

Open mzueva opened this issue 5 months ago • 0 comments

Background A new service shall be implemented providing API endpoints for chatbot.

Approach A clear and concise description of what you want to happen. Chat bot server should provide the following API:

  • POST /chat - creates a new chat entry and returns it's ID
  • GET /chat/${chat_id} - returns chat message history with message contents
  • POST /chat/${chat_id} - adds a new message to the chat, message is passed as request body
  • GET /chat/${chat_id}/message/${message_id} - returns message specified by id
  • DELETE /chat/${chat_id}/message/${message_id} - deletes message specified by id
  • WebSocket endpoint assistant - accepts as input request object with chat_id, list<message_id> history and streams generated response. When the LLM answer is fully returned to the client, the handler message should save response to the chat message history and only then send final done event

Model:

  • chat - id, title (empty for now), later shall be generated
  • message - id, chat_id, created_date, role, content, attributes (dictionary)

Further development steps:

  1. Replace Sqlite with MongoDB to support requests from multiple processes/threads/users
  2. Offload LLM communication tasks to separate threads using Celery
  3. Introduce requests API, to reduce size of messages send to WebSocket endpoint

mzueva avatar May 07 '25 10:05 mzueva