View Source GptAgent behaviour (gpt_agent v3.0.0)

Provides a GPT conversation agent

Summary

Types

@type assistant_id() :: binary()
@type connect_opt() ::
  {:subscribe, boolean()}
  | {:thread_id, thread_id()}
  | {:assistant_id, assistant_id()}
@type connect_opts() :: [connect_opt()]
@type t() :: %GptAgent{
  default_assistant_id: binary() | nil,
  last_message_id: (binary() | nil) | nil,
  run_id: (binary() | nil) | nil,
  running?: boolean(),
  thread_id: (binary() | nil) | nil,
  tool_calls: [GptAgent.Events.ToolCallRequested.t()],
  tool_outputs: [GptAgent.Events.ToolCallOutputRecorded.t()]
}
@type thread_id() :: binary()

Callbacks

Link to this callback

add_user_message(pid, binary)

View Source
@callback add_user_message(pid(), binary()) ::
  {:ok, binary()} | {:error, :run_in_progress}
@callback connect(connect_opts()) :: {:ok, pid()} | {:error, :invalid_thread_id}
@callback create_thread() :: {:ok, binary()}
@callback default_assistant(pid()) :: binary()
Link to this callback

set_default_assistant(pid, binary)

View Source
@callback set_default_assistant(pid(), binary()) :: :ok
@callback shutdown(pid()) :: :ok
@callback start_link(keyword()) :: {:ok, pid()} | {:error, reason :: term()}
Link to this callback

submit_tool_output(pid, binary, map)

View Source
@callback submit_tool_output(pid(), binary(), map()) ::
  {:ok, binary()} | {:error, :invalid_tool_call_id}
@callback thread_id(pid()) :: binary()

Functions

@spec __knigge__() :: :ok

Acts as a "flag" to mark this module as a Knigge module.

@spec __knigge__(:behaviour) :: module()
@spec __knigge__(:implementation) :: module()
@spec __knigge__(:options) :: Knigge.Options.t()

Access Knigge internal values, such as the implementation being delegated to etc.

Link to this function

add_user_message(arg1, arg2)

View Source

See GptAgent.Impl.add_user_message/2.

Returns a specification to start this module under a supervisor.

See Supervisor.

See GptAgent.Impl.connect/1.

See GptAgent.Impl.create_thread/0.

See GptAgent.Impl.default_assistant/1.

Link to this function

set_default_assistant(arg1, arg2)

View Source

See GptAgent.Impl.set_default_assistant/2.

See GptAgent.Impl.shutdown/1.

See GptAgent.Impl.start_link/1.

Link to this function

submit_tool_output(arg1, arg2, arg3)

View Source

See GptAgent.Impl.submit_tool_output/3.

See GptAgent.Impl.thread_id/1.