fix: finish hooking up accommodations flow

This commit is contained in:
bracesproul
2025-03-05 13:32:51 -08:00
parent 6923c99c32
commit 4e9f33a1d5
5 changed files with 196 additions and 16 deletions

View File

@@ -0,0 +1,23 @@
import {
useStreamContext,
type UIMessage,
} from "@langchain/langgraph-sdk/react-ui";
import { Message, ToolMessage } from "@langchain/langgraph-sdk";
type StreamContextType = ReturnType<
typeof useStreamContext<
{ messages: Message[]; ui: UIMessage[] },
{ MetaType: { ui: UIMessage | undefined } }
>
>;
export function getToolResponse(
toolCallId: string,
thread: StreamContextType,
): ToolMessage | undefined {
const toolResponse = thread.messages.findLast(
(message): message is ToolMessage =>
message.type === "tool" && message.tool_call_id === toolCallId,
);
return toolResponse;
}