From cd410259ffec1b3f566389c86e140352712a650e Mon Sep 17 00:00:00 2001 From: Tat Dat Duong Date: Mon, 3 Mar 2025 14:50:43 +0100 Subject: [PATCH] Add langsmith:nostream to avoid emitting an empty AI message --- agent/agent.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/agent/agent.tsx b/agent/agent.tsx index 4368d9a..2667501 100644 --- a/agent/agent.tsx +++ b/agent/agent.tsx @@ -6,7 +6,7 @@ import { stockbrokerGraph } from "./stockbroker"; import { ChatOpenAI } from "@langchain/openai"; async function router( - state: GenerativeUIState, + state: GenerativeUIState ): Promise> { const routerDescription = `The route to take based on the user's input. - stockbroker: can fetch the price of a ticker, purchase/sell a ticker, or get the user's portfolio @@ -27,7 +27,9 @@ async function router( const llm = new ChatGoogleGenerativeAI({ model: "gemini-2.0-flash", temperature: 0, - }).bindTools([routerTool], { tool_choice: "router" }); + }) + .bindTools([routerTool], { tool_choice: "router" }) + .withConfig({ tags: ["langsmith:nostream"] }); const prompt = `You're a highly helpful AI assistant, tasked with routing the user's query to the appropriate tool. You should analyze the user's input, and choose the appropriate tool to use.`; @@ -58,7 +60,7 @@ You should analyze the user's input, and choose the appropriate tool to use.`; } function handleRoute( - state: GenerativeUIState, + state: GenerativeUIState ): "stockbroker" | "weather" | "generalInput" { return state.next; }