gemini

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package gemini implements providers.ModelProvider against the Gemini API (streamGenerateContent with native function calling). It maps RunLore's engine- agnostic exchange (OpenAI-shaped: assistant tool_calls + separate tool messages) onto Gemini's contents/parts form: assistant turns become role "model" with functionCall parts, and tool results coalesce into one role "user" turn of functionResponse parts. Each call/response carries the originating call id, so parallel calls to the same function name correlate by id (Gemini's rule for parallel calls); when the model returns no id, correlation falls back to name.

Streaming is internal: callers see the same one-shot Complete interface, but the request uses :streamGenerateContent?alt=sse and the SSE chunks are accumulated into a single CompletionResponse. Consuming the stream avoids a flat request deadline truncating a long completion.

Index

Constants

View Source
const DefaultBaseURL = "https://generativelanguage.googleapis.com"

DefaultBaseURL is the public Gemini API.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	clientcore.Base
}

Client is a Gemini (streamGenerateContent) model provider.

func New

func New(baseURL, model, apiKey string, maxTokens int) *Client

New builds a client. baseURL may be empty (defaults to DefaultBaseURL). maxTokens caps output tokens per request; <= 0 falls back to clientcore.DefaultMaxTokens.

func (*Client) Complete

Complete sends a streaming streamGenerateContent request with tools and accumulates the full SSE response into a single CompletionResponse. Streaming is internal — callers see the same one-shot interface; consuming the stream avoids the flat request deadline truncating a long completion.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL