forked from GithubProxy/ChatGPT-Next-Web
Merge pull request #5965 from zmhuanf/temp
Fix issue #5964: Prevents character loss in gemini-2.0-flash-thinking-exp-1219 responses
This commit is contained in:
commit
13430ea3e2
@ -60,9 +60,18 @@ export class GeminiProApi implements LLMApi {
|
|||||||
extractMessage(res: any) {
|
extractMessage(res: any) {
|
||||||
console.log("[Response] gemini-pro response: ", res);
|
console.log("[Response] gemini-pro response: ", res);
|
||||||
|
|
||||||
|
const getTextFromParts = (parts: any[]) => {
|
||||||
|
if (!Array.isArray(parts)) return "";
|
||||||
|
|
||||||
|
return parts
|
||||||
|
.map((part) => part?.text || "")
|
||||||
|
.filter((text) => text.trim() !== "")
|
||||||
|
.join("\n\n");
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
res?.candidates?.at(0)?.content?.parts.at(0)?.text ||
|
getTextFromParts(res?.candidates?.at(0)?.content?.parts) ||
|
||||||
res?.at(0)?.candidates?.at(0)?.content?.parts.at(0)?.text ||
|
getTextFromParts(res?.at(0)?.candidates?.at(0)?.content?.parts) ||
|
||||||
res?.error?.message ||
|
res?.error?.message ||
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
@ -223,7 +232,10 @@ export class GeminiProApi implements LLMApi {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return chunkJson?.candidates?.at(0)?.content.parts.at(0)?.text;
|
return chunkJson?.candidates
|
||||||
|
?.at(0)
|
||||||
|
?.content.parts?.map((part: { text: string }) => part.text)
|
||||||
|
.join("\n\n");
|
||||||
},
|
},
|
||||||
// processToolMessage, include tool_calls message and tool call results
|
// processToolMessage, include tool_calls message and tool call results
|
||||||
(
|
(
|
||||||
|
Loading…
Reference in New Issue
Block a user