Skip to main content

agora.sender.core

Sender Objects

class Sender()

Main Sender class responsible for orchestrating protocols, components, and memory.

__init__

def __init__(memory: SenderMemory,
protocol_picker: ProtocolPicker,
negotiator: SenderNegotiator,
programmer: SenderProgrammer,
executor: Executor,
querier: Querier,
transporter: SenderTransporter,
protocol_threshold: int = 5,
negotiation_threshold: int = 10,
implementation_threshold: int = 5)

Initialize the Sender with the necessary components and thresholds.

Arguments:

  • memory SenderMemory - Memory component for storing protocols and task conversations.
  • protocol_picker ProtocolPicker - Component responsible for selecting protocols.
  • negotiator SenderNegotiator - Handles negotiation of protocols.
  • programmer SenderProgrammer - Generates protocol implementations.
  • executor Executor - Executes protocol implementations.
  • querier Querier - Manages querying external services.
  • transporter SenderTransporter - Handles the transportation of messages.
  • protocol_threshold int, optional - Minimum number of conversations to check existing protocols and see if one is suitable. Defaults to 5.
  • negotiation_threshold int, optional - Minimum number of conversations to negotiate a new protocol. Defaults to 10.
  • implementation_threshold int, optional - Minimum number of conversations using a protocol to write an implementation. Defaults to 5.

make_default

@staticmethod
def make_default(toolformer,
storage: Storage = None,
protocol_picker: ProtocolPicker = None,
negotiator: SenderNegotiator = None,
programmer: SenderProgrammer = None,
executor: Executor = None,
querier: Querier = None,
transporter: SenderTransporter = None,
storage_path: str = './.agora/storage/sender.json',
protocol_threshold: int = 5,
negotiation_threshold: int = 10,
implementation_threshold: int = 5)

Create a default Sender instance with optional custom components.

Arguments:

  • toolformer - The toolformer instance to use for creating components.
  • storage Storage, optional - Custom storage backend. Defaults to None.
  • protocol_picker ProtocolPicker, optional - Custom protocol picker. Defaults to None.
  • negotiator SenderNegotiator, optional - Custom negotiator. Defaults to None.
  • programmer SenderProgrammer, optional - Custom programmer. Defaults to None.
  • executor Executor, optional - Custom executor. Defaults to None.
  • querier Querier, optional - Custom querier. Defaults to None.
  • transporter SenderTransporter, optional - Custom transporter. Defaults to None.
  • storage_path str, optional - Path to the storage file. Defaults to './sender_storage.json'.
  • protocol_threshold int, optional - Minimum number of conversations to check existing protocols and see if one is suitable. Defaults to 5.
  • storage0 int, optional - Minimum number of conversations to negotiate a new protocol. Defaults to 10.
  • storage1 int, optional - Minimum number of conversations using a protocol to write an implementation. Defaults to 5.

Returns:

  • storage2 - A configured Sender instance.

execute_task

def execute_task(task_id: str,
task_schema: TaskSchemaLike,
task_data: dict,
target: str,
force_no_protocol: bool = False,
force_llm: bool = False) -> Any

Execute a task by selecting and running an appropriate protocol or falling back to querying.

Arguments:

  • task_id str - The identifier of the task.
  • task_schema TaskSchemaLike - The schema of the task to be performed.
  • task_data - The data required for the task.
  • target str - The target for which the task is being executed.
  • force_no_protocol bool, optional - If True, forces execution without a protocol. Defaults to False.
  • force_llm bool, optional - If True, forces execution using a language model. Defaults to False.

Returns:

  • Any - The result of the task execution.

task

def task(task_id: Optional[str] = None,
description: Optional[str] = None,
input_schema: Optional[dict] = None,
output_schema: Optional[dict] = None,
schema_generator: Optional[TaskSchemaGenerator] = None)

Decorator to define a task with optional schemas and description.

Arguments:

  • task_id str, optional - The identifier of the task. Defaults to None.
  • description str, optional - A brief description of the task. Defaults to None.
  • input_schema dict, optional - The input schema for the task. Defaults to None.
  • output_schema dict, optional - The output schema for the task. Defaults to None.
  • schema_generator TaskSchemaGenerator, optional - A generator to fill in missing schema fields. Defaults to None.

Returns:

  • Callable - The decorated function.