Documentation
¶
Overview ¶
Package vertex provides embedding generation via Google Vertex AI's text-embedding models.
Vertex is not OpenAI-wire-compatible: embeddings are produced by POSTing to .../publishers/google/models/{model}:predict with
{"instances":[{"content":"…","task_type":"…"}],"parameters":{…}}
and reading back
{"predictions":[{"embeddings":{"values":[…],"statistics":{"token_count":N}}}]}
so it needs its own provider type rather than a transport-level rewrite of an OpenAI body (#1301).
Authentication is a GCP OAuth2 bearer token applied by the HTTP client's transport (see providers.ResolveEmbeddingTransport with platform "vertex"), so this package never handles credentials directly.
Index ¶
Constants ¶
const DefaultModel = "text-embedding-005"
DefaultModel is Google's current general-purpose text embedding model.
const DefaultTaskType = "RETRIEVAL_DOCUMENT"
DefaultTaskType is Vertex's task type for embedding documents to be indexed. Use "RETRIEVAL_QUERY" when embedding a search query; the two produce different vectors on purpose.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmbeddingOption ¶
type EmbeddingOption func(*EmbeddingProvider)
EmbeddingOption configures the EmbeddingProvider.
func WithPlatformAuth ¶
func WithPlatformAuth() EmbeddingOption
WithPlatformAuth marks the provider as authenticated by its HTTP client's transport. Vertex has no API-key mode, so this is always the case in real use; the flag exists for symmetry with the other embedding providers.
func WithTaskType ¶
func WithTaskType(taskType string) EmbeddingOption
WithTaskType sets the Vertex task type ("RETRIEVAL_DOCUMENT", "RETRIEVAL_QUERY", "SEMANTIC_SIMILARITY", …).
func WithWiring ¶
func WithWiring(w providers.EmbeddingWiring) EmbeddingOption
WithWiring applies the transport-derived settings the factory resolved.
type EmbeddingProvider ¶
type EmbeddingProvider struct {
*providers.BaseEmbeddingProvider
// contains filtered or unexported fields
}
EmbeddingProvider implements embedding generation via Vertex AI.
func NewEmbeddingProvider ¶
func NewEmbeddingProvider(opts ...EmbeddingOption) (*EmbeddingProvider, error)
NewEmbeddingProvider creates a Vertex embedding provider. It fails when the model is not a recognized embedding family rather than sending a body the endpoint would reject at request time.
func (*EmbeddingProvider) Embed ¶
func (p *EmbeddingProvider) Embed( ctx context.Context, req providers.EmbeddingRequest, ) (providers.EmbeddingResponse, error)
Embed generates embeddings for the given texts.