# `SystemOneClient.Wire.GeminiDecisions`
[🔗](https://github.com/schainks/system_one_client/blob/v0.5.0/lib/system_one_client/wire/gemini_decisions.ex#L1)

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.

# `encode_request`

```elixir
@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?"}}
    }

---

*Consult [api-reference.md](api-reference.md) for complete listing*
