Streaming Events
When using streaming in R2R, various event types are emitted during the retrieval and generation process:Event Type | Description |
---|---|
SearchResultsEvent | Contains initial search results from documents |
MessageEvent | Streams partial tokens of the response as they’re generated |
CitationEvent | Indicates when a citation is added to the response |
ThinkingEvent | Contains the model’s step-by-step reasoning (for agents) |
ToolCallEvent | Indicates when the model calls a tool (for agents) |
ToolResultEvent | Contains results from tool calls (for agents) |
FinalAnswerEvent | Contains the complete generated answer with citations |
Streaming RAG
Basic Streaming RAG
To use streaming with basic RAG functionality:Streaming RAG with Web Search
To include web search in your streaming RAG:Streaming Agent
R2R provides a powerful streaming agent mode that supports complex interactions with both document-based knowledge and web resources.Basic Streaming Agent
Advanced Research Agent with Tools
R2R’s agent mode can leverage multiple tools to perform in-depth research:Streaming Citations
R2R’s streaming citations provide detailed attribution information that links specific parts of the response to source documents:id
: Unique identifier for the citationindex
: The display index (e.g., /[1], /[2])start_index
and end_index: Character positions in the responsesource_type
: The type of source (chunk, graph, web)source_id
: ID of the specific chunk/nodedocument_id
: ID of the parent documentsource_title
: Title of the source document