-module(glean@models@openai_reasoning). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/glean/models/openai_reasoning.gleam"). -export([max_output_tokens/2, stop_sequences/2, build/1, gpt5_nano/1, gpt5_mini/1, o3/1, o3_mini/1, o3_pro/1, o1/1, o4_mini/1]). -export_type([reasoning/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC( " OpenAI reasoning models (o-series and GPT-5 mini/nano).\n" "\n" " These models use chain-of-thought reasoning and do NOT support\n" " temperature, top_p, seed, presence_penalty, or frequency_penalty.\n" " Supported parameters: max_output_tokens, stop_sequences.\n" "\n" " For standard GPT models that support the full set of sampling\n" " parameters, see `glean/models/openai`.\n" ). -opaque reasoning() :: {reasoning, binary(), binary(), gleam@option:option(integer()), gleam@option:option(list(binary())), gleam@option:option({binary(), binary()})}. -file("src/glean/models/openai_reasoning.gleam", 78). ?DOC(" Set the maximum number of output tokens.\n"). -spec max_output_tokens(reasoning(), integer()) -> reasoning(). max_output_tokens(M, N) -> {reasoning, erlang:element(2, M), erlang:element(3, M), {some, N}, erlang:element(5, M), erlang:element(6, M)}. -file("src/glean/models/openai_reasoning.gleam", 84). ?DOC( " Set stop sequences — the model will stop generating when it encounters\n" " any of these strings.\n" ). -spec stop_sequences(reasoning(), list(binary())) -> reasoning(). stop_sequences(M, Stops) -> {reasoning, erlang:element(2, M), erlang:element(3, M), erlang:element(4, M), {some, Stops}, erlang:element(6, M)}. -file("src/glean/models/openai_reasoning.gleam", 96). ?DOC( " Build a `Model` from this reasoning model configuration.\n" "\n" " If the model is deprecated, a warning is printed and the replacement\n" " model ID is used instead.\n" ). -spec build(reasoning()) -> glean@model:model(). build(M) -> Actual_model_id = case erlang:element(6, M) of none -> erlang:element(3, M); {some, {Replacement, Shutdown}} -> glean@model:deprecation_warning( erlang:element(3, M), Replacement, Shutdown ), Replacement end, Provider = glean@providers@openai:new(erlang:element(2, M), Actual_model_id), Settings = {model_settings, erlang:element(4, M), none, none, none, erlang:element(5, M), none, none, none}, {model, Provider, Settings}. -file("src/glean/models/openai_reasoning.gleam", 127). -spec new_reasoning(binary(), binary()) -> reasoning(). new_reasoning(Api_key, Model_id) -> {reasoning, Api_key, Model_id, none, none, none}. -file("src/glean/models/openai_reasoning.gleam", 33). ?DOC(" GPT-5 Nano — lightweight reasoning model\n"). -spec gpt5_nano(binary()) -> reasoning(). gpt5_nano(Key) -> new_reasoning(Key, <<"gpt-5-nano"/utf8>>). -file("src/glean/models/openai_reasoning.gleam", 38). ?DOC(" GPT-5 Mini — compact reasoning model\n"). -spec gpt5_mini(binary()) -> reasoning(). gpt5_mini(Key) -> new_reasoning(Key, <<"gpt-5-mini"/utf8>>). -file("src/glean/models/openai_reasoning.gleam", 43). ?DOC(" o3\n"). -spec o3(binary()) -> reasoning(). o3(Key) -> new_reasoning(Key, <<"o3"/utf8>>). -file("src/glean/models/openai_reasoning.gleam", 48). ?DOC(" o3-mini\n"). -spec o3_mini(binary()) -> reasoning(). o3_mini(Key) -> new_reasoning(Key, <<"o3-mini"/utf8>>). -file("src/glean/models/openai_reasoning.gleam", 53). ?DOC(" o3-pro\n"). -spec o3_pro(binary()) -> reasoning(). o3_pro(Key) -> new_reasoning(Key, <<"o3-pro"/utf8>>). -file("src/glean/models/openai_reasoning.gleam", 137). -spec new_deprecated_reasoning(binary(), binary(), binary(), binary()) -> reasoning(). new_deprecated_reasoning(Api_key, Model_id, Replacement, Shutdown) -> {reasoning, Api_key, Model_id, none, none, {some, {Replacement, Shutdown}}}. -file("src/glean/models/openai_reasoning.gleam", 63). ?DOC(" o1 — deprecated, will be replaced by o3 at build time.\n"). -spec o1(binary()) -> reasoning(). o1(Key) -> new_deprecated_reasoning( Key, <<"o1"/utf8>>, <<"o3"/utf8>>, <<"already deprecated"/utf8>> ). -file("src/glean/models/openai_reasoning.gleam", 69). ?DOC(" o4-mini — deprecated, will be replaced by o3-mini at build time.\n"). -spec o4_mini(binary()) -> reasoning(). o4_mini(Key) -> new_deprecated_reasoning( Key, <<"o4-mini"/utf8>>, <<"o3-mini"/utf8>>, <<"Feb 16, 2026"/utf8>> ).