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:
memorySenderMemory - Memory component for storing protocols and task conversations.protocol_pickerProtocolPicker - Component responsible for selecting protocols.negotiatorSenderNegotiator - Handles negotiation of protocols.programmerSenderProgrammer - Generates protocol implementations.executorExecutor - Executes protocol implementations.querierQuerier - Manages querying external services.transporterSenderTransporter - Handles the transportation of messages.protocol_thresholdint, optional - Minimum number of conversations to check existing protocols and see if one is suitable. Defaults to 5.negotiation_thresholdint, optional - Minimum number of conversations to negotiate a new protocol. Defaults to 10.implementation_thresholdint, 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.storageStorage, optional - Custom storage backend. Defaults to None.protocol_pickerProtocolPicker, optional - Custom protocol picker. Defaults to None.negotiatorSenderNegotiator, optional - Custom negotiator. Defaults to None.programmerSenderProgrammer, optional - Custom programmer. Defaults to None.executorExecutor, optional - Custom executor. Defaults to None.querierQuerier, optional - Custom querier. Defaults to None.transporterSenderTransporter, optional - Custom transporter. Defaults to None.storage_pathstr, optional - Path to the storage file. Defaults to './sender_storage.json'.protocol_thresholdint, 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_idstr - The identifier of the task.task_schemaTaskSchemaLike - The schema of the task to be performed.task_data- The data required for the task.targetstr - The target for which the task is being executed.force_no_protocolbool, optional - If True, forces execution without a protocol. Defaults to False.force_llmbool, 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_idstr, optional - The identifier of the task. Defaults to None.descriptionstr, optional - A brief description of the task. Defaults to None.input_schemadict, optional - The input schema for the task. Defaults to None.output_schemadict, optional - The output schema for the task. Defaults to None.schema_generatorTaskSchemaGenerator, optional - A generator to fill in missing schema fields. Defaults to None.
Returns:
Callable- The decorated function.