Skip to content

Gemini Adapter

Gemini Adapter is implemented by GeminiGenerator in the root package and adapts Google Gemini GenerateContent API to genx.Generator.

Convert boundaries

  • Convert ModelContext to Gemini contents, system instructions, tools and generation config.
  • Convert the text, inline data and function call of Gemini streaming candidate to MessageChunk.
  • Convert stop, max tokens and safety blocking to unified GenX terminal state.
  • Invoke Use response schema to generate typed FuncCall arguments.

Core structure and main function

SymbolFunction
GeminiGeneratorStores Gemini client, model and calling parameters, and implement Generator.
GeminiGenerator.GenerateStreamConsumes Gemini streaming candidates and outputs GenX Stream.
GeminiGenerator.InvokeUse Gemini response schema to generate FuncCall arguments.

Gemini-specific content, finish reason and usage only exist inside the Adapter and cannot be spread to Agent or GizClaw service contract.