Documentation
¶
Overview ¶
/ Package gemini provides the Gemini AI provider
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Candidate ¶
type Candidate struct { Content *CandidateContent `json:"content"` FinishReason string `json:"finishReason"` Index int `json:"index"` }
Candidate is the element of Response
type CandidateContent ¶
CandidateContent is the content of Candidate
type CandidateSafetyRating ¶
type CandidateSafetyRating struct { Category string `json:"category"` Probability string `json:"probability"` }
CandidateSafetyRating is the safetyRatings of Candidate
type FunctionCall ¶
FunctionCall is the functionCall of Part
type FunctionDeclaration ¶
type FunctionDeclaration struct { Name string `json:"name"` Description string `json:"description"` Parameters *FunctionParameters `json:"parameters"` }
FunctionDeclaration is the element of Tool
type FunctionParameters ¶
type FunctionParameters struct { Type string `json:"type"` Properties map[string]*Property `json:"properties"` Required []string `json:"required"` }
FunctionParameters is the parameters of FunctionDeclaration
type GeminiProvider ¶
type GeminiProvider struct {
APIKey string
}
GeminiProvider is the provider for Gemini
func NewProvider ¶
func NewProvider(apiKey string) *GeminiProvider
NewProvider creates a new GeminiProvider
func (*GeminiProvider) GetChatCompletions ¶
func (p *GeminiProvider) GetChatCompletions(userInstruction string, baseSystemMessage string, chainMessage ai.ChainMessage, md metadata.M, withTool bool) (*ai.InvokeResponse, error)
GetChatCompletions get chat completions for ai service
func (*GeminiProvider) Name ¶
func (p *GeminiProvider) Name() string
Name returns the name of the provider
type Part ¶
type Part struct { Text string `json:"text,omitempty"` FunctionCall *FunctionCall `json:"functionCall"` }
Part is the element of CandidateContent
type Parts ¶
type Parts struct {
Text string `json:"text"`
}
Parts is the contents.parts in RequestBody
type PromptFeedback ¶
type PromptFeedback struct {
SafetyRatings []*SafetyRating `json:"safetyRatings"`
}
PromptFeedback is the feedback of Prompt
type RequestBody ¶
RequestBody is the request body
type Response ¶
type Response struct { Candidates []Candidate `json:"candidates"` PromptFeedback PromptFeedback `json:"promptFeedback"` }
Response is the response of the Gemini API
type SafetyRating ¶
type SafetyRating struct { Category string `json:"category"` Probability string `json:"probability"` }
SafetyRating is the element of PromptFeedback
type Tool ¶
type Tool struct {
FunctionDeclarations []*FunctionDeclaration `json:"function_declarations"`
}
Tool is the element of tools in RequestBody
type UsageMetadata ¶
type UsageMetadata struct { PromptTokenCount int `json:"promptTokenCount"` TotalTokenCount int `json:"totalTokenCount"` }
UsageMetadata is the token usage in Response