Documentation
¶
Overview ¶
Package google provides an implementation of the fantasy AI SDK for Google's language models.
Package google provides an implementation of the fantasy AI SDK for Google's language models.
Index ¶
- Constants
- func New(opts ...Option) (fantasy.Provider, error)
- type FileUploader
- type Option
- func WithBaseURL(baseURL string) Option
- func WithGeminiAPIKey(apiKey string) Option
- func WithHTTPClient(client *http.Client) Option
- func WithHeaders(headers map[string]string) Option
- func WithName(name string) Option
- func WithObjectMode(om fantasy.ObjectMode) Option
- func WithSkipAuth(skipAuth bool) Option
- func WithToolCallIDFunc(f ToolCallIDFunc) Option
- func WithVertex(project, location string) Option
- type ProviderOptions
- type ReasoningMetadata
- type SafetySetting
- type ThinkingConfig
- type ToolCallIDFunc
Constants ¶
const ( TypeProviderOptions = Name + ".options" TypeReasoningMetadata = Name + ".reasoning_metadata" )
Global type identifiers for Google-specific provider data.
const Name = "google"
Name is the name of the Google provider.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FileUploader ¶
type FileUploader struct {
// contains filtered or unexported fields
}
FileUploader is a utility for uploading files to Google Gemini File API.
func NewFileUploader ¶
func NewFileUploader(ctx context.Context, apiKey string) (*FileUploader, error)
NewFileUploader creates a new FileUploader.
type Option ¶
type Option = func(*options)
Option defines a function that configures Google provider options.
func WithBaseURL ¶
WithBaseURL sets the base URL for the Google provider.
func WithGeminiAPIKey ¶
WithGeminiAPIKey sets the Gemini API key for the Google provider.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client for the Google provider.
func WithHeaders ¶
WithHeaders sets the headers for the Google provider.
func WithObjectMode ¶
func WithObjectMode(om fantasy.ObjectMode) Option
WithObjectMode sets the object generation mode for the Google provider.
func WithSkipAuth ¶
WithSkipAuth configures whether to skip authentication for the Google provider.
func WithToolCallIDFunc ¶
func WithToolCallIDFunc(f ToolCallIDFunc) Option
WithToolCallIDFunc sets the function that generates a tool call ID.
func WithVertex ¶
WithVertex configures the Google provider to use Vertex AI.
type ProviderOptions ¶
type ProviderOptions struct {
ThinkingConfig *ThinkingConfig `json:"thinking_config"`
// Optional.
// The name of the cached content used as context to serve the prediction.
// Format: cachedContents/{cachedContent}
CachedContent string `json:"cached_content"`
// Optional. A list of unique safety settings for blocking unsafe content.
SafetySettings []SafetySetting `json:"safety_settings"`
// 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',
// 'BLOCK_LOW_AND_ABOVE',
// 'BLOCK_MEDIUM_AND_ABOVE',
// 'BLOCK_ONLY_HIGH',
// 'BLOCK_NONE',
// 'OFF',
Threshold string `json:"threshold"`
}
ProviderOptions represents additional options for the Google provider.
func ParseOptions ¶
func ParseOptions(data map[string]any) (*ProviderOptions, error)
ParseOptions parses provider options from a map for the Google provider.
func (ProviderOptions) MarshalJSON ¶
func (o ProviderOptions) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling with type info for ProviderOptions.
func (*ProviderOptions) Options ¶
func (o *ProviderOptions) Options()
Options implements the ProviderOptionsData interface for ProviderOptions.
func (*ProviderOptions) UnmarshalJSON ¶
func (o *ProviderOptions) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling with type info for ProviderOptions.
type ReasoningMetadata ¶
type ReasoningMetadata struct {
Signature string `json:"signature"`
ToolID string `json:"tool_id"`
}
ReasoningMetadata represents reasoning metadata for the Google provider.
func GetReasoningMetadata ¶
func GetReasoningMetadata(providerOptions fantasy.ProviderOptions) *ReasoningMetadata
GetReasoningMetadata extracts reasoning metadata from provider options for google models.
func (ReasoningMetadata) MarshalJSON ¶
func (m ReasoningMetadata) MarshalJSON() ([]byte, error)
MarshalJSON implements custom JSON marshaling with type info for ReasoningMetadata.
func (*ReasoningMetadata) Options ¶
func (m *ReasoningMetadata) Options()
Options implements the ProviderOptionsData interface for ReasoningMetadata.
func (*ReasoningMetadata) UnmarshalJSON ¶
func (m *ReasoningMetadata) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling with type info for ReasoningMetadata.
type SafetySetting ¶
type SafetySetting struct {
// 'HARM_CATEGORY_UNSPECIFIED',
// 'HARM_CATEGORY_HATE_SPEECH',
// 'HARM_CATEGORY_DANGEROUS_CONTENT',
// 'HARM_CATEGORY_HARASSMENT',
// 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
// 'HARM_CATEGORY_CIVIC_INTEGRITY',
Category string `json:"category"`
// 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',
// 'BLOCK_LOW_AND_ABOVE',
// 'BLOCK_MEDIUM_AND_ABOVE',
// 'BLOCK_ONLY_HIGH',
// 'BLOCK_NONE',
// 'OFF',
Threshold string `json:"threshold"`
}
SafetySetting represents safety settings for the Google provider.
type ThinkingConfig ¶
type ThinkingConfig struct {
ThinkingBudget *int64 `json:"thinking_budget"`
IncludeThoughts *bool `json:"include_thoughts"`
}
ThinkingConfig represents thinking configuration for the Google provider.
type ToolCallIDFunc ¶
type ToolCallIDFunc = func() string
ToolCallIDFunc defines a function that generates a tool call ID.