Skip to content

Commit

Permalink
Support multiple parts (gemini-2.0-flash-thinking-exp)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnd0e committed Dec 26, 2024
1 parent f1d1a41 commit ef6e6e7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/worker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,12 @@ const reasonsMap = { //https://ai.google.dev/api/rest/v1/GenerateContentResponse
//"OTHER": "OTHER",
// :"function_call",
};
const SEP = "\n\n|>";
const transformCandidates = (key, cand) => ({
index: cand.index || 0, // 0-index is absent in new -002 models response
[key]: { role: "assistant", content: cand.content?.parts[0].text },
[key]: {
role: "assistant",
content: cand.content?.parts.map(p => p.text).join(SEP) },
logprobs: null,
finish_reason: reasonsMap[cand.finishReason] || cand.finishReason,
});
Expand Down

0 comments on commit ef6e6e7

Please sign in to comment.