Documentation
¶
Overview ¶
Package gemini provides a client for the Google generative AI API.
Index ¶
- Constants
- type Client
- func (c *Client) Close() error
- func (c *Client) ListContextMessages() []*ContextMessage
- func (c *Client) ListModelNames(ctx context.Context) ([]string, error)
- func (c *Client) RefreshContext()
- func (c *Client) Send(ctx context.Context, prompt string, files ...string) (string, error)
- func (c *Client) SendStream(ctx context.Context, prompt string, files ...string) *aicli.StreamReply
- type ClientOption
- type ContextMessage
Constants ¶
View Source
const ( Model25Flash = "gemini-2.5-flash" Model25Pro = "gemini-2.5-pro" DefaultModel = Model25Flash RoleUser = "user" RoleModel = "model" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { ModelName string Cli *genai.Client Model *genai.GenerativeModel // contains filtered or unexported fields }
Client is a Google generative AI client.
func NewClient ¶
func NewClient(apiKey string, opts ...ClientOption) (*Client, error)
NewClient creates a new Google generative AI client.
func (*Client) ListContextMessages ¶
func (c *Client) ListContextMessages() []*ContextMessage
ListContextMessages list assistant context messages
func (*Client) ListModelNames ¶
ListModelNames lists the available models.
func (*Client) RefreshContext ¶
func (c *Client) RefreshContext()
RefreshContext refreshes assistant context
func (*Client) SendStream ¶
SendStream sends a prompt to the gemini model and returns a channel of responses.
type ClientOption ¶
type ClientOption func(*Client)
ClientOption is a function that sets a Client option.
func WithEnableContext ¶
func WithEnableContext() ClientOption
WithEnableContext enable assistant context
func WithInitialContextMessages ¶
func WithInitialContextMessages(messages ...*ContextMessage) ClientOption
WithInitialContextMessages sets assistant initial context messages
type ContextMessage ¶
type ContextMessage struct { Role string `json:"role"` // "user" or "model" Content string `json:"content"` }
ContextMessage chat history message
Click to show internal directories.
Click to hide internal directories.