Skip to content

Commit

Permalink
Remove 4 lines in ToolResult.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
AtlantisPleb committed Aug 28, 2024
1 parent e2396ea commit 40afc20
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions panes/chat/ToolResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ export const ToolResult: React.FC<ToolResultProps> = ({ toolName, args, result,
let resultToRender = currentResult;

// Handle rehydrated data structure
if (typeof currentResult === 'object' && 'result' in currentResult) {
resultToRender = currentResult.result;
if (typeof resultToRender === 'object' && 'result' in resultToRender) {
resultToRender = resultToRender.result;
}

if (typeof resultToRender === 'string') {
return resultToRender;
}

if (typeof resultToRender === 'object' && resultToRender !== null) {
Expand All @@ -54,19 +58,11 @@ export const ToolResult: React.FC<ToolResultProps> = ({ toolName, args, result,
if ('content' in resultToRender) {
return resultToRender.content;
}
// If it's an object without summary or content, return an empty string
return '';
}

// If it's a string, return it directly
if (typeof resultToRender === 'string') {
return resultToRender;
}

// If it's an object, only return the 'summary' field if it exists
if (typeof resultToRender === 'object' && resultToRender !== null && 'summary' in resultToRender) {
return resultToRender.summary;
}

// Otherwise, return an empty string to prevent displaying unnecessary information
// If it's neither a string nor an object, return an empty string
return '';
}
if (currentState === 'call') {
Expand Down

0 comments on commit 40afc20

Please sign in to comment.