forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopilotChatToolCallsView.tsx
More file actions
40 lines (34 loc) · 971 Bytes
/
Copy pathCopilotChatToolCallsView.tsx
File metadata and controls
40 lines (34 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { useRenderToolCall } from "../../hooks";
import type { AssistantMessage, Message, ToolMessage } from "@ag-ui/core";
import React from "react";
export type CopilotChatToolCallsViewProps = {
message: AssistantMessage;
messages?: Message[];
};
export function CopilotChatToolCallsView({
message,
messages = [],
}: CopilotChatToolCallsViewProps) {
const renderToolCall = useRenderToolCall();
if (!message.toolCalls || message.toolCalls.length === 0) {
return null;
}
return (
<>
{message.toolCalls.map((toolCall) => {
const toolMessage = messages.find(
(m) => m.role === "tool" && m.toolCallId === toolCall.id,
) as ToolMessage | undefined;
return (
<React.Fragment key={toolCall.id}>
{renderToolCall({
toolCall,
toolMessage,
})}
</React.Fragment>
);
})}
</>
);
}
export default CopilotChatToolCallsView;