Documentation
¶
Index ¶
- func WithCachedContentName(name string) model.Option
- func WithImageConfig(cfg *genai.ImageConfig) model.Option
- func WithResponseJSONSchema(s *jsonschema.Schema) model.Option
- func WithResponseModalities(m []genai.Modality) model.Option
- func WithServerTools(tools []*ServerToolConfig) model.Option
- func WithThinkingConfig(t *genai.ThinkingConfig) model.Option
- func WithTopK(k int32) model.Option
- type CacheExpiration
- type CodeExecutionResult
- type Config
- type ExecutableCode
- type Language
- type Model
- func (g *Model) CreatePrefixCache(ctx context.Context, prefixMsgs []*schema.AgenticMessage, opts ...model.Option) (*genai.CachedContent, error)
- func (g *Model) Generate(ctx context.Context, input []*schema.AgenticMessage, opts ...model.Option) (*schema.AgenticMessage, error)
- func (g *Model) GetType() string
- func (g *Model) IsCallbacksEnabled() bool
- func (g *Model) Stream(ctx context.Context, input []*schema.AgenticMessage, opts ...model.Option) (*schema.StreamReader[*schema.AgenticMessage], error)
- type Outcome
- type ServerToolCallArguments
- type ServerToolCallResult
- type ServerToolConfig
- type ServerToolName
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCachedContentName ¶
WithCachedContentName the name of the content cached to use as context to serve the prediction. Format: cachedContents/{cachedContent}
func WithImageConfig ¶
func WithImageConfig(cfg *genai.ImageConfig) model.Option
WithImageConfig sets the image generation configuration. Note: an error will be returned for a model that does not support the configuration options. Optional.
func WithResponseJSONSchema ¶
func WithResponseJSONSchema(s *jsonschema.Schema) model.Option
func WithServerTools ¶
func WithServerTools(tools []*ServerToolConfig) model.Option
WithServerTools sets Gemini server-side tools for this request.
func WithThinkingConfig ¶
func WithThinkingConfig(t *genai.ThinkingConfig) model.Option
Types ¶
type CacheExpiration ¶
type CacheExpiration struct {
// TTL specifies how long prefix cache resources remain valid (now + TTL).
TTL *time.Duration
// ExpireTime sets the absolute expiration timestamp for prefix cache resources.
ExpireTime *time.Time
}
CacheExpiration configures the expiration policy for prefix cache resources. Exactly one field should be set.
type CodeExecutionResult ¶
type Config ¶
type Config struct {
// Client is the Gemini API client instance
// Required for making API calls to Gemini
Client *genai.Client
// Model specifies which Gemini model to use
// Examples: "gemini-pro", "gemini-pro-vision", "gemini-1.5-flash"
Model string
// MaxTokens limits the maximum number of tokens in the response
// Optional. Example: maxTokens := 100
MaxTokens *int
// Temperature controls randomness in responses
// Range: [0.0, 1.0], where 0.0 is more focused and 1.0 is more creative
// Optional. Example: temperature := float32(0.7)
Temperature *float32
// TopP controls diversity via nucleus sampling
// Range: [0.0, 1.0], where 1.0 disables nucleus sampling
// Optional. Example: topP := float32(0.95)
TopP *float32
// TopK controls diversity by limiting the top K tokens to sample from
// Optional. Example: topK := int32(40)
TopK *int32
// ResponseJSONSchema defines the structure for JSON responses
// Optional. Used when you want structured output in JSON format
ResponseJSONSchema *jsonschema.Schema
// SafetySettings configures content filtering for different harm categories
// Controls the model's filtering behavior for potentially harmful content
// Optional.
SafetySettings []*genai.SafetySetting
ThinkingConfig *genai.ThinkingConfig
// ImageConfig is the image generation configuration.
// Note: an error will be returned if this field is set for a model that does not support the configuration options.
// Optional.
ImageConfig *genai.ImageConfig
// ResponseModalities specifies the modalities the model can return.
// Optional.
ResponseModalities []genai.Modality
MediaResolution genai.MediaResolution
// CacheExpiration configures the expiration policy for prefix cache resources.
// Optional.
CacheExpiration *CacheExpiration
}
Config contains the configuration options for the Gemini agentic model
type ExecutableCode ¶
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func (*Model) CreatePrefixCache ¶
func (g *Model) CreatePrefixCache(ctx context.Context, prefixMsgs []*schema.AgenticMessage, opts ...model.Option) ( *genai.CachedContent, error)
CreatePrefixCache assembles inputs the same as Generate/Stream and writes the final system instruction, tools, and messages into a reusable prefix cache.
func (*Model) Generate ¶
func (g *Model) Generate(ctx context.Context, input []*schema.AgenticMessage, opts ...model.Option) (*schema.AgenticMessage, error)
func (*Model) IsCallbacksEnabled ¶
func (*Model) Stream ¶
func (g *Model) Stream(ctx context.Context, input []*schema.AgenticMessage, opts ...model.Option) (*schema.StreamReader[*schema.AgenticMessage], error)
type Outcome ¶
type Outcome string
const ( // OutcomeUnspecified specifies that unspecified status. This value should not be used. OutcomeUnspecified Outcome = "OUTCOME_UNSPECIFIED" // OutcomeOK specifies that code execution completed successfully. OutcomeOK Outcome = "OUTCOME_OK" // OutcomeFailed specifies that code execution finished but with a failure. `stderr` should contain the reason. OutcomeFailed Outcome = "OUTCOME_FAILED" // OutcomeDeadlineExceeded specifies that code execution ran for too long, and was cancelled. There may or may not be a partial // output present. OutcomeDeadlineExceeded Outcome = "OUTCOME_DEADLINE_EXCEEDED" )
type ServerToolCallArguments ¶
type ServerToolCallArguments struct {
ExecutableCode *ExecutableCode `json:"executable_code,omitempty" mapstructure:"executable_code,omitempty"`
}
type ServerToolCallResult ¶
type ServerToolCallResult struct {
CodeExecutionResult *CodeExecutionResult `json:"code_execution_result,omitempty" mapstructure:"code_execution_result,omitempty"`
}
type ServerToolConfig ¶
type ServerToolConfig struct {
CodeExecution *genai.ToolCodeExecution
GoogleSearch *genai.GoogleSearch
GoogleSearchRetrieval *genai.GoogleSearchRetrieval
URLContext *genai.URLContext
FileSearch *genai.FileSearch
GoogleMaps *genai.GoogleMaps
}
type ServerToolName ¶
type ServerToolName string
const (
ServerToolNameCodeExecution ServerToolName = "CodeExecution"
)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
generate
command
|
|
|
generate_with_image
command
|
|
|
generate_with_prefix_cache
command
|
|
|
image_generate
command
|
|
|
intent_tool
command
|
|
|
server_tool
command
|
|
|
stream
command
|