Skip to content

Commit

Permalink
fix: don't error when tool call has no metadata
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
tylerslaton committed Oct 15, 2024
1 parent 2c5ec01 commit a86630d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ui/admin/app/components/chat/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function Message({ message }: MessageProps) {
)}
>
<div className="max-w-full overflow-hidden p-4 flex gap-2 items-center pl-[20px]">
{toolCall?.metadata.icon && (
{toolCall?.metadata?.icon && (
<ToolIcon
icon={toolCall.metadata.icon}
category={toolCall.metadata.category}
Expand Down
2 changes: 1 addition & 1 deletion ui/admin/app/lib/model/chatEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type ToolCall = {
name: string;
description: string;
input: string;
metadata: {
metadata?: {
category?: string;
icon?: string;
};
Expand Down
2 changes: 1 addition & 1 deletion ui/admin/app/lib/model/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const runsToMessages = (runs: Run[]) => {
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;
};
Expand Down
2 changes: 1 addition & 1 deletion ui/admin/app/lib/model/toolReferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export type ToolReferenceBase = {
name: string;
toolType: ToolReferenceType;
reference: string;
metadata: Record<string, string>;
metadata?: Record<string, string>;
};

export type ToolReferenceType = "tool" | "stepTemplate";
Expand Down

0 comments on commit a86630d

Please sign in to comment.