Description
RAG pipelines are slow because they involve embedding generation, vector retrieval, and LLM generation. Waiting for the entire response to be generated before displaying it leads to poor UX.
Implementation
- Update the LLM integration in
bots/ (e.g., Langchain or OpenAI SDK) to use streaming mode.
- Modify the FastAPI
backend/ to return a StreamingResponse or Server-Sent Events (SSE).
- Update the React
frontend/ chat component to append incoming chunks to the chat bubble in real-time, creating a typewriter effect.
- Ensure error handling gracefully manages interrupted streams.
Level: Advanced
Affected Files: backend/api.py, bots/assistant.py, frontend/components/Chat/
Description
RAG pipelines are slow because they involve embedding generation, vector retrieval, and LLM generation. Waiting for the entire response to be generated before displaying it leads to poor UX.
Implementation
bots/(e.g., Langchain or OpenAI SDK) to use streaming mode.backend/to return aStreamingResponseor Server-Sent Events (SSE).frontend/chat component to append incoming chunks to the chat bubble in real-time, creating a typewriter effect.Level: Advanced
Affected Files:
backend/api.py,bots/assistant.py,frontend/components/Chat/