Skip to content

Commit

Permalink
perf(assistant): reduce react re-renders (#615)
Browse files Browse the repository at this point in the history
* perf(assistant): reduce react re-renders to improve rendering performance

* upgrade @petercatai/assistant version
  • Loading branch information
ch-liuzhide authored Dec 25, 2024
1 parent 5591916 commit bc42d1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion assistant/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@petercatai/assistant",
"version": "2.0.8",
"version": "2.0.9",
"description": "PeterCat Assistant Application",
"repository": "https://github.com/petercat-ai/petercat.git",
"license": "MIT",
Expand Down
9 changes: 6 additions & 3 deletions assistant/src/Chat/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,12 @@ const Chat: FC<ChatProps> = memo(
const toolContent: ITool[] = resContent.filter(
(i: MessageContent) => i.type === 'tool',
);
if (toolContent.length > 0 && toolContent[0]?.extra) {
getToolsResult?.(toolContent[0]?.extra);
if (
toolContent.length > 0 &&
toolContent[0]?.extra &&
getToolsResult !== undefined
) {
getToolsResult(toolContent[0].extra);
}
onUpdate(res);
}
Expand Down Expand Up @@ -409,7 +413,6 @@ const Chat: FC<ChatProps> = memo(
(i: MessageContent) => i.type === 'tool',
);
const extra = toolContent?.extra;
// getToolsResult?.(extra);
const textContent = message.content.find(
(i: MessageContent) => i.type === MessageTypeEnum.TEXT,
);
Expand Down

0 comments on commit bc42d1e

Please sign in to comment.