From 33cdef986afcbef7396d5e26abeaa33915bff7eb Mon Sep 17 00:00:00 2001 From: Jonas Helming Date: Sat, 9 Nov 2024 00:47:58 +0100 Subject: [PATCH] Show arguments in tool call response renderer fixed #14423 Signed-off-by: Jonas Helming --- .../toolcall-part-renderer.tsx | 49 +++++++++++++++---- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/packages/ai-chat-ui/src/browser/chat-response-renderer/toolcall-part-renderer.tsx b/packages/ai-chat-ui/src/browser/chat-response-renderer/toolcall-part-renderer.tsx index 4f5bc127f285b..112ef4bfda3af 100644 --- a/packages/ai-chat-ui/src/browser/chat-response-renderer/toolcall-part-renderer.tsx +++ b/packages/ai-chat-ui/src/browser/chat-response-renderer/toolcall-part-renderer.tsx @@ -20,6 +20,7 @@ import { ChatResponseContent, ToolCallChatResponseContent } from '@theia/ai-chat import { ReactNode } from '@theia/core/shared/react'; import * as React from '@theia/core/shared/react'; + @injectable() export class ToolCallPartRenderer implements ChatResponsePartRenderer { @@ -29,19 +30,49 @@ export class ToolCallPartRenderer implements ChatResponsePartRenderer - {response.finished ? -
- Ran {response.name} -
{this.tryPrettyPrintJson(response)}
+ + renderCollapsibleArguments(args: any): ReactNode { + return ( + args && ( +
+ + > + + {JSON.stringify(args, null, 2)}
- : Running [{response.name}] - } - ; + ) + ); + } + render(response: ToolCallChatResponseContent): ReactNode { + return ( +

+ {response.finished ? ( +
+ Ran [{response.name} + {response.arguments && <>({this.renderCollapsibleArguments(response.arguments)})} + ] +
{this.tryPrettyPrintJson(response)}
+ {this.renderCollapsibleArguments(response.arguments)} +
+ ) : ( + + Running [{response.name} + {response.arguments && <>({this.renderCollapsibleArguments(response.arguments)})} + ] + + )} +

+ ); } + + private tryPrettyPrintJson(response: ToolCallChatResponseContent): string | undefined { let responseContent = response.result; try {