uiMessageReducer,}from"@langchain/langgraph-sdk/react-ui/server";import{ ChatOpenAI }from"@langchain/openai";import{ v4 as uuidv4 }from"uuid";import{ z }from"zod";importtypeComponentMapfrom"./ui.js";import{
MessagesAnnotation,typeLangGraphRunnableConfig,}from"@langchain/langgraph";import{ z }from"zod";import{ ChatAnthropic }from"@langchain/anthropic";import{
// 我们已经通过 UI 消息将 LLM 响应流式传输到客户端// 因此无需再次将其流式传输到 `messages` 流模式。.withConfig({ tags:["nostream"]}).stream(`Create a short poem with the topic: ${message.text}`);let content: AIMessageChunk |undefined;forawait(const chunk of contentStream){