From a86630d4222512b66320c540a7f0c4943ff29cf2 Mon Sep 17 00:00:00 2001 From: tylerslaton Date: Tue, 15 Oct 2024 12:06:05 -0400 Subject: [PATCH] fix: don't error when tool call has no metadata This resolves an issue defined in #183 where tool calls with no metadata would cause an error when loading thread history. Signed-off-by: tylerslaton --- ui/admin/app/components/chat/Message.tsx | 2 +- ui/admin/app/lib/model/chatEvents.ts | 2 +- ui/admin/app/lib/model/messages.ts | 2 +- ui/admin/app/lib/model/toolReferences.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/admin/app/components/chat/Message.tsx b/ui/admin/app/components/chat/Message.tsx index ee0ad549..845dd984 100644 --- a/ui/admin/app/components/chat/Message.tsx +++ b/ui/admin/app/components/chat/Message.tsx @@ -67,7 +67,7 @@ export function Message({ message }: MessageProps) { )} >
- {toolCall?.metadata.icon && ( + {toolCall?.metadata?.icon && ( { export const toolCallMessage = (toolCall: ToolCall) => { return { sender: "agent", - text: `Tool call: ${[toolCall.metadata.category, toolCall.name].filter((x) => !!x).join(" - ")}`, + text: `Tool call: ${[toolCall.metadata?.category, toolCall.name].filter((x) => !!x).join(" - ")}`, tools: [toolCall], } as Message; }; diff --git a/ui/admin/app/lib/model/toolReferences.ts b/ui/admin/app/lib/model/toolReferences.ts index 6b242451..79adcb7c 100644 --- a/ui/admin/app/lib/model/toolReferences.ts +++ b/ui/admin/app/lib/model/toolReferences.ts @@ -5,7 +5,7 @@ export type ToolReferenceBase = { name: string; toolType: ToolReferenceType; reference: string; - metadata: Record; + metadata?: Record; }; export type ToolReferenceType = "tool" | "stepTemplate";