toGeminiContents
function toGeminiContents(messages, provider?): object;Defined in: core/src/providers/gemini.ts:284
Our messages → Gemini contents.
Three shape differences the rest of the adapter must not have to know about:
system text is lifted out and merged into ONE instruction (Gemini takes a
single one, not a role in the turn list); assistant turns are role model
and carry tool calls as functionCall parts with the thought signature
beside them; tool results are role user with a functionResponse part
naming the FUNCTION, since Gemini pairs a result to its call by name.
A run of results is ONE user turn: Gemini answers a model turn’s parallel calls with every response together, and spread over several turns it 400s that the response count does not match the call count. The responses go first, in call order, and the run’s images follow them all, the way the OpenAI dialect places them.
A model turn that ran built-in tools goes back to provider, the one that
made it, as the parts it came in: the code and its result, the server
tool’s call and response with their thought signatures, which Gemini needs
returned unchanged when built-ins and functions share a turn.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
messages |
readonly ChatMessage[] |
provider? |
string |
Returns
Section titled “Returns”object
contents
Section titled “contents”contents: GeminiContent[];system?
Section titled “system?”optional system?: string;