Current section
Files
Jump to
Current section
Files
src/pig@ai@message.erl
-module(pig@ai@message).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/pig/ai/message.gleam").
-export([role/1]).
-export_type([tool_call/0, thinking/0, message/0, role/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.
-type tool_call() :: {tool_call, binary(), binary(), binary()}.
-type thinking() :: {thinking, binary()}.
-type message() :: {user, binary()} |
{system, binary()} |
{assistant,
binary(),
list(tool_call()),
gleam@option:option(thinking()),
gleam@option:option(pig@ai@stop_reason:stop_reason())} |
{tool, binary(), binary()}.
-type role() :: user_role | assistant_role | system_role | tool_role.
-file("src/pig/ai/message.gleam", 36).
?DOC(" Get the role of a message.\n").
-spec role(message()) -> role().
role(Msg) ->
case Msg of
{user, _} ->
user_role;
{system, _} ->
system_role;
{assistant, _, _, _, _} ->
assistant_role;
{tool, _, _} ->
tool_role
end.