Documentation
¶
Overview ¶
Package google implements Gemini Live realtime sessions with the official Google Gen AI Go SDK.
Index ¶
- type Connection
- func (connection *Connection) AnswersToolCallsPerResponse() bool
- func (connection *Connection) CanReconnect() bool
- func (connection *Connection) Close(context.Context) error
- func (connection *Connection) Events(ctx context.Context) iter.Seq2[realtime.CodecEvent, error]
- func (connection *Connection) InputTranscriptionEnabled() bool
- func (connection *Connection) IsReconnecting() bool
- func (connection *Connection) ModelName() string
- func (*Connection) ReconnectRestoresInFlightState() bool
- func (connection *Connection) Send(ctx context.Context, input realtime.Input) error
- type Connector
- type LiveSession
- type Model
- type Option
- func WithAPIKey(key string) Option
- func WithAPIVersion(version string) Option
- func WithBaseURL(baseURL string) Option
- func WithClient(client *genai.Client) Option
- func WithConnector(connector Connector) Option
- func WithHTTPClient(client *http.Client) Option
- func WithProfile(override realtime.ProfileOverride) Option
- func WithSettings(settings Settings) Option
- func WithVertex(project, location string) Option
- type Settings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
Connection adapts one official SDK live session.
func (*Connection) AnswersToolCallsPerResponse ¶ added in v0.5.0
func (connection *Connection) AnswersToolCallsPerResponse() bool
AnswersToolCallsPerResponse reports that blocking tool results share one reply.
func (*Connection) CanReconnect ¶ added in v0.5.0
func (connection *Connection) CanReconnect() bool
CanReconnect reports whether another transport recovery is available.
func (*Connection) Close ¶
func (connection *Connection) Close(context.Context) error
Close closes the official SDK session once.
func (*Connection) Events ¶
func (connection *Connection) Events(ctx context.Context) iter.Seq2[realtime.CodecEvent, error]
func (*Connection) InputTranscriptionEnabled ¶
func (connection *Connection) InputTranscriptionEnabled() bool
InputTranscriptionEnabled reports configured native transcription.
func (*Connection) IsReconnecting ¶ added in v0.5.0
func (connection *Connection) IsReconnecting() bool
IsReconnecting reports that the current transport is being replaced.
func (*Connection) ModelName ¶
func (connection *Connection) ModelName() string
ModelName returns the requested model because Gemini Live does not report a replacement.
func (*Connection) ReconnectRestoresInFlightState ¶
func (*Connection) ReconnectRestoresInFlightState() bool
ReconnectRestoresInFlightState reports Gemini's native session behavior.
type Connector ¶
type Connector interface {
Connect(ctx context.Context, model string, config *genai.LiveConnectConfig) (LiveSession, error)
}
Connector opens official SDK live sessions.
type LiveSession ¶
type LiveSession interface {
SendClientContent(input genai.LiveClientContentInput) error
SendRealtimeInput(input genai.LiveRealtimeInput) error
SendToolResponse(input genai.LiveToolResponseInput) error
Receive() (*genai.LiveServerMessage, error)
Close() error
}
LiveSession is the official SDK session surface used by Connection.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model opens Gemini Live sessions.
func (*Model) Connect ¶
func (model *Model) Connect(ctx context.Context, params realtime.ConnectParams) (realtime.Connection, error)
Connect opens and configures a Gemini Live session.
func (*Model) ProviderName ¶
ProviderName returns the durable provider identity.
type Option ¶
type Option func(*Model)
Option configures a Model.
func WithAPIKey ¶
WithAPIKey sets a Gemini Developer API key instead of reading GOOGLE_API_KEY or GEMINI_API_KEY.
func WithAPIVersion ¶ added in v0.5.0
WithAPIVersion selects the Google API version. Gemini Developer API proactive audio requires v1alpha. The default is v1beta.
func WithBaseURL ¶
WithBaseURL sets a custom official SDK endpoint.
func WithClient ¶
WithClient uses an existing official Google Gen AI client.
func WithConnector ¶
WithConnector injects an official-SDK-compatible live connector.
func WithHTTPClient ¶
WithHTTPClient selects the client used by the official SDK.
func WithProfile ¶
func WithProfile(override realtime.ProfileOverride) Option
WithProfile applies a partial profile override.
func WithSettings ¶
WithSettings adds model-level Gemini Live defaults.
func WithVertex ¶
WithVertex selects Vertex AI and its project and location.
type Settings ¶
type Settings struct {
// Temperature controls response randomness.
Temperature *float32
// TopP controls nucleus sampling.
TopP *float32
// TopK limits the candidate tokens considered at each step.
TopK *float32
// Seed requests best-effort deterministic sampling.
Seed *int32
// Voice selects a Gemini prebuilt voice.
Voice string
// LanguageCode is the BCP 47 speech output language.
LanguageCode string
// InputTranscription enables native user speech transcription.
InputTranscription *bool
// OutputTranscription enables model speech transcription.
OutputTranscription *bool
// AffectiveDialog enables emotion-aware delivery where supported.
AffectiveDialog *bool
// ProactiveAudio allows the model to decide whether input needs a response.
ProactiveAudio *bool
// AsyncToolCalls keeps supported native-audio generation active while tools run.
AsyncToolCalls bool
// EnableSessionResumption explicitly controls provider resume handles.
EnableSessionResumption *bool
// ConfigOverrides applies advanced official SDK configuration last.
ConfigOverrides func(*genai.LiveConnectConfig)
}
Settings configures Gemini Live-specific generation, speech, and session behavior.