-module(examples@ollama_list_models). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/examples/ollama_list_models.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_list_models.gleam", 8). ?DOC(false). -spec main() -> nil. main() -> Result = begin gleam@result:'try'( starlet@ollama:list_models(<<"http://localhost:11434"/utf8>>), fun(Models) -> gleam_stdlib:println(<<"Available models:"/utf8>>), gleam_stdlib:println(<<""/utf8>>), gleam@list:each( Models, fun(Model) -> gleam_stdlib:println( <<<<<<<<" "/utf8, (erlang:element(2, Model))/binary>>/binary, " ("/utf8>>/binary, (erlang:element(3, Model))/binary>>/binary, ")"/utf8>> ) end ), gleam_stdlib:println(<<""/utf8>>), gleam_stdlib:println( <<<<"Total: "/utf8, (erlang:integer_to_binary(erlang:length(Models)))/binary>>/binary, " models"/utf8>> ), {ok, nil} end ) end, case Result of {ok, _} -> nil; {error, Err} -> gleam_stdlib:println( <<"Error: "/utf8, (examples@utils:error_to_string(Err))/binary>> ) end.