From 9298355fe9641fbeabeac016a18b163a9bb3fb5d Mon Sep 17 00:00:00 2001 From: Richard Gill Date: Sat, 1 Jun 2024 16:08:00 +0000 Subject: [PATCH 1/2] fix perf --- apps/www/src/components/demo/message/Message.tsx | 3 ++- packages/react/src/core/useLLMOutput/helper.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/www/src/components/demo/message/Message.tsx b/apps/www/src/components/demo/message/Message.tsx index 2d2ba9eb..f6b560c1 100644 --- a/apps/www/src/components/demo/message/Message.tsx +++ b/apps/www/src/components/demo/message/Message.tsx @@ -4,7 +4,7 @@ import { buttonsJsonBlock as createJsonButtonsBlock } from "@/components/example import { codeBlockBlock } from "@/components/examples/CodeBlock"; import { Markdown } from "@/components/examples/Markdown"; import { markdownLookBack } from "@llm-ui/markdown"; -import { useLLMOutput } from "@llm-ui/react"; +import { throttleBasic, useLLMOutput } from "@llm-ui/react"; const buttonsJsonBlock = createJsonButtonsBlock(); const buttonsCsvBlock = createCsvButtonsBlock(); @@ -21,6 +21,7 @@ export const Message: React.FC<{ }, blocks: [codeBlockBlock, buttonsJsonBlock, buttonsCsvBlock], isStreamFinished, + throttle: throttleBasic({ targetBufferChars: 60 }), }); // min-w-0 stops overflows diff --git a/packages/react/src/core/useLLMOutput/helper.ts b/packages/react/src/core/useLLMOutput/helper.ts index e0feea9b..117765b7 100644 --- a/packages/react/src/core/useLLMOutput/helper.ts +++ b/packages/react/src/core/useLLMOutput/helper.ts @@ -191,7 +191,10 @@ const matchesWithLookback = ({ isStreamFinished: isStreamFinished, output: match.match.outputRaw, }); - if (visibleText.length > localVisibleTextLengthTarget) { + if ( + visibleText.length > localVisibleTextLengthTarget && + process.env.NODE_ENV !== "production" + ) { console.warn( `Visible text length exceeded target for: ${visibleText} has length ${visibleText.length} target: ${localVisibleTextLengthTarget}. Raw output: ${llmOutputRaw}`, ); From 68328b7534cb096f986a88c21757d14434dc830c Mon Sep 17 00:00:00 2001 From: Richard Gill Date: Sat, 1 Jun 2024 16:13:00 +0000 Subject: [PATCH 2/2] changeset --- .changeset/happy-avocados-lay.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/happy-avocados-lay.md diff --git a/.changeset/happy-avocados-lay.md b/.changeset/happy-avocados-lay.md new file mode 100644 index 00000000..5e103130 --- /dev/null +++ b/.changeset/happy-avocados-lay.md @@ -0,0 +1,5 @@ +--- +"@llm-ui/react": patch +--- + +Performance improvement: Only log console warnings in dev