google

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package google is a streaming LLM service backed by Google's Gemini API (generateContent with SSE). It consumes an LLMContextFrame and emits the response as LLM response frames, like every other jargo LLM service.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// APIKey is the Gemini API key. Required.
	APIKey string `validate:"required"`
	// Model is the model id; empty uses a low-latency flash default.
	Model string
	// MaxTokens caps the response length; 0 uses a small default suited to voice.
	MaxTokens int
	// Temperature is the sampling temperature (0.0 to 2.0); nil omits it.
	Temperature *float64
	// TopP is the nucleus-sampling parameter (0.0 to 1.0); nil omits it.
	TopP *float64
	// TopK is the top-k sampling parameter; nil omits it.
	TopK *int
	// Extra sets arbitrary additional generationConfig fields not modeled above,
	// applied to every request.
	Extra map[string]any
}

Config configures the Gemini LLM service. The sampling controls are pointers so a deliberate zero is distinguishable from "unset"; a nil value is omitted from the request, leaving the API default.

func (Config) Validate

func (c Config) Validate() error

Validate reports whether the configuration is usable.

type Service

type Service struct {
	*llm.Base
	// contains filtered or unexported fields
}

Service is a streaming Gemini LLM processor.

func NewLLM

func NewLLM(cfg Config) *Service

NewLLM builds a Gemini LLM service.

func (*Service) Generate

func (s *Service) Generate(ctx context.Context, convo *frames.LLMContext, emit llm.Emit) error

Generate streams a Gemini completion, emitting each text delta.

func (*Service) GenerateWithTools

func (s *Service) GenerateWithTools(ctx context.Context, convo *frames.LLMContext, sink llm.Sink) error

GenerateWithTools streams a tool-capable completion. It emits text deltas to the sink as they arrive and reports each functionCall the model produces. The conversation's tools are sent on the request, and any tool turns already in the context are replayed as functionCall / functionResponse parts.

Jump to

Keyboard shortcuts

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