Current section
Files
Jump to
Current section
Files
src/llmgleam@types.erl
-module(llmgleam@types).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/llmgleam/types.gleam").
-export([str_to_role/1]).
-export_type([role/0, chat_message/0, completion/0, completion_error/0]).
-type role() :: user | assistant.
-type chat_message() :: {chat_message, binary(), role()}.
-type completion() :: {completion, binary()}.
-type completion_error() :: {http_error, binary()} |
{json_error, binary()} |
{api_error, binary()}.
-file("src/llmgleam/types.gleam", 22).
-spec str_to_role(binary()) -> gleam@option:option(role()).
str_to_role(Role_str) ->
case Role_str of
<<"user"/utf8>> ->
{some, user};
<<"assistant"/utf8>> ->
{some, assistant};
<<"model"/utf8>> ->
{some, assistant};
_ ->
none
end.