View Source GoogleAI.Embedding (google_ai v0.1.0)

This module provides an implementation of the Google AI embeddings API. The API reference can be found at https://ai.google.dev/tutorials/rest_quickstart#embedding.

Summary

Types

The structure of a GoogleAI batch embedding request.

The structure of a GoogleAI batch embedding response.

The structure of a GoogleAI embedding request.

The structure of a GoogleAI embedding response.

Functions

Create an embedding using the given model for the given input.

Types

@type batch_embed_request() :: %{requests: [embed_request()]}

The structure of a GoogleAI batch embedding request.

Link to this type

batch_embed_response()

View Source
@type batch_embed_response() :: %{
  required(String.t()) => [%{required(String.t()) => [float()]}]
}

The structure of a GoogleAI batch embedding response.

Has the following format:

%{
  "embeddings" => [%{
    "values" => [
      0.0234234,
      0.3214135,
      0.5645654,
      ...
    ]
  }]
}
@type embed_request() :: %{
  model: String.t(),
  content: %{parts: [%{text: String.t()}]}
}

The structure of a GoogleAI embedding request.

@type embed_response() :: %{
  required(String.t()) => %{required(String.t()) => [float()]}
}

The structure of a GoogleAI embedding response.

Has the following format:

%{
  "embedding" => %{
    "values" => [
      0.0234234,
      0.3214135,
      0.5645654,
      ...
    ]
  }
}

Functions

Create an embedding using the given model for the given input.

Arguments

  • :model - The GoogleAI.Model to use for this request.
  • :input - Either a single string or a list of strings. In the case that it is a list, the batchEmbedContents action will be used.

Returns

A map containing the fields of the embedding response.

See https://ai.google.dev/tutorials/rest_quickstart#embedding.