Geminix.V1beta.CountTokensRequest (geminix v0.2.0)

Counts the number of tokens in the prompt sent to a model. Models may tokenize text differently, so each model may return a different token_count.

Fields:

  • :contents (list of Geminix.V1beta.Content.t/0) - Optional. The input given to the model as a prompt. This field is ignored when generate_content_request is set.
  • :generate_content_request (Geminix.V1beta.GenerateContentRequest.t/0) - Optional. The overall input given to the Model. This includes the prompt as well as other model steering information like system instructions, and/or function declarations for function calling. Models/Contents and generate_content_requests are mutually exclusive. You can either send Model + Contents or a generate_content_request, but never both.

Summary

Types

t()

@type t() :: %Geminix.V1beta.CountTokensRequest{
  __meta__: term(),
  contents: [Geminix.V1beta.Content.t()],
  generate_content_request: Geminix.V1beta.GenerateContentRequest.t()
}

Functions

from_map(schema \\ %__MODULE__{}, map)

@spec from_map(t(), map()) :: {:ok, t()} | {:error, Ecto.Changeset.t()}

Create a Geminix.V1beta.CountTokensRequest.t/0 from a map returned by the Gemini API.

Sometimes, this function should not be applied to the full response body, but instead it should be applied to the correct part of the map in the response body. This depends on the concrete API call.