Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
Signed-off-by: cbh778899 <[email protected]>
  • Loading branch information
cbh778899 committed Sep 26, 2024
1 parent 4887204 commit 43fe385
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions actions/bedrock.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,19 @@ export async function inference(messages, settings, cb = null) {
const response = await client.send(command);

let response_text;
for await (const resp of response.stream) {
if(resp.contentBlockDelta) {
text_piece = resp.contentBlockDelta.delta.text;
response_text += text_piece;
cb && cb(text_piece, false);
if(settings.stream) {
for await (const resp of response.stream) {
if(resp.contentBlockDelta) {
const text_piece = resp.contentBlockDelta.delta.text;
response_text += text_piece;
cb && cb(text_piece, false);
}
}
cb && cb('', true)
} else {
response_text = response.output.message.content[0].text;
cb && cb(response_text, true)
}
cb && cb('', true)

return response_text;
}

0 comments on commit 43fe385

Please sign in to comment.