AI.Util (fnord v0.8.24)

View Source

Summary

Functions

Creates an assistant message object, representing the assistant's response.

This is the tool call message, which must come immediately before the tool_msg/3 message with the same tool_call_id (id).

Builds a "transcript" of the research process by converting the messages into text. This is most commonly used to generate a transcript of the research performed in a conversation for various agents and tool calls.

Creates a system message object, used to define the assistant's behavior for the conversation.

This is the tool outputs message, which must come immediately after the assistant_tool_msg/3 message with the same tool_call_id (id).

Creates a user message object, representing the user's input prompt.

Extracts the user's most recent query from the conversation messages.

Types

content_msg()

@type content_msg() :: %{role: binary(), content: binary()}

msg()

tool_call()

@type tool_call() :: %{
  id: binary(),
  type: binary(),
  function: %{name: binary(), arguments: binary()}
}

tool_call_parsed()

@type tool_call_parsed() :: %{
  id: binary(),
  type: binary(),
  function: %{name: binary(), arguments: map()}
}

tool_request_msg()

@type tool_request_msg() :: %{
  role: binary(),
  content: nil,
  tool_calls: [tool_call_parsed()]
}

tool_response_msg()

@type tool_response_msg() :: %{
  role: binary(),
  name: binary(),
  tool_call_id: binary(),
  content: binary()
}

Functions

assistant_msg(msg)

@spec assistant_msg(binary()) :: content_msg()

Creates an assistant message object, representing the assistant's response.

assistant_tool_msg(id, func, args)

@spec assistant_tool_msg(binary(), binary(), binary()) :: tool_request_msg()

This is the tool call message, which must come immediately before the tool_msg/3 message with the same tool_call_id (id).

cosine_similarity(vec1, vec2)

@spec cosine_similarity([float()], [float()]) :: float()

research_transcript(msgs)

@spec research_transcript([msg()]) :: binary()

Builds a "transcript" of the research process by converting the messages into text. This is most commonly used to generate a transcript of the research performed in a conversation for various agents and tool calls.

system_msg(msg)

@spec system_msg(binary()) :: content_msg()

Creates a system message object, used to define the assistant's behavior for the conversation.

tool_msg(id, func, output)

@spec tool_msg(binary(), binary(), any()) :: tool_response_msg()

This is the tool outputs message, which must come immediately after the assistant_tool_msg/3 message with the same tool_call_id (id).

user_msg(msg)

@spec user_msg(binary()) :: content_msg()

Creates a user message object, representing the user's input prompt.

user_query(messages)

@spec user_query([msg()]) :: binary() | nil

Extracts the user's most recent query from the conversation messages.