Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) GenerateContent(ctx context.Context, systemPrompt, userPrompt string) (string, error)
- func (c *Client) GetLastUsage() *TokenUsage
- func (c *Client) GetModelID() string
- func (c *Client) LoadSession(sessionName string) error
- func (c *Client) SaveSession(sessionName string) error
- func (c *Client) SendMessage(ctx context.Context, message string, webSearchEnabled bool) (string, error)
- func (c *Client) SendMessageStream(ctx context.Context, message string, callback StreamCallback, ...) (string, error)
- func (c *Client) StartChat(systemPrompt string)
- type SessionData
- type StreamCallback
- type TokenUsage
Constants ¶
const ChunkChannelBufferSize = 10
ChunkChannelBufferSize is the buffer size for chunk channels in UI streaming Buffer of 10 provides smooth chunk delivery without blocking the producer
const DefaultHistoryCapacity = 20
DefaultHistoryCapacity is the default capacity for pre-allocating chat history slice
const DefaultModelTemperature = float32(0.3)
DefaultModelTemperature is the default temperature parameter
const DefaultModelTopK = 40
DefaultModelTopK is the default topK parameter
const DefaultModelTopP = float32(0.95)
DefaultModelTopP is the default topP parameter
const DoneChannelBufferSize = 1
DoneChannelBufferSize is the buffer size for completion channels Buffer of 1 is sufficient as only one completion signal is sent per operation
const ErrorChannelBufferSize = 1
ErrorChannelBufferSize is the buffer size for error channels Buffer of 1 is sufficient as only one error is sent per operation
const StreamChannelBufferSize = 20
StreamChannelBufferSize is the buffer size for streaming result channels Buffer of 20 allows producer (goroutine) to continue without blocking while consumer processes results, improving streaming performance
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GenerateContent ¶
func (c *Client) GenerateContent(ctx context.Context, systemPrompt, userPrompt string) (string, error)
GenerateContent remains simple for one-off calls
func (*Client) GetLastUsage ¶
func (c *Client) GetLastUsage() *TokenUsage
func (*Client) GetModelID ¶
func (*Client) LoadSession ¶
LoadSession loads a session (history and system prompt) from disk
func (*Client) SaveSession ¶
SaveSession saves the current session (history and system prompt) to disk
func (*Client) SendMessage ¶
func (c *Client) SendMessage(ctx context.Context, message string, webSearchEnabled bool) (string, error)
SendMessage sends a message with history and optional Web Search
func (*Client) SendMessageStream ¶
func (c *Client) SendMessageStream(ctx context.Context, message string, callback StreamCallback, webSearchEnabled bool) (string, error)
SendMessageStream streams responses while maintaining history
type SessionData ¶
type SessionData struct {
SystemPrompt string `json:"systemPrompt"`
History []*genai.Content `json:"history"`
ModelID string `json:"modelID"`
}
SessionData represents the serializable session state
type TokenUsage ¶
TokenUsage matches the new SDK field names