Documentation
¶
Overview ¶
Package gemini provides Google Gemini provider adapter for the OmniLLM unified interface
Package gemini provides Google Gemini API client implementation
Index ¶
- func NewProvider(apiKey string) provider.Provider
- func NewProviderWithContext(ctx context.Context, apiKey string) (provider.Provider, error)
- type Choice
- type Chunk
- type Client
- type Message
- type Provider
- func (p *Provider) Close() error
- func (p *Provider) CreateChatCompletion(ctx context.Context, req *provider.ChatCompletionRequest) (*provider.ChatCompletionResponse, error)
- func (p *Provider) CreateChatCompletionStream(ctx context.Context, req *provider.ChatCompletionRequest) (provider.ChatCompletionStream, error)
- func (p *Provider) Name() string
- type Request
- type Response
- type ResponseFormat
- type Stream
- type StreamAdapter
- type Usage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewProvider ¶
NewProvider creates a new Gemini provider adapter
Types ¶
type Choice ¶
type Choice struct {
Index int `json:"index"`
Message Message `json:"message"`
Delta *Message `json:"delta,omitempty"`
FinishReason *string `json:"finish_reason"`
}
Choice represents a choice in the response
type Chunk ¶
type Chunk struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []Choice `json:"choices"`
Usage *Usage `json:"usage,omitempty"`
}
Chunk represents a chunk in streaming response
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements Google Gemini API client
func NewWithContext ¶
NewWithContext creates a new Gemini client with context
func (*Client) CreateCompletion ¶
CreateCompletion creates a chat completion
func (*Client) CreateCompletionStream ¶
CreateCompletionStream creates a streaming chat completion
type Message ¶
type Message struct {
Role string `json:"role"`
Content string `json:"content"`
Name *string `json:"name,omitempty"`
}
Message represents a chat message
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider represents the Gemini provider adapter
func (*Provider) CreateChatCompletion ¶
func (p *Provider) CreateChatCompletion(ctx context.Context, req *provider.ChatCompletionRequest) (*provider.ChatCompletionResponse, error)
CreateChatCompletion creates a chat completion
func (*Provider) CreateChatCompletionStream ¶
func (p *Provider) CreateChatCompletionStream(ctx context.Context, req *provider.ChatCompletionRequest) (provider.ChatCompletionStream, error)
CreateChatCompletionStream creates a streaming chat completion
type Request ¶
type Request struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
MaxTokens *int `json:"max_tokens,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
TopK *int `json:"top_k,omitempty"`
Stream *bool `json:"stream,omitempty"`
Stop []string `json:"stop,omitempty"`
PresencePenalty *float64 `json:"presence_penalty,omitempty"`
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
LogitBias map[string]int `json:"logit_bias,omitempty"`
User *string `json:"user,omitempty"`
ResponseFormat *ResponseFormat `json:"response_format,omitempty"`
}
Request represents a Gemini chat completion request
type Response ¶
type Response struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []Choice `json:"choices"`
Usage Usage `json:"usage"`
}
Response represents a Gemini chat completion response
type ResponseFormat ¶ added in v0.11.0
type ResponseFormat struct {
Type string `json:"type"` // "text" or "json_object"
}
ResponseFormat specifies the format of the response
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
Stream represents a streaming response
type StreamAdapter ¶
type StreamAdapter struct {
// contains filtered or unexported fields
}
StreamAdapter adapts Gemini stream to unified interface
func (*StreamAdapter) Recv ¶
func (s *StreamAdapter) Recv() (*provider.ChatCompletionChunk, error)
Recv receives the next chunk from the stream