View Source GoogleAI.Model (google_ai v0.1.1)

A struct representing a Google AI model.

Summary

Types

Configuration used for tweaking model generation.

The structure of a GoogleAI get model response.

The structure of a GoogleAI list models response.

Configuration used for tweaking model safety.

t()

Type of the underlying model struct.

Functions

Get information about the model with the given model_name.

List information about the all models available on Google AI.

Create a new GoogleAI model from the given client and opts.

Types

@type generation_config() :: %{
  candidateCount: integer(),
  stopSequences: [String.t()],
  maxOutputTokens: integer(),
  temperature: float(),
  topP: number(),
  topK: number()
}

Configuration used for tweaking model generation.

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

The structure of a GoogleAI get model response.

Has the following format:

%{
  "name" => "models/gemini-pro",
  "version" => "001",
  "displayName" => "Gemini Pro",
  "description" => "The best model for scaling across a wide range of tasks",
  "inputTokenLimit" => 30720,
  "outputTokenLimit" => 2048,
  "supportedGenerationMethods" => [
    "generateContent",
    "countTokens"
  ],
  "temperature" => 0.9,
  "topP" => 1,
  "topK" => 1
}
Link to this type

list_models_response()

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

The structure of a GoogleAI list models response.

Has the following format:

%{
  "models" => [
    %{
      "name" => "models/gemini-pro",
      "version" => "001",
      "displayName" => "Gemini Pro",
      "description" => "The best model for scaling across a wide range of tasks",
      "inputTokenLimit" => 30720,
      "outputTokenLimit" => 2048,
      "supportedGenerationMethods" => [
        "generateContent",
        "countTokens"
      ],
      "temperature" => 0.9,
      "topP" => 1,
      "topK" => 1
    }
  ]
}
@type safety_settings() :: [%{category: String.t(), threshold: String.t()}]

Configuration used for tweaking model safety.

@type t() :: %GoogleAI.Model{
  client: GoogleAI.Client.t(),
  generation_config: generation_config(),
  model: String.t(),
  safety_settings: safety_settings()
}

Type of the underlying model struct.

Functions

Link to this function

get(client \\ GoogleAI.client(), model_name)

View Source
@spec get(client :: GoogleAI.Client.t(), model_name :: String.t()) ::
  GoogleAI.Http.response(get_model_response())

Get information about the model with the given model_name.

Arguments

  • :client - The GoogleAI.Client to use for this request.
  • :model_name - The name of the model to look up.

Returns

A map containing the fields of the get model response.

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

Link to this function

list(client \\ GoogleAI.client())

View Source

List information about the all models available on Google AI.

Arguments

Returns

A map containing the fields of the list models response.

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

Link to this function

new(client \\ GoogleAI.client(), opts)

View Source
@spec new(client :: GoogleAI.Client.t(), opts :: Keyword.t()) :: t()

Create a new GoogleAI model from the given client and opts.

The function new/1 will use the default GoogleAI API configuration.

Options

  • :model (String.t/0) - Required. The model name e.g. gemini-pro, gemini-pro-vision or embedding-001.

  • :generation_config (keyword/0) - The model generation configuration. These will be passed to requests as required.

  • :safety_settings (keyword/0) - The model safety settings. These will be passed to requests as required.

Examples

iex> client = GoogleAI.client(api_key: "asdfasdf") ...> GoogleAI.Model.new(client, model: "gemini-pro") %GoogleAI.Model{

client: %GoogleAI.Client{
  req: Req.new(
    url: "/:version/models/:model::action",
    base_url: "https://generativelanguage.googleapis.com",
    params: [key: "asdfasdf"], 
    path_params: [version: "v1beta", model: "gemini-pro"]
  )
},
model: "gemini-pro",
generation_config: nil,
safety_settings: nil

}