swarmauri.core.agent_apis package

Submodules

Module contents

class swarmauri.core.agent_apis.IAgentCommands[source]

Bases: ABC

Interface for the API object that enables a SwarmAgent to host various API routes.

abstract async abatch(requests)[source]

Handles batched invocation requests asynchronously.

Parameters:

requests (List[Any]) – A list of incoming request payloads.

Returns:

A list of responses.

Return type:

List[Any]

abstract async ainvoke(request)[source]

Handles invocation requests asynchronously.

Parameters:

request (Any) – The incoming request payload.

Returns:

The response payload.

Return type:

Any

abstract batch(requests)[source]

Handles batched invocation requests synchronously.

Parameters:

requests (List[Any]) – A list of incoming request payloads.

Returns:

A list of responses.

Return type:

List[Any]

abstract get_schema_config()[source]

Retrieves the schema configuration for the API.

Returns:

The schema configuration.

Return type:

dict

abstract invoke(request)[source]

Handles invocation requests synchronously.

Parameters:

request (Any) – The incoming request payload.

Returns:

The response payload.

Return type:

Any

abstract stream(request)[source]

Handles streaming requests.

Parameters:

request (Any) – The incoming request payload.

Returns:

A streaming response.

Return type:

Any

class swarmauri.core.agent_apis.IAgentRouterCRUD[source]

Bases: ABC

Interface for managing API routes within a SwarmAgent.

abstract create_route(path, method, handler)[source]

Create a new route for the API.

Parameters: - path (str): The URL path for the route. - method (str): The HTTP method (e.g., ‘GET’, ‘POST’). - handler (Callable[[Any], Any]): The function that handles requests to this route.

Return type:

None

abstract delete_route(path, method)[source]

Delete a specific route from the API.

Parameters: - path (str): The URL path for the route. - method (str): The HTTP method.

Return type:

None

abstract read_route(path, method)[source]

Retrieve information about a specific route.

Parameters: - path (str): The URL path for the route. - method (str): The HTTP method.

Returns: - Dict: Information about the route, including path, method, and handler.

Return type:

Dict

abstract update_route(path, method, new_handler)[source]

Update the handler function for an existing route.

Parameters: - path (str): The URL path for the route. - method (str): The HTTP method. - new_handler (Callable[[Any], Any]): The new function that handles requests to this route.

Return type:

None