gemini

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

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"`
	FinishMessage string           `json:"finishMessage"`
}

Candidate represents a single response candidate

type CandidateContent

type CandidateContent struct {
	Parts []Part `json:"parts"`
}

CandidateContent is the content of a candidate

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client communicates with the Vertex AI Gemini API

func NewClient

func NewClient(project, location, model, url, apiKey string, insecure bool, timeout time.Duration) *Client

NewClient creates a new Gemini client

func (*Client) Generate

func (c *Client) Generate(ctx context.Context, systemPrompt, userPrompt string, responseSchema any) (*llm.GenerateResult, error)

Generate calls the Gemini API

type Content

type Content struct {
	Parts []Part `json:"parts"`
}

Content holds text parts

type ContentItem

type ContentItem struct {
	Role  string `json:"role"`
	Parts []Part `json:"parts"`
}

ContentItem holds a role and parts

type GenerationConfig

type GenerationConfig struct {
	ResponseMIMEType   string `json:"responseMimeType"`
	ResponseJSONSchema any    `json:"responseJsonSchema,omitempty"`
}

GenerationConfig configures the generation

type Part

type Part struct {
	Text string `json:"text"`
}

Part is a text part

type Request

type Request struct {
	SystemInstruction *Content         `json:"systemInstruction,omitempty"`
	Contents          []ContentItem    `json:"contents"`
	GenerationConfig  GenerationConfig `json:"generationConfig"`
}

Request represents the Gemini API request

type Response

type Response struct {
	Candidates    []Candidate   `json:"candidates"`
	UsageMetadata UsageMetadata `json:"usageMetadata"`
}

Response represents the Gemini API response

type UsageMetadata

type UsageMetadata struct {
	PromptTokenCount     int `json:"promptTokenCount"`
	CandidatesTokenCount int `json:"candidatesTokenCount"`
	TotalTokenCount      int `json:"totalTokenCount"`
}

UsageMetadata contains token usage information

Jump to

Keyboard shortcuts

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