Request translation for Google's Gemini Decisions API (POST /v1beta/decisions).
Gemini's format is close to System One: questions are a map of id to noul / choice
/ score, and answers come back as a map under the same ids with probabilities as
maps. The response needs no translation, so only the request is mapped:
| System One | Gemini Decisions |
|---|---|
state (any JSON) | input (text; non-string state is JSON-encoded) |
images: option | image blocks (data, mime_type), then the state as a text block |
noul criteria true / false | criteria: %{true_description, false_description} |
choice criteria: %{value => description} | the same; a missing description is "" |
score criteria: [description] | the same |
Non-string instructions and descriptions (System One allows objects and arrays) are JSON-encoded, since Gemini expects text.
Summary
Functions
Builds the /v1beta/decisions request body.
Functions
@spec encode_request(term(), map(), String.t() | nil, [String.t()]) :: {:ok, map()} | {:error, term()}
Builds the /v1beta/decisions request body.
iex> {:ok, body} =
...> SystemOneClient.Wire.GeminiDecisions.encode_request(
...> "I was charged twice.",
...> %{"urgent" => %{"type" => "noul", "instructions" => "Is this urgent?"}},
...> "gemini-decision-1"
...> )
iex> body
%{
model: "gemini-decision-1",
input: "I was charged twice.",
questions: %{"urgent" => %{type: "noul", instructions: "Is this urgent?"}}
}