Documentation
¶
Overview ¶
Copyright 2026 Teradata
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2026 Teradata ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- type APIError
- type Candidate
- type Client
- func (c *Client) Chat(ctx context.Context, messages []llmtypes.Message, tools []shuttle.Tool) (*llmtypes.LLMResponse, error)
- func (c *Client) ChatStream(ctx context.Context, messages []llmtypes.Message, tools []shuttle.Tool, ...) (*llmtypes.LLMResponse, error)
- func (c *Client) Model() string
- func (c *Client) Name() string
- type Config
- type Content
- type FunctionCall
- type FunctionDeclaration
- type FunctionResponse
- type GenerateContentRequest
- type GenerateContentResponse
- type GenerationConfig
- type InlineData
- type Part
- type Schema
- type Tool
- type UsageMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
Code int `json:"code"`
Message string `json:"message"`
Status string `json:"status"`
}
APIError represents an error from the Gemini API.
type Candidate ¶
type Candidate struct {
Content Content `json:"content"`
FinishReason string `json:"finishReason"`
Index int `json:"index"`
}
Candidate represents a generated response candidate.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements the LLMProvider interface for Google Gemini.
func (*Client) Chat ¶
func (c *Client) Chat(ctx context.Context, messages []llmtypes.Message, tools []shuttle.Tool) (*llmtypes.LLMResponse, error)
Chat sends a conversation to Google Gemini and returns the response.
func (*Client) ChatStream ¶
func (c *Client) ChatStream(ctx context.Context, messages []llmtypes.Message, tools []shuttle.Tool, tokenCallback llmtypes.TokenCallback) (*llmtypes.LLMResponse, error)
ChatStream implements token-by-token streaming for Google Gemini. This method uses Gemini's streamGenerateContent endpoint to stream tokens as they are generated. The tokenCallback is called for each token received.
type Config ¶
type Config struct {
// Required: Gemini API key from https://makersuite.google.com/
APIKey string
// Model to use (default: "gemini-2.5-flash")
// Available models:
// - gemini-3-pro-preview: Most intelligent, $2-4/$12-18 per 1M tokens
// - gemini-2.5-pro: Complex reasoning, $1.25-2.50/$10-15 per 1M tokens
// - gemini-2.5-flash: Best price/performance, $0.30/$2.50 per 1M tokens
// - gemini-2.5-flash-lite: Fastest/cheapest, similar to Flash pricing
Model string
// Optional configuration
MaxTokens int // Default: 8192
Temperature float64 // Default: 1.0
Timeout time.Duration // Default: 60s
RateLimiterConfig llm.RateLimiterConfig
}
Config holds configuration for the Gemini client.
type Content ¶
type Content struct {
Role string `json:"role"` // "user", "model", or "function"
Parts []Part `json:"parts"`
}
Content represents a conversational turn (message).
type FunctionCall ¶
FunctionCall represents a function call request from the model.
type FunctionDeclaration ¶
type FunctionDeclaration struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters Schema `json:"parameters,omitempty"`
}
FunctionDeclaration defines a function that the model can call.
type FunctionResponse ¶
type FunctionResponse struct {
Name string `json:"name"`
Response map[string]interface{} `json:"response"`
}
FunctionResponse represents a function execution result.
type GenerateContentRequest ¶
type GenerateContentRequest struct {
Contents []Content `json:"contents"`
Tools []Tool `json:"tools,omitempty"`
GenerationConfig GenerationConfig `json:"generationConfig,omitempty"`
}
GenerateContentRequest represents a request to generate content.
type GenerateContentResponse ¶
type GenerateContentResponse struct {
Candidates []Candidate `json:"candidates,omitempty"`
UsageMetadata UsageMetadata `json:"usageMetadata,omitempty"`
Error *APIError `json:"error,omitempty"`
}
GenerateContentResponse represents a response from the API.
type GenerationConfig ¶
type GenerationConfig struct {
Temperature float64 `json:"temperature,omitempty"`
MaxOutputTokens int `json:"maxOutputTokens,omitempty"`
TopP float64 `json:"topP,omitempty"`
TopK int `json:"topK,omitempty"`
}
GenerationConfig controls generation behavior.
type InlineData ¶
type InlineData struct {
MimeType string `json:"mimeType"` // "image/jpeg", "image/png", etc.
Data string `json:"data"` // Base64-encoded data
}
InlineData represents inline data like images.
type Part ¶
type Part struct {
Text string `json:"text,omitempty"`
InlineData *InlineData `json:"inlineData,omitempty"`
FunctionCall *FunctionCall `json:"functionCall,omitempty"`
FunctionResponse *FunctionResponse `json:"functionResponse,omitempty"`
}
Part represents a piece of content (text, function call, function response, or inline data).
type Schema ¶
type Schema struct {
Type string `json:"type"`
Description string `json:"description,omitempty"`
Properties map[string]Schema `json:"properties,omitempty"`
Items *Schema `json:"items,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
Required []string `json:"required,omitempty"`
}
Schema represents a JSON schema for function parameters.
type Tool ¶
type Tool struct {
FunctionDeclarations []FunctionDeclaration `json:"functionDeclarations"`
}
Tool represents a set of function declarations available to the model.
type UsageMetadata ¶
type UsageMetadata struct {
PromptTokenCount int `json:"promptTokenCount"`
CandidatesTokenCount int `json:"candidatesTokenCount"`
TotalTokenCount int `json:"totalTokenCount"`
}
UsageMetadata contains token usage information.