fix bug that gemini has multiple candidates part

This commit is contained in:
suruiqiang 2025-02-07 16:20:07 +08:00
parent f156430cc5
commit 3fe55b4f7f

View File

@ -69,9 +69,16 @@ export class GeminiProApi implements LLMApi {
.join("\n\n"); .join("\n\n");
}; };
let content = "";
if (Array.isArray(res)) {
res.map((item) => {
content += getTextFromParts(item?.candidates?.at(0)?.content?.parts);
});
}
return ( return (
getTextFromParts(res?.candidates?.at(0)?.content?.parts) || getTextFromParts(res?.candidates?.at(0)?.content?.parts) ||
getTextFromParts(res?.at(0)?.candidates?.at(0)?.content?.parts) || content || //getTextFromParts(res?.at(0)?.candidates?.at(0)?.content?.parts) ||
res?.error?.message || res?.error?.message ||
"" ""
); );