Chat Stream
Stream RAG chat response using Server-Sent Events.
The stream emits events in this order:
sourcesevent with retrieved context attributions- Multiple
textevents with generated content chunks doneevent when generation is complete
Event format:
event: sources
data: {"sources": [...]}
event: text
data: {"content": "..."}
event: done
data: {"completed": true}
Args: request: Chat request with query, history, and configuration service: Chat service (injected)
Returns: StreamingResponse with SSE events
Raises: HTTPException: 503 if service not configured
Request Body required
Section titled “Request Body required ”Request model for chat completion.
object
User query text
Conversation history
A message in the conversation history.
object
Message role
Message content
How to retrieve context
Configuration for RAG context retrieval.
object
Data sources to search
Configuration for a single data source in RAG retrieval.
object
Descriptive name for the source
Embedding model name
Max results from this source
Min similarity
Weight for merging results
Strategy for combining results from multiple sources
Max total context items
Configuration for attachment-based context retrieval.
object
Include full document content (vs summary/excerpts)
Embedding model for query (when no rag_config specified)
LLM model for generation
Generation temperature
Max tokens in response
Responses
Section titled “ Responses ”Successful Response
Validation Error