gemini

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package gemini provides a model.Client implementation backed by the Google Gen AI SDK. It translates loom-mcp requests into Gemini GenerateContent calls and maps responses back into the generic planner structures.

Package gemini wires Google Gemini model clients into loom-mcp planners.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client implements model.Client using Gemini GenerateContent calls.

func New

func New(opts Options) (*Client, error)

New builds a Gemini-backed model client from the provided options.

func NewFromAPIKey

func NewFromAPIKey(apiKey, defaultModel string) (*Client, error)

NewFromAPIKey constructs a Gemini API client using the official Gen AI SDK.

func NewFromVertex added in v1.2.0

func NewFromVertex(ctx context.Context, opts VertexOptions) (*Client, error)

NewFromVertex constructs a Gemini client using the official Gen AI SDK's Vertex AI backend.

func (*Client) Complete

func (c *Client) Complete(ctx context.Context, req *model.Request) (*model.Response, error)

Complete renders a response using the configured Gemini client.

func (*Client) CountTokens added in v1.2.0

func (c *Client) CountTokens(ctx context.Context, req *model.Request) (model.TokenCount, error)

CountTokens implements model.TokenCounter using Gemini's native counter.

func (*Client) Stream

Stream reports that Gemini streaming is not yet supported by this adapter.

type ModelsClient

type ModelsClient interface {
	GenerateContent(ctx context.Context, model string, contents []*genai.Content, config *genai.GenerateContentConfig) (*genai.GenerateContentResponse, error)
}

ModelsClient captures the subset of the Gen AI SDK used by the adapter.

type Options

type Options struct {
	// Client is the underlying Gen AI models client.
	Client ModelsClient

	// DefaultModel is the model identifier used when Request.Model is empty.
	DefaultModel string

	// HighModel is used when Request.ModelClass is high-reasoning and
	// Request.Model is empty.
	HighModel string

	// SmallModel is used when Request.ModelClass is small and Request.Model is
	// empty.
	SmallModel string

	// MaxTokens is the default completion token cap when Request.MaxTokens is
	// unset.
	MaxTokens int

	// Temperature is the default sampling temperature when Request.Temperature
	// is unset.
	Temperature float32

	// ThinkingBudget is the default thinking-token budget when thinking is
	// enabled without a per-request budget.
	ThinkingBudget int
}

Options configures optional Gemini adapter behavior.

type VertexOptions added in v1.2.0

type VertexOptions struct {
	// ProjectID is the Google Cloud project used for Vertex AI requests.
	ProjectID string

	// Location is the Google Cloud location or region used for Vertex AI
	// requests.
	Location string

	// APIKey optionally configures API-key auth for Vertex AI. Leave empty
	// to use Credentials or Application Default Credentials.
	APIKey string

	// Credentials optionally supplies explicit Google Cloud credentials.
	Credentials *auth.Credentials

	// HTTPClient optionally supplies the HTTP client used by the Gen AI SDK.
	HTTPClient *http.Client

	// HTTPOptions optionally overrides Gen AI SDK HTTP behavior.
	HTTPOptions genai.HTTPOptions

	// DefaultModel is the model identifier used when Request.Model is empty.
	DefaultModel string

	// HighModel is used when Request.ModelClass is high-reasoning and
	// Request.Model is empty.
	HighModel string

	// SmallModel is used when Request.ModelClass is small and Request.Model is
	// empty.
	SmallModel string

	// MaxTokens is the default completion token cap when Request.MaxTokens is
	// unset.
	MaxTokens int

	// Temperature is the default sampling temperature when Request.Temperature
	// is unset.
	Temperature float32

	// ThinkingBudget is the default thinking-token budget when thinking is
	// enabled without a per-request budget.
	ThinkingBudget int
}

VertexOptions configures a Vertex AI-backed Gemini adapter.

Jump to

Keyboard shortcuts

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