ayn.controllers

Agent controllers for invoking agents.

Classes

AgentController(*args, **kwargs)

Standard protocol for agent controllers

BaseAgentController(config)

Base class for agent controllers

GenericController(metadata, config)

Generic controller for custom agents

CrewAIController(metadata, config)

Controller for CrewAI agents

LangChainController(metadata, config)

Controller for LangChain agents

AutoGenController(metadata, config)

Controller for AutoGen agents

class ayn.controllers.AgentController(*args, **kwargs)[source]

Bases: Protocol

Standard protocol for agent controllers

Controllers provide a uniform interface for invoking agents regardless of their underlying framework.

Example

>>> class MyController:
...     def __init__(self, config):
...         self.config = config
...     def invoke(self, input_data, **kwargs):
...         return f"Processed: {input_data}"
>>> controller = MyController({'model': 'gpt-4'})
>>> controller.invoke('test')
'Processed: test'
async ainvoke(input_data, **kwargs)[source]

Invoke the agent asynchronously

Return type:

Any

invoke(input_data, **kwargs)[source]

Invoke the agent synchronously

Parameters:
  • input_data (Any) – Input data for the agent

  • **kwargs – Additional parameters

Return type:

Any

Returns:

Agent output

stream(input_data, **kwargs)[source]

Stream agent outputs

Return type:

Iterable[Any]

class ayn.controllers.AutoGenController(metadata, config)[source]

Bases: GenericController

Controller for AutoGen agents

Not implemented yet: today this behaves exactly like GenericController (it echoes its input) and does not run an AutoGen agent. See AYN_IMPLEMENTATION_ROADMAP.md for details

class ayn.controllers.BaseAgentController(config)[source]

Bases: ABC

Base class for agent controllers

Provides common functionality and enforces the controller protocol.

Example

>>> class SimpleController(BaseAgentController):
...     def invoke(self, input_data, **kwargs):
...         return f"Result: {input_data}"
>>> controller = SimpleController(ControllerConfig())
>>> controller.invoke('test')
'Result: test'
async ainvoke(input_data, **kwargs)[source]

Default async implementation wraps synchronous invoke

Return type:

Any

classmethod from_metadata(metadata, config=None)[source]

Factory method to create controller from metadata

Return type:

BaseAgentController

abstractmethod invoke(input_data, **kwargs)[source]

Invoke the agent - must be implemented by subclasses

Return type:

Any

stream(input_data, **kwargs)[source]

Default streaming yields single result

Return type:

Iterable[Any]

class ayn.controllers.CrewAIController(metadata, config)[source]

Bases: GenericController

Controller for CrewAI agents

Not implemented yet: today this behaves exactly like GenericController (it echoes its input) and does not run a CrewAI agent. See AYN_IMPLEMENTATION_ROADMAP.md for details

class ayn.controllers.GenericController(metadata, config)[source]

Bases: BaseAgentController

Generic controller for custom agents

Example

>>> from ayn.core import AgentMetadata, AgentFramework, ControllerConfig
>>> meta = AgentMetadata(name="test", description="test", framework=AgentFramework.CUSTOM)
>>> controller = GenericController(meta, ControllerConfig())
>>> result = controller.invoke({'input': 'test'})
invoke(input_data, **kwargs)[source]

Generic invoke - subclasses override for specific behavior

Return type:

Any

class ayn.controllers.LangChainController(metadata, config)[source]

Bases: GenericController

Controller for LangChain agents

Not implemented yet: today this behaves exactly like GenericController (it echoes its input) and does not run a LangChain agent. See AYN_IMPLEMENTATION_ROADMAP.md for details

Modules

base

Base controller protocol and abstract class.

framework

Framework-specific controller implementations.

generic

Generic controller for custom agents.