Skip to main content

agora.sender.components.querier

PROTOCOL_QUERIER_PROMPT

\

construct_query_description

def construct_query_description(protocol_document: str,
task_schema: TaskSchemaLike,
task_data: Any) -> str

Constructs a query description for the protocol and task.

Arguments:

  • protocol_document str - The protocol document text.
  • task_schema TaskSchemaLike - The schema for the task.
  • task_data Any - The data for the task.

Returns:

  • str - The constructed query description.

parse_and_handle_query

def parse_and_handle_query(query: str, callback: Callable[[str], Dict]) -> str

Parses and processes a query by calling the given callback.

Arguments:

  • query str - The query to be processed.
  • callback Callable[[str], Dict] - The function that processes the query.

Returns:

  • str - The response from the callback or error information.

Querier Objects

class Querier()

Handles querying external services based on protocol documents and task schemas.

__init__

def __init__(toolformer: Toolformer,
max_queries: int = 5,
max_messages: int = None,
force_query: bool = True)

Initializes the Querier with the given toolformer and query/message limits.

Arguments:

  • toolformer Toolformer - The Toolformer instance managing tools and conversations.
  • max_queries int, optional - Maximum number of queries allowed. Defaults to 5.
  • max_messages int, optional - Maximum number of messages allowed. If None, set to max_queries * 2. Defaults to None.
  • force_query bool, optional - Whether to enforce sending a query before output. Defaults to True.

handle_conversation

def handle_conversation(prompt: str, message: str, output_schema: dict,
callback: Callable[[str], Dict]) -> str

Manages the conversation flow for handling queries and delivering outputs.

Arguments:

  • prompt str - The initial prompt for the conversation.
  • message str - The message to process in the conversation.
  • output_schema dict - The schema defining the structure of the expected output.
  • callback Callable[[str], Dict] - A callback function to handle query responses.

Returns:

  • str - The structured output produced by the conversation.

__call__

def __call__(task_schema: TaskSchemaLike, task_data: Any,
protocol_document: str, callback: Callable[[str], Dict]) -> str

Executes the querying process based on task schema and protocol document.

Arguments:

  • task_schema TaskSchemaLike - The schema of the task to be performed.
  • task_data Any - The data associated with the task.
  • protocol_document str - The document defining the protocol for querying.
  • callback - A callback function to handle query responses.

Returns:

  • str - The structured output resulting from the querying process.