Skip to main content
Chat is part of the Query workflow. It retrieves relevant chunks, builds grounded context, calls an LLM, and returns an answer with sources, updated history, confidence metadata, and any stage errors. Use this page to understand chat behavior. Use the interface-specific pages when you need exact parameters, flags, request fields, or response shapes.
Chat is stateless. Ragrails does not persist conversations. Pass history into each turn and store the returned history wherever your application keeps session state.

Basic chat

Result:

Streaming

chat_stream() yields progress events, token events, error events, and one final event containing the same ChatResult shape.
Example event sequence:

Conversation features

Query rewriting

Use query rewriting when follow-up questions need previous context to search correctly.

Reranked chat

Reranking retrieves a wider candidate set, reorders it, and keeps the top reranked chunks for answer generation.

Retrieval quality

Retrieval quality decides how chat behaves when the retrieved context is weak.
Low-confidence modes:

Possible errors

Most stage-level failures are returned in the result errors list instead of raising immediately. REST validation and setup failures may return an exception envelope instead. See Errors for the shared shapes.

Next steps

  • Use Retrieval when you want chunks without answer generation.
  • Use Pipeline Overview to see how chat fits into the full RAG flow.
  • Use Chat Tuning for deeper quality and prompt behavior.