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// SafetySetting represents safety settings for the Google provider.
13type SafetySetting struct {
14	// 'HARM_CATEGORY_UNSPECIFIED',
15	// 'HARM_CATEGORY_HATE_SPEECH',
16	// 'HARM_CATEGORY_DANGEROUS_CONTENT',
17	// 'HARM_CATEGORY_HARASSMENT',
18	// 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
19	// 'HARM_CATEGORY_CIVIC_INTEGRITY',
20	Category string `json:"category"`
21
22	// 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',
23	// 'BLOCK_LOW_AND_ABOVE',
24	// 'BLOCK_MEDIUM_AND_ABOVE',
25	// 'BLOCK_ONLY_HIGH',
26	// 'BLOCK_NONE',
27	// 'OFF',
28	Threshold string `json:"threshold"`
29}
30
31// ProviderOptions represents additional options for the Google provider.
32type ProviderOptions struct {
33	ThinkingConfig *ThinkingConfig `json:"thinking_config"`
34
35	// Optional.
36	// The name of the cached content used as context to serve the prediction.
37	// Format: cachedContents/{cachedContent}
38	CachedContent string `json:"cached_content"`
39
40	// Optional. A list of unique safety settings for blocking unsafe content.
41	SafetySettings []SafetySetting `json:"safety_settings"`
42	// 'HARM_BLOCK_THRESHOLD_UNSPECIFIED',
43	// 'BLOCK_LOW_AND_ABOVE',
44	// 'BLOCK_MEDIUM_AND_ABOVE',
45	// 'BLOCK_ONLY_HIGH',
46	// 'BLOCK_NONE',
47	// 'OFF',
48	Threshold string `json:"threshold"`
49}
50
51// Options implements the ProviderOptionsData interface for ProviderOptions.
52func (o *ProviderOptions) Options() {}
53
54// ParseOptions parses provider options from a map for the Google provider.
55func ParseOptions(data map[string]any) (*ProviderOptions, error) {
56	var options ProviderOptions
57	if err := fantasy.ParseOptions(data, &options); err != nil {
58		return nil, err
59	}
60	return &options, nil
61}