fix message reversing

This commit is contained in:
bracesproul
2025-02-28 14:15:37 -08:00
parent 3f4aad48e6
commit a15a9104b4
6 changed files with 57 additions and 129 deletions

View File

@@ -1,5 +1,4 @@
import { StockbrokerState } from "../types";
import { ToolMessage } from "@langchain/core/messages";
import { ChatOpenAI } from "@langchain/openai";
import { typedUi } from "@langchain/langgraph-sdk/react-ui/server";
import type ComponentMap from "../../uis/index";
@@ -64,19 +63,8 @@ export async function callTools(
ui.write("portfolio", {});
}
const toolMessages =
message.tool_calls?.map((tc) => {
return new ToolMessage({
name: tc.name,
tool_call_id: tc.id ?? "",
content: "Successfully handled tool call",
});
}) || [];
console.log("Returning", [message, ...toolMessages]);
return {
messages: [message, ...toolMessages],
messages: [message],
// TODO: Fix the ui return type.
ui: ui.collect as any[],
timestamp: Date.now(),