google

package module
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

README

google

Package google exposes Google Gemini's native chat, embedding, image, speech, transcription, token-estimation adapters, and its first-party OpenAI-compatible endpoint. All constructors return Google-owned types.

Install

go get github.com/Tangerg/scope/models/google

Constructors

Every constructor validates its config and returns a value implementing the Model contracts in core:

  • NewAudioTTSModel
  • NewAudioTranscriptionModel
  • NewChat
  • NewEmbeddingModel
  • NewImageModel
  • NewOpenAIChat
  • NewTextEstimator

Testing

This module integrates a third-party service, so its tests cover what runs without live credentials: config validation, request and response mapping, and error classification. The shared conformance contract is core/modeltest for behavior and dev/providerconformance for construction and API consistency — this module runs it rather than copying it.

An integration probe skips unless its credential environment variable is set, so go test ./... is always runnable offline.

Boundaries

This is an independent leaf module: it carries only its own SDK dependency and never imports a sibling provider. The shared contract every module in this family obeys is in ../ARCHITECTURE.md.

See ARCHITECTURE.md for what this module owns.

Documentation

Overview

Package google exposes Google Gemini's native chat, embedding, image, speech, transcription, token-estimation adapters, and its first-party OpenAI-compatible endpoint. All constructors return Google-owned types.

Index

Constants

View Source
const (
	Provider       = "Google"
	DefaultBaseURL = protocol.DefaultBaseURL
	BaseURLOpenAI  = "https://generativelanguage.googleapis.com/v1beta/openai"

	RequestExtensionKey  = "google/request"
	ResponseExtensionKey = "google/response"

	SpeechRequestExtensionKey         = "google/speech_request"
	SpeechResponseExtensionKey        = "google/speech_response"
	TranscriptionRequestExtensionKey  = "google/transcription_request"
	TranscriptionResponseExtensionKey = "google/transcription_response"
	EmbeddingRequestExtensionKey      = "google/embedding_request"
	EmbeddingResponseExtensionKey     = "google/embedding_response"
	ImageRequestExtensionKey          = "google/image_request"
	ImageResponseExtensionKey         = "google/image_response"

	OpenAIRequestExtensionKey     = "google/openai_request"
	OpenAIResponseExtensionKey    = "google/openai_response"
	OpenAIStreamChunkExtensionKey = "google/openai_stream_chunk"

	ModelGemini36Flash      = protocol.ModelGemini36Flash
	ModelGemini35Flash      = protocol.ModelGemini35Flash
	ModelGemini35FlashLite  = protocol.ModelGemini35FlashLite
	ModelGemini31ProPreview = protocol.ModelGemini31ProPreview

	ModelGemini25FlashPreviewTTS = protocol.ModelGemini25FlashPreviewTTS
	ModelGemini25ProPreviewTTS   = protocol.ModelGemini25ProPreviewTTS
	ModelGemini31FlashTTSPreview = protocol.ModelGemini31FlashTTSPreview

	ModelGemini25FlashImage     = protocol.ModelGemini25FlashImage
	ModelGemini3ProImage        = protocol.ModelGemini3ProImage
	ModelGemini31FlashImage     = protocol.ModelGemini31FlashImage
	ModelGemini31FlashLiteImage = protocol.ModelGemini31FlashLiteImage

	ModelGeminiEmbedding2 = protocol.ModelGeminiEmbedding2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AudioTTSModel

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

func NewAudioTTSModel

func NewAudioTTSModel(config AudioTTSModelConfig) (*AudioTTSModel, error)

func (*AudioTTSModel) Call

func (a *AudioTTSModel) Call(ctx context.Context, req *tts.Request) (*tts.Response, error)

func (*AudioTTSModel) Stream

func (a *AudioTTSModel) Stream(ctx context.Context, req *tts.Request) iter.Seq2[*tts.Response, error]

type AudioTTSModelConfig

type AudioTTSModelConfig struct {
	APIKey         string
	DefaultOptions tts.Options
	BaseURL        string
	HTTPClient     *http.Client
}

func (AudioTTSModelConfig) Validate

func (a AudioTTSModelConfig) Validate() error

type AudioTranscriptionModel

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

func (*AudioTranscriptionModel) Call

type AudioTranscriptionModelConfig

type AudioTranscriptionModelConfig struct {
	APIKey         string
	DefaultOptions transcription.Options
	BaseURL        string
	HTTPClient     *http.Client
}

func (AudioTranscriptionModelConfig) Validate

func (a AudioTranscriptionModelConfig) Validate() error

type Chat

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

func NewChat

func NewChat(config ChatConfig) (*Chat, error)

func (*Chat) Call

func (c *Chat) Call(ctx context.Context, req *corechat.Request) (*corechat.Response, error)

func (*Chat) Stream

func (c *Chat) Stream(ctx context.Context, req *corechat.Request) iter.Seq2[*corechat.Response, error]

type ChatConfig

type ChatConfig struct {
	APIKey         string
	DefaultOptions corechat.Options
	BaseURL        string
	HTTPClient     *http.Client
}

func (ChatConfig) Validate

func (c ChatConfig) Validate() error

type EmbeddingModel

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

func NewEmbeddingModel

func NewEmbeddingModel(config EmbeddingModelConfig) (*EmbeddingModel, error)

func (*EmbeddingModel) Call

type EmbeddingModelConfig

type EmbeddingModelConfig struct {
	APIKey         string
	DefaultOptions embedding.Options
	BaseURL        string
	HTTPClient     *http.Client
}

func (EmbeddingModelConfig) Validate

func (e EmbeddingModelConfig) Validate() error

type ImageGenerationOptions

type ImageGenerationOptions struct {
	AspectRatio           string                    `json:"aspect_ratio,omitempty"`
	ImageSize             string                    `json:"image_size,omitempty"`
	Delivery              string                    `json:"delivery,omitempty"`
	PreviousInteractionID string                    `json:"previous_interaction_id,omitempty"`
	Store                 *bool                     `json:"store,omitempty"`
	ThinkingLevel         string                    `json:"thinking_level,omitempty"`
	ThinkingSummaries     string                    `json:"thinking_summaries,omitempty"`
	ServiceTier           string                    `json:"service_tier,omitempty"`
	Labels                map[string]string         `json:"labels,omitempty"`
	InputImages           []*media.Media            `json:"input_images,omitempty"`
	GoogleSearch          *ImageGoogleSearchOptions `json:"google_search,omitempty"`
	SafetySettings        []ImageSafetySetting      `json:"safety_settings,omitempty"`
}

type ImageGoogleSearchOptions

type ImageGoogleSearchOptions struct {
	SearchTypes []string `json:"search_types,omitempty"`
}

type ImageModel

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

func NewImageModel

func NewImageModel(config ImageModelConfig) (*ImageModel, error)

func (*ImageModel) Call

func (i *ImageModel) Call(ctx context.Context, req *image.Request) (*image.Response, error)

type ImageModelConfig

type ImageModelConfig struct {
	APIKey         string
	DefaultOptions image.Options
	BaseURL        string
	HTTPClient     *http.Client
}

func (ImageModelConfig) Validate

func (i ImageModelConfig) Validate() error

type ImageSafetySetting

type ImageSafetySetting struct {
	Type      string `json:"type"`
	Threshold string `json:"threshold"`
	Method    string `json:"method,omitempty"`
}

type OpenAIChat

type OpenAIChat = openaiprotocol.Chat

OpenAIChat is Google's OpenAI-compatible protocol model.

func NewOpenAIChat

func NewOpenAIChat(config OpenAIChatConfig) (*OpenAIChat, error)

type OpenAIChatConfig

type OpenAIChatConfig struct {
	APIKey         string
	DefaultOptions corechat.Options
	BaseURL        string
	HTTPClient     *http.Client
}

func (OpenAIChatConfig) Validate

func (o OpenAIChatConfig) Validate() error

type TextEstimator

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

func NewTextEstimator

func NewTextEstimator(config TextEstimatorConfig) (*TextEstimator, error)

func (*TextEstimator) EstimateText

func (t *TextEstimator) EstimateText(ctx context.Context, value string) (int, error)

type TextEstimatorConfig

type TextEstimatorConfig struct {
	APIKey     string
	Model      string
	BaseURL    string
	HTTPClient *http.Client
}

func (TextEstimatorConfig) Validate

func (t TextEstimatorConfig) Validate() error

Directories

Path Synopsis
internal
protocol
Package protocol implements the Google Gen AI wire protocol reused by Gemini and Vertex AI provider endpoints inside the models module.
Package protocol implements the Google Gen AI wire protocol reused by Gemini and Vertex AI provider endpoints inside the models module.
Package vertexai exposes Google Gen AI capabilities through Vertex AI's GCP backend and Application Default Credentials.
Package vertexai exposes Google Gen AI capabilities through Vertex AI's GCP backend and Application Default Credentials.

Jump to

Keyboard shortcuts

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