From 484bb5c201e17bf45e1a1d97b1e9b2d61d6087dc Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Tue, 4 Feb 2025 15:42:03 -0500 Subject: [PATCH] fix: parser error for empty json buffer --- src/backend/src/modules/puterai/lib/Streaming.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/backend/src/modules/puterai/lib/Streaming.js b/src/backend/src/modules/puterai/lib/Streaming.js index 3ebadd2ca..ad2e1f9ea 100644 --- a/src/backend/src/modules/puterai/lib/Streaming.js +++ b/src/backend/src/modules/puterai/lib/Streaming.js @@ -46,6 +46,9 @@ class AIChatToolUseStream extends AIChatConstructStream { this.buffer += partial_json; } _end () { + if ( this.buffer.trim() === '' ) { + this.buffer = '{}'; + } const str = JSON.stringify(objectAssignTop({ ...this.contentBlock, input: JSON.parse(this.buffer),