Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MrlolDev committed Dec 15, 2023
1 parent 39004fe commit c72d63a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/models/text/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,15 @@ export default {
}),
};
let promptLength = 0;
await delay(250);
generativeModel
.generateContentStream(request)
.then(async (streamingResp) => {
const cost = 0;
let resultLength = 0;
for await (const item of streamingResp.stream) {
if (item.candidates.length == 0) continue;
if (item.candidates?.length == 0) continue;
if (!item.candidates[0]?.content?.parts) continue;
if (item.candidates[0]?.content?.parts.length == 0) continue;
res.result = item.candidates[0]?.content?.parts[0]?.text || "";
resultLength = item.usageMetadata?.candidates_token_count || 0;
Expand Down

0 comments on commit c72d63a

Please sign in to comment.