+:::python
+
:::
+
+:::js
+- Start with `generateQueryOrRespond` and determine whether to call the retriever tool.
+- Route to the next step using a conditional edge:
+ - If `generateQueryOrRespond` returned `tool_calls`, call the retriever tool to retrieve context.
+ - Otherwise, respond directly to the user.
+- Grade retrieved document content for relevance to the question (`gradeDocuments`) and route to the next step:
+ - If not relevant, rewrite the question using `rewrite` and then call `generateQueryOrRespond` again.
+ - If relevant, proceed to `generate` and generate the final response using the @[ToolMessage] with the retrieved document context.
+
+updates, values, messages, custom, checkpoints, tasks, debugProcessing...
}
+
:::
:::js
-```typescript
-const question = "Which genre on average has the longest tracks?";
-
-const stream = await agent.stream(
- { messages: [{ role: "user", content: question }] },
- { streamMode: "values" }
-);
-
-for await (const step of stream) {
- if (step.messages && step.messages.length > 0) {
- const lastMessage = step.messages[step.messages.length - 1];
- console.log(lastMessage.toFormattedString());
- }
-}
-```
+
+