gemini

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxOutputTokens = 8192
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps the Google GenAI SDK client.

func NewClientWithConfig

func NewClientWithConfig(apiKey, model string) (*Client, error)

NewClientWithConfig creates a new Gemini client with explicit API key and model.

func (*Client) Chat

func (c *Client) Chat(messages []Message, thinkingEnabled bool, tools []Tool) (string, string, []FunctionCallResult, *TokenUsage, error)

Chat sends a non-streaming chat request.

func (*Client) ChatStream

func (c *Client) ChatStream(messages []Message, thinkingEnabled bool, tools []Tool, callback StreamCallback) (string, []FunctionCallResult, *TokenUsage, error)

ChatStream sends a streaming chat request.

func (*Client) Close

func (c *Client) Close()

Close is a no-op for the Gemini client.

type FunctionCallData

type FunctionCallData struct {
	ID               string
	Name             string
	Args             map[string]interface{}
	ThoughtSignature string
}

FunctionCallData is a tool call from a prior assistant message (for history).

type FunctionCallResult

type FunctionCallResult struct {
	ID               string
	Name             string
	Args             map[string]interface{}
	ThoughtSignature string
}

FunctionCallResult holds a parsed tool call from the model response.

type FunctionResponseData

type FunctionResponseData struct {
	ID       string
	Name     string
	Response map[string]interface{}
}

FunctionResponseData is the tool result sent back to the model.

type GeminiProvider

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

GeminiProvider implements common.Provider for Google Gemini.

func NewGeminiProvider

func NewGeminiProvider(config common.ProviderConfig) (*GeminiProvider, error)

NewGeminiProvider creates a new Gemini provider.

func (*GeminiProvider) Chat

func (p *GeminiProvider) Chat(messages []common.Message, tools []common.Tool, thinkingEnabled bool) (*common.ChatResponse, error)

Chat sends a non-streaming chat request.

func (*GeminiProvider) ChatStream

func (p *GeminiProvider) ChatStream(messages []common.Message, tools []common.Tool, thinkingEnabled bool, callback common.StreamCallback) (*common.ChatResponse, error)

ChatStream sends a streaming chat request.

func (*GeminiProvider) Close

func (p *GeminiProvider) Close() error

Close closes any resources.

type Message

type Message struct {
	Role             string
	Content          string
	ReasoningContent string
	FunctionResponse *FunctionResponseData
	FunctionCalls    []FunctionCallData
}

Message is the internal message format for the Gemini client.

type StreamCallback

type StreamCallback func(chunk string, isThought bool)

StreamCallback is called for each chunk during streaming.

type TokenUsage

type TokenUsage struct {
	InputTokens  int64
	OutputTokens int64
}

TokenUsage represents token usage information.

type Tool

type Tool struct {
	Name        string
	Description string
	InputSchema map[string]interface{}
}

Tool is the internal tool definition for the Gemini client.

Jump to

Keyboard shortcuts

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