provider_options.go

 1// Package google provides an implementation of the fantasy AI SDK for Google's language models.
 2package google
 3
 4import "charm.land/fantasy"
 5
 6// ThinkingConfig represents thinking configuration for the Google provider.
 7type ThinkingConfig struct {
 8	ThinkingBudget  *int64 `json:"thinking_budget"`
 9	IncludeThoughts *bool  `json:"include_thoughts"`
10}
11
12// ReasoningMetadata represents reasoning metadata for the Google provider.
13type ReasoningMetadata struct {
14	Signature string `json:"signature"`
15}
16
17// Options implements the ProviderOptionsData interface for ReasoningMetadata.
18func (m *ReasoningMetadata) Options() {}
19
20// SafetySetting represents safety settings for the Google provider.
21type SafetySetting struct {
22	// 'HARM_CATEGORY_UNSPECIFIED',
23	// 'HARM_CATEGORY_HATE_SPEECH',
24	// 'HARM_CATEGORY_DANGEROUS_CONTENT',
25	// 'HARM_CATEGORY_HARASSMENT',
26	// 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
27	// 'HARM_CATEGORY_CIVIC_INTEGRITY',
28	Category string `json:"category"`
29
30	// 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',
31	// 'BLOCK_LOW_AND_ABOVE',
32	// 'BLOCK_MEDIUM_AND_ABOVE',
33	// 'BLOCK_ONLY_HIGH',
34	// 'BLOCK_NONE',
35	// 'OFF',
36	Threshold string `json:"threshold"`
37}
38
39// ProviderOptions represents additional options for the Google provider.
40type ProviderOptions struct {
41	ThinkingConfig *ThinkingConfig `json:"thinking_config"`
42
43	// Optional.
44	// The name of the cached content used as context to serve the prediction.
45	// Format: cachedContents/{cachedContent}
46	CachedContent string `json:"cached_content"`
47
48	// Optional. A list of unique safety settings for blocking unsafe content.
49	SafetySettings []SafetySetting `json:"safety_settings"`
50	// 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',
51	// 'BLOCK_LOW_AND_ABOVE',
52	// 'BLOCK_MEDIUM_AND_ABOVE',
53	// 'BLOCK_ONLY_HIGH',
54	// 'BLOCK_NONE',
55	// 'OFF',
56	Threshold string `json:"threshold"`
57}
58
59// Options implements the ProviderOptionsData interface for ProviderOptions.
60func (o *ProviderOptions) Options() {}
61
62// ParseOptions parses provider options from a map for the Google provider.
63func ParseOptions(data map[string]any) (*ProviderOptions, error) {
64	var options ProviderOptions
65	if err := fantasy.ParseOptions(data, &options); err != nil {
66		return nil, err
67	}
68	return &options, nil
69}