fix: finish hooking up accommodations flow
This commit is contained in:
23
agent/uis/utils/get-tool-response.ts
Normal file
23
agent/uis/utils/get-tool-response.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user