AI.Agent.Code.Common (fnord v0.8.83)
View SourceSummary
Types
Common state for AI agents that work with code. Includes an internal map
that can be used to store additional state that is specific to the
implementation.
Functions
Returns a string that describes the values and principles that guide the code agent's design and implementation decisions. This is used to inform the AI agent's behavior and responses, ensuring that it adheres to a consistent set of coding standards and practices.
Executes a completion request using the AI model specified in the state. The
prompt is appended to the existing messages in the state as a system
message. Unless keep_prompt? is true, the system prompt will be removed
from the messages after the completion is received to keep the cascade of
instructions clean.
Retrieves a value from the internal state of the AI agent. key may be
either a single atom or a list of atoms representing a path to a value in the
internal map (per get_in/2 semantics).
Creates a new state for an AI agent that works with code. The initial message list includes the system prompt and the user prompt, as provided.
Sets the internal, implementation-specific state for the AI agent. key
may be either a single atom or a list of atoms representing a path to a value
in the internal map (per put_in/3 semantics).
Types
@type t() :: %AI.Agent.Code.Common{ agent: AI.Agent.t(), error: any(), internal: map(), messages: AI.Util.msg_list(), model: AI.Model.t(), request: binary(), response: binary() | nil, toolbox: AI.Tools.toolbox() }
Common state for AI agents that work with code. Includes an internal map
that can be used to store additional state that is specific to the
implementation.
@type task() :: Services.Task.task()
Functions
@spec add_task(Services.Task.list_id(), new_task()) :: any()
@spec add_tasks(Services.Task.list_id(), [new_task()]) :: :ok
@spec coder_values_prompt() :: binary()
Returns a string that describes the values and principles that guide the code agent's design and implementation decisions. This is used to inform the AI agent's behavior and responses, ensuring that it adheres to a consistent set of coding standards and practices.
@spec get_completion( state :: t(), prompt :: binary(), response_format :: map() | nil, keep_prompt? :: boolean() ) :: t()
Executes a completion request using the AI model specified in the state. The
prompt is appended to the existing messages in the state as a system
message. Unless keep_prompt? is true, the system prompt will be removed
from the messages after the completion is received to keep the cascade of
instructions clean.
Retrieves a value from the internal state of the AI agent. key may be
either a single atom or a list of atoms representing a path to a value in the
internal map (per get_in/2 semantics).
When passing a list of keys, all keys must exist within the nested structure.
{:error, :not_found} will be returned if any key is missing.
Examples:
# Get a single value
{:ok, value} = AI.Agent.Code.Common.get_state(state, :blarg)
# Get a nested value
{:ok, value} = AI.Agent.Code.Common.get_state(state, [:blarg, :foo])
@spec new( agent :: AI.Agent.t(), model :: AI.Model.t(), toolbox :: AI.Tools.toolbox(), system_prompt :: binary(), user_prompt :: binary() ) :: t()
Creates a new state for an AI agent that works with code. The initial message list includes the system prompt and the user prompt, as provided.
Sets the internal, implementation-specific state for the AI agent. key
may be either a single atom or a list of atoms representing a path to a value
in the internal map (per put_in/3 semantics).
When passing a list of keys, all keys must exist within the nested structure.
An exception will be thrown (by put_in/3) if any key is missing.
Examples:
# Set a single value
state = AI.Agent.Code.Common.put_state(state, :blarg, "how now brown beaurocrat")
# Set a nested value
state = AI.Agent.Code.Common.put_state(state, [:blarg, :foo], "bar")