agora.sender.task_schema
TaskSchema Objects
class TaskSchema(Mapping)
Defines the schema for a task, including description and input/output schemas.
__init__
def __init__(description: Optional[str], input_schema: Optional[dict],
output_schema: Optional[dict])
Initializes the TaskSchema.
Arguments:
description
Optional[str] - A description of the task.input_schema
Optional[dict] - The JSON schema of the input data.output_schema
Optional[dict] - The JSON schema of the output data.
from_json
@staticmethod
def from_json(json_dict: dict) -> 'TaskSchema'
Creates a TaskSchema from a JSON dictionary.
Arguments:
json_dict
dict - The JSON dictionary containing task schema details.
Returns:
TaskSchema
- An instance of TaskSchema based on the provided JSON.
Raises:
SchemaError
- If required fields are missing in the JSON dictionary.
to_json
def to_json() -> dict
Converts the TaskSchema to a JSON dictionary.
Returns:
dict
- The JSON representation of the TaskSchema.
from_function
@staticmethod
def from_function(
func: Callable,
description: Optional[str] = None,
input_schema: Optional[dict] = None,
output_schema: Optional[dict] = None,
generator: Optional['TaskSchemaGenerator'] = None) -> 'TaskSchema'
Creates a TaskSchema from a function, inferring schemas if necessary.
Arguments:
func
Callable - The function to infer the schema from.description
Optional[str], optional - Overrides the task description. Defaults to None.input_schema
Optional[dict], optional - Overrides the input schema. Defaults to None.output_schema
Optional[dict], optional - Overrides the output schema. Defaults to None.generator
Optional[TaskSchemaGenerator], optional - Used to fill the fields that could not be parsed from function introspection. Defaults to None.
Returns:
TaskSchema
- An instance of TaskSchema based on the function.
from_taskschemalike
@staticmethod
def from_taskschemalike(task_schema_like: 'TaskSchemaLike') -> 'TaskSchema'
Converts a TaskSchema-like object into a TaskSchema instance.
Arguments:
task_schema_like
TaskSchemaLike - The TaskSchema-like object to convert.
Returns:
TaskSchema
- An instance of TaskSchema.
Raises:
SchemaError
- If the input is neither a TaskSchema nor a dictionary.
__str__
def __str__() -> str
Returns the JSON string representation of the TaskSchema.
Returns:
str
- The JSON-formatted string of the TaskSchema.