From e00478f375ebd18645fd1037463fd4ad68dc3da5 Mon Sep 17 00:00:00 2001 From: Corneliu CROITORU Date: Wed, 25 Sep 2024 22:17:25 +0200 Subject: [PATCH] fix streaming for tooluse in ts --- typescript/src/agents/bedrockLLMAgent.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/typescript/src/agents/bedrockLLMAgent.ts b/typescript/src/agents/bedrockLLMAgent.ts index f36d33c..f212ead 100644 --- a/typescript/src/agents/bedrockLLMAgent.ts +++ b/typescript/src/agents/bedrockLLMAgent.ts @@ -193,7 +193,12 @@ export class BedrockLLMAgent extends Agent { while (continueWithTools && maxRecursions > 0){ // send the conversation to Amazon Bedrock - const bedrockResponse = await this.handleSingleResponse(converseCmd); + let bedrockResponse; + if (this.streaming) { + bedrockResponse = this.handleStreamingResponse(converseCmd); + } else { + bedrockResponse = await this.handleSingleResponse(converseCmd); + } // Append the model's response to the ongoing conversation conversation.push(bedrockResponse); @@ -218,7 +223,7 @@ export class BedrockLLMAgent extends Agent { if (this.streaming) { return this.handleStreamingResponse(converseCmd); } else { - return this.handleSingleResponse(converseCmd); + return await this.handleSingleResponse(converseCmd); } } }