Documentation
¶
Index ¶
- Constants
- func Prompt(systemPrompt, userPrompt, jsonSchema, apiKey string, files ...File) (string, error)
- type Candidate
- type Content
- type File
- type FileData
- type FileUploadInfo
- type FileUploadRequest
- type FileUploadResponse
- type GenerationConfig
- type GoogleRequest
- type GoogleResponse
- type JsonSchema
- type Part
- type Provider
- type SafetyRating
- type UsageMetadata
Constants ¶
const ( // Endpoint is the Google Generative AI API endpoint Endpoint = "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent" // FilesEndpoint is the Google Files API endpoint for uploads FilesEndpoint = "https://generativelanguage.googleapis.com/upload/v1beta/files" // Model is the default Gemini model to use Model = "gemini-2.5-flash" )
API Configuration Constants
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Candidate ¶
type Candidate struct {
Content struct {
Parts []Part `json:"parts"`
Role string `json:"role"`
} `json:"content"`
FinishReason string `json:"finishReason"`
Index int `json:"index"`
SafetyRatings []SafetyRating `json:"safetyRatings"`
}
Candidate represents a response candidate
type Content ¶
type Content struct {
Parts []Part `json:"parts"`
}
Content represents a content part in the request
type File ¶ added in v0.2.2
type File struct {
URI string `json:"uri"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
MimeType string `json:"mime_type"`
SizeBytes int64 `json:"size_bytes"`
State string `json:"state"`
}
File represents an uploaded file
func UploadFile ¶ added in v0.2.2
UploadFile uploads a file to Google and returns file metadata
type FileUploadInfo ¶ added in v0.2.2
type FileUploadInfo struct {
DisplayName string `json:"display_name"`
}
FileUploadInfo represents file metadata for upload
type FileUploadRequest ¶ added in v0.2.2
type FileUploadRequest struct {
File FileUploadInfo `json:"file"`
}
FileUploadRequest represents the initial upload request
type FileUploadResponse ¶ added in v0.2.2
type FileUploadResponse struct {
File File `json:"file"`
}
FileUploadResponse wraps the uploaded file
type GenerationConfig ¶
type GenerationConfig struct {
ResponseMimeType string `json:"responseMimeType,omitempty"`
ResponseSchema interface{} `json:"responseSchema,omitempty"`
}
GenerationConfig configures the generation parameters
type GoogleRequest ¶
type GoogleRequest struct {
Contents []Content `json:"contents"`
GenerationConfig *GenerationConfig `json:"generationConfig,omitempty"`
}
GoogleRequest represents the request body for Google's API
type GoogleResponse ¶
type GoogleResponse struct {
Candidates []Candidate `json:"candidates"`
UsageMetadata UsageMetadata `json:"usageMetadata"`
}
GoogleResponse represents the API response structure
type JsonSchema ¶
type JsonSchema struct {
Type string `json:"type"`
Properties map[string]interface{} `json:"properties,omitempty"`
Items interface{} `json:"items,omitempty"`
Required []string `json:"required,omitempty"`
Description string `json:"description,omitempty"`
}
JsonSchema represents Google's JSON schema structure for structured output
type Part ¶
type Part struct {
Text string `json:"text,omitempty"`
FileData *FileData `json:"file_data,omitempty"`
}
Part represents a text or file part of the content
type Provider ¶ added in v0.2.5
type Provider struct{}
Provider implements the internal.Provider interface for Google
func NewProvider ¶ added in v0.2.5
func NewProvider() *Provider
NewProvider creates a new Google provider
type SafetyRating ¶
type SafetyRating struct {
Category string `json:"category"`
Probability string `json:"probability"`
}
SafetyRating represents safety assessment
type UsageMetadata ¶
type UsageMetadata struct {
PromptTokenCount int `json:"promptTokenCount"`
CandidatesTokenCount int `json:"candidatesTokenCount"`
TotalTokenCount int `json:"totalTokenCount"`
}
UsageMetadata represents token usage information