From b8d0a5064bb22a1abdf2000ed3ea1b19cacefa92 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Wed, 24 Jul 2024 21:18:21 -0700 Subject: [PATCH] Tool Use/Response terrible rendering --- .../fragments-content/ContentFragments.tsx | 126 +++++++++++++++++- 1 file changed, 123 insertions(+), 3 deletions(-) diff --git a/src/apps/chat/components/message/fragments-content/ContentFragments.tsx b/src/apps/chat/components/message/fragments-content/ContentFragments.tsx index 76a7fe015..1b36d551b 100644 --- a/src/apps/chat/components/message/fragments-content/ContentFragments.tsx +++ b/src/apps/chat/components/message/fragments-content/ContentFragments.tsx @@ -1,7 +1,9 @@ import * as React from 'react'; import type { SxProps } from '@mui/joy/styles/types'; -import { Box } from '@mui/joy'; +import { Box, Sheet } from '@mui/joy'; + +import { BlocksContainer } from '~/modules/blocks/BlocksContainer'; import type { ContentScaling } from '~/common/app.theme'; import type { DMessageRole } from '~/common/stores/chat/chat.message'; @@ -102,7 +104,7 @@ export function ContentFragments(props: { messageRole={props.messageRole} contentScaling={props.contentScaling} showAsDanger - showAsItalic + // showAsItalic /> ); @@ -150,8 +152,126 @@ export function ContentFragments(props: { /> ); - case 'tool_call': + case 'tool_invocation': + return ( + + {fragment.part.invocation.type === 'function_call' ? ( + +
Id
+
{fragment.part.id}
+
Name
+
{fragment.part.invocation.name}
+
Args
+
{fragment.part.invocation.args/*?.replaceAll('{', '').replaceAll('}', '').replaceAll('","', '", "')*/}
+
+ ) : ( + +
Id
+
{fragment.part.id}
+
Language
+
{fragment.part.invocation.language}
+
Code
+
{fragment.part.invocation.code?.trim()}
+
Author
+
{fragment.part.invocation.author}
+
+ )} +
+ ); + case 'tool_response': + return ( + + {fragment.part.response.type === 'function_call' ? ( + +
Type
+
Function Call Response
+
Id
+
{fragment.part.id}
+
Error
+
{fragment.part.error === null ? 'null' : fragment.part.error === 'false' ? '' : fragment.part.error}
+
Name
+
{fragment.part.response.name}
+
Result
+
{fragment.part.response.result}
+
Environment
+
{fragment.part.environment}
+
+ ) : ( + +
Type
+
Code Execution Response
+
Id
+
{fragment.part.id}
+
Error
+
{fragment.part.error === null ? 'null' : fragment.part.error === 'false' ? '' : fragment.part.error}
+
Result
+
{fragment.part.response.result}
+
Executor
+
{fragment.part.response.executor}
+
Environment
+
{fragment.part.environment}
+
+ )} +
+ ); + case '_pt_sentinel': default: return (