-module(examples@ollama_thinking). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/examples/ollama_thinking.gleam"). -export([main/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(false). -file("src/examples/ollama_thinking.gleam", 16). ?DOC(false). -spec run_example(binary()) -> nil. run_example(Base_url) -> Client = starlet@ollama:new(Base_url), Result = begin Msg = <<"What is the sum of all prime numbers between 1 and 20? Think through this step by step."/utf8>>, Chat = begin _pipe = starlet:chat(Client, <<"qwen3:0.6b"/utf8>>), _pipe@1 = starlet@ollama:with_thinking(_pipe, thinking_enabled), starlet:user(_pipe@1, Msg) end, gleam_stdlib:println(<<"User: "/utf8, Msg/binary>>), gleam_stdlib:println(<<""/utf8>>), gleam@result:'try'( starlet:send(Chat), fun(_use0) -> {_, Turn} = _use0, case starlet@ollama:thinking(Turn) of {some, Thinking} -> gleam_stdlib:println( <<"=== Model's Thinking ==="/utf8>> ), gleam_stdlib:println(Thinking), gleam_stdlib:println(<<""/utf8>>); none -> gleam_stdlib:println(<<"(No thinking content)"/utf8>>) end, gleam_stdlib:println(<<"=== Model's Response ==="/utf8>>), gleam_stdlib:println(starlet:text(Turn)), {ok, nil} end ) end, case Result of {ok, _} -> nil; {error, Err} -> gleam_stdlib:println( <<"Error: "/utf8, (examples@utils:error_to_string(Err))/binary>> ) end. -file("src/examples/ollama_thinking.gleam", 9). ?DOC(false). -spec main() -> nil. main() -> Base_url = begin _pipe = envoy_ffi:get(<<"OLLAMA_BASE_URL"/utf8>>), gleam@result:unwrap(_pipe, <<"http://localhost:11434"/utf8>>) end, run_example(Base_url).