gen_ai_hub.orchestration_v2.models.embeddings module

Embeddings Module Configuration Models

class gen_ai_hub.orchestration_v2.models.embeddings.EmbeddingsEncodingFormat(*values)

Bases: str, Enum

Encoding format for the embeddings output.

Values:

FLOAT: Returns embeddings as an array of floats. BASE64: Returns embeddings as a base64 encoded string. BINARY: Returns embeddings in binary format.

FLOAT = 'float'
BASE64 = 'base64'
BINARY = 'binary'
class gen_ai_hub.orchestration_v2.models.embeddings.EmbeddingsInputType(*values)

Bases: str, Enum

Type hint for the embedding model about the purpose of the text.

Some models use asymmetric embeddings for better search performance.

Values:

TEXT: General purpose text (default). DOCUMENT: Content to be searched/retrieved. QUERY: Short search queries.

TEXT = 'text'
DOCUMENT = 'document'
QUERY = 'query'
class gen_ai_hub.orchestration_v2.models.embeddings.EmbeddingsModelParams(*, dimensions: int | None = None, encoding_format: EmbeddingsEncodingFormat | None = None, normalize: bool | None = None)

Bases: ABCBaseModel

Additional parameters for generating embeddings.

Parameters:
  • dimensions – The number of dimensions for the output embeddings.

  • encoding_format – The format for the embeddings output (float, base64, or binary).

  • normalize – Whether to normalize the embeddings.

dimensions: int | None
encoding_format: EmbeddingsEncodingFormat | None
normalize: bool | None
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.orchestration_v2.models.embeddings.EmbeddingsModelDetails(*, name: str, version: str | None = 'latest', params: EmbeddingsModelParams | None = None, timeout: Annotated[int | None, Ge(ge=1), Le(le=600)] = 600, max_retries: Annotated[int | None, Ge(ge=0), Le(le=5)] = 2)

Bases: ABCBaseModel

The model and parameters to be used for generating embeddings.

Parameters:
  • name – Name of the embedding model.

  • version – Version of the model to be used. Defaults to “latest”.

  • params – Additional parameters for the model (dimensions, encoding_format, normalize).

  • timeout – Timeout for the embeddings request in seconds. Ignored for Vertex AI models.

  • max_retries – Maximum number of retries. Ignored for Vertex AI models.

name: str
version: str | None
params: EmbeddingsModelParams | None
timeout: int | None
max_retries: int | None
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.orchestration_v2.models.embeddings.EmbeddingsModelConfig(*, model: EmbeddingsModelDetails)

Bases: ABCBaseModel

Configuration for the embeddings model.

Parameters:

model – The embedding model details.

model: EmbeddingsModelDetails
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.orchestration_v2.models.embeddings.EmbeddingsModuleConfigs(*, embeddings: EmbeddingsModelConfig, masking: MaskingModuleConfig | None = None)

Bases: ABCBaseModel

Module configurations for the embeddings endpoint.

Parameters:
  • embeddings – Required configuration for the embeddings model.

  • masking – Optional configuration for data masking before embedding.

embeddings: EmbeddingsModelConfig
masking: MaskingModuleConfig | None
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.orchestration_v2.models.embeddings.EmbeddingsOrchestrationConfig(*, modules: EmbeddingsModuleConfigs)

Bases: ABCBaseModel

Configuration for the Embeddings Orchestration endpoint.

Parameters:

modules – The module configurations including embeddings model and optional masking.

modules: EmbeddingsModuleConfigs
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.orchestration_v2.models.embeddings.EmbeddingsInput(*, text: str | List[str], type: EmbeddingsInputType | None = None)

Bases: ABCBaseModel

Input for the embeddings endpoint.

Parameters:
  • text – The text to embed. Can be a single string or a list of strings.

  • type – Optional type hint for the embedding model (text, document, or query).

text: str | List[str]
type_: EmbeddingsInputType | None
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.orchestration_v2.models.embeddings.EmbeddingsUsage(*, prompt_tokens: int, total_tokens: int)

Bases: ABCBaseModel

Token usage information for the embeddings request.

Parameters:
  • prompt_tokens – The number of tokens used by the prompt.

  • total_tokens – The total number of tokens used by the request.

prompt_tokens: int
total_tokens: int
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.orchestration_v2.models.embeddings.EmbeddingResult(*, object: str = 'embedding', embedding: List[float] | str, index: int)

Bases: ABCBaseModel

A single embedding result.

Parameters:
  • object – The object type, always “embedding”.

  • embedding – The embedding vector (array of floats) or base64 string.

  • index – The index of this embedding in the list.

object: str
embedding: List[float] | str
index: int
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.orchestration_v2.models.embeddings.EmbeddingsResponse(*, object: str = 'list', data: List[EmbeddingResult], model: str, usage: EmbeddingsUsage)

Bases: ABCBaseModel

The response from the embedding model, following OpenAI specification.

Parameters:
  • object – The object type, always “list”.

  • data – The list of embeddings generated by the model.

  • model – The name of the model used to generate the embeddings.

  • usage – Token usage information.

object: str
data: List[EmbeddingResult]
model: str
usage: EmbeddingsUsage
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.orchestration_v2.models.embeddings.EmbeddingsPostResponse(*, request_id: str, intermediate_results: Dict | None = None, final_result: EmbeddingsResponse)

Bases: ABCBaseModel

Response for an embeddings POST request.

Parameters:
  • request_id – Unique identifier for the request.

  • intermediate_results – Optional results from intermediate modules (e.g., masking).

  • final_result – The embeddings response from the model.

request_id: str
intermediate_results: Dict | None
final_result: EmbeddingsResponse
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class gen_ai_hub.orchestration_v2.models.embeddings.EmbeddingsRequest(*, config: EmbeddingsOrchestrationConfig, input: EmbeddingsInput)

Bases: ABCBaseModel

Request body for the embeddings endpoint.

Parameters:
  • config – The embeddings orchestration configuration.

  • input – The input text to embed.

config: EmbeddingsOrchestrationConfig
input: EmbeddingsInput
model_config: ClassVar[ConfigDict] = {'extra': 'forbid', 'frozen': False}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].