Documentation
¶
Overview ¶
Package gemini implements the LLM client adapter for Google Gemini models.
This adapter implements the ports.LLMClient interface defined in dago-libs, providing integration with the Google AI Gemini API.
Supported models:
- gemini-2.0-flash-exp
- gemini-1.5-pro
- gemini-1.5-flash
Usage:
import "github.com/aescanero/dago-adapters/pkg/llm/gemini"
client, err := gemini.NewClient(apiKey, logger)
if err != nil {
log.Fatal(err)
}
defer client.Close()
resp, err := client.GenerateCompletion(ctx, &domain.LLMRequest{
Model: "gemini-2.0-flash-exp",
Messages: []domain.Message{
{Role: "user", Content: "Hello!"},
},
})
Note: Gemini uses "model" role instead of "assistant" role. This adapter handles the conversion automatically.
Index ¶
- type Client
- func (c *Client) Close() error
- func (c *Client) Complete(ctx context.Context, req ports.CompletionRequest) (*ports.CompletionResponse, error)
- func (c *Client) CompleteStructured(ctx context.Context, req ports.CompletionRequest, schema ports.JSONSchema) (*ports.StructuredResponse, error)
- func (c *Client) CompleteWithTools(ctx context.Context, req ports.CompletionRequest, tools []ports.Tool) (*ports.CompletionResponse, error)
- func (c *Client) GenerateCompletion(ctx context.Context, req interface{}) (interface{}, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements the LLMClient interface for Google Gemini models
func (*Client) Complete ¶
func (c *Client) Complete(ctx context.Context, req ports.CompletionRequest) (*ports.CompletionResponse, error)
Complete performs a standard text completion (ports.LLMClient interface)
func (*Client) CompleteStructured ¶
func (c *Client) CompleteStructured(ctx context.Context, req ports.CompletionRequest, schema ports.JSONSchema) (*ports.StructuredResponse, error)
CompleteStructured performs a completion with guaranteed JSON schema conformance (ports.LLMClient interface)
func (*Client) CompleteWithTools ¶
func (c *Client) CompleteWithTools(ctx context.Context, req ports.CompletionRequest, tools []ports.Tool) (*ports.CompletionResponse, error)
CompleteWithTools performs a completion with tool calling support (ports.LLMClient interface)