gemini

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

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

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 NewClient

func NewClient(apiKey string, logger *zap.Logger) (*Client, error)

NewClient creates a new Gemini client

func (*Client) Close

func (c *Client) Close() error

Close closes the Gemini client

func (*Client) Complete

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)

func (*Client) GenerateCompletion

func (c *Client) GenerateCompletion(ctx context.Context, req interface{}) (interface{}, error)

GenerateCompletion generates a completion using domain.LLMRequest (compatibility method)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL