Documentation ¶
Overview ¶
Package gemini provides a very minimal client for interacting with Gemini API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Candidate ¶
type Candidate struct { // Content is the generated text content for this candidate. Content *Content `json:"content"` }
Candidate represents a generated text candidate with a corresponding Content object.
type Client ¶
type Client struct { // APIKey is the API key used for authentication. APIKey string // HTTPClient is an optional HTTP client to use for requests. Defaults to // request.DefaultClient. HTTPClient *http.Client // Scrubber is an optional strings.Replacer that scrubs unwanted data from // error messages. Scrubber *strings.Replacer }
Client holds configuration for interacting with the Gemini API.
func (*Client) GenerateContent ¶
func (c *Client) GenerateContent(ctx context.Context, model string, params GenerateContentParams) (*GenerateContentResponse, error)
GenerateContent sends a request to the Gemini API to generate creative text content.
type Content ¶
type Content struct { // Parts is a list of Part objects representing the textual elements within // the content. Parts []*Part `json:"parts"` // Role is the producer of the content. Must be either 'user' or 'model'. Role string `json:"role,omitempty"` }
Content represents a piece of text content with a list of Part objects.
type GenerateContentParams ¶
type GenerateContentParams struct { // Contents is a list of Content objects representing the input text for // generation. Contents []*Content `json:"contents"` // SystemInstruction is an optional Content object specifying system // instructions for generation. SystemInstruction *Content `json:"systemInstruction,omitempty"` // SafetySettings is a list of unique SafetySetting instances for blocking // unsafe content. SafetySettings []*SafetySetting `json:"safetySettings,omitempty"` }
GenerateContentParams defines the structure for the request body sent to the GenerateContent API.
type GenerateContentResponse ¶
type GenerateContentResponse struct { // Candidates is a list of Candidate objects representing the generated text // alternatives. Candidates []*Candidate `json:"candidates"` }
GenerateContentResponse defines the structure of the response received from the GenerateContent API.
type HarmBlockThreshold ¶
type HarmBlockThreshold string
HarmBlockThreshold represents a threshold to block at and beyond a specified harm probability.
const (
BlockNone HarmBlockThreshold = "BLOCK_NONE"
)
See https://ai.google.dev/api/generate-content#harmblockthreshold for all thresholds.
type HarmCategory ¶
type HarmCategory string
HarmCategory covers various kinds of harms that can be filtered from model responses.
const ( DangerousContent HarmCategory = "HARM_CATEGORY_DANGEROUS_CONTENT" Harassment HarmCategory = "HARM_CATEGORY_HARASSMENT" HateSpeech HarmCategory = "HARM_CATEGORY_HATE_SPEECH" SexuallyExplicit HarmCategory = "HARM_CATEGORY_SEXUALLY_EXPLICIT" )
See https://ai.google.dev/api/generate-content#v1beta.HarmCategory for all categories.
type Part ¶
type Part struct { // Text is the content of the textual element. Text string `json:"text"` }
Part represents a textual element within a Content object.
type SafetySetting ¶
type SafetySetting struct { Category HarmCategory `json:"category"` Threshold HarmBlockThreshold `json:"threshold"` }
SafetySetting represents a safety setting, affecting the safety-blocking behavior.