ExAgent.Services.GeminiEmbedService (ExAgent v0.3.0)

Copy Markdown View Source

HTTP service for the Gemini embeddings API.

Gemini's embedding models express the task in two incompatible ways, so the model name selects a family:

  • :task_type (gemini-embedding-001, text-embedding-004) - the task is a taskType enum field on the request, and truncated output is not normalized, so it is scaled client-side.
  • :prefix (gemini-embedding-2) - there is no taskType field; the task is written into the text itself, and truncated output is self-normalizing.

Requests always go through batchEmbedContents with one Content per input. A flat multi-input list returns a single aggregated vector on gemini-embedding-2, which would silently corrupt an entire index.

Summary

Functions

Generates embeddings for inputs.

Returns the task atoms this service accepts.

Functions

embed(provider, inputs, opts \\ [])

Generates embeddings for inputs.

Options

  • :model - defaults to "gemini-embedding-001". Never the provider's chat model.
  • :dimensions - sets outputDimensionality
  • :task - one of [:retrieval_query, :retrieval_document, :similarity, :classification, :clustering, :question_answering, :fact_verification, :code_query]
  • :embedding_family - :task_type or :prefix, to use a model this library does not know yet
  • :args - Gemini exposes nothing beyond the above, so any key here is rejected rather than silently ignored by the API

tasks()

@spec tasks() :: [ExAgent.Embeddings.task()]

Returns the task atoms this service accepts.