ayn.utils¶
Convenience utility functions.
Functions
|
Search registry and create agent controller |
|
Export agent with all integrations |
- ayn.utils.create_agent_from_registry(registry, query, config=None)[source]¶
Search registry and create agent controller
- Parameters:
registry (
AgentRegistry) – Agent registryquery (
str) – Search queryconfig (
Optional[ControllerConfig]) – Optional controller config
- Return type:
- Returns:
Agent controller
Example
>>> from ayn import AgentRegistry >>> from ayn.core import AgentMetadata, AgentFramework >>> import tempfile >>> registry = AgentRegistry(searchers=[], cache_dir=tempfile.mkdtemp()) >>> meta = AgentMetadata(name="test-agent", description="test", framework=AgentFramework.CUSTOM) >>> registry['test-agent'] = meta >>> controller = create_agent_from_registry(registry, 'test') >>> isinstance(controller, BaseAgentController) True
- ayn.utils.export_agent_full_stack(controller, metadata, *, api_host='0.0.0.0', api_port=8000, export_fastapi=True, export_mcp=True, export_chatgpt=True, mcp_tools=None)[source]¶
Export agent with all integrations
- Parameters:
controller (
AgentController) – Agent controllermetadata (
AgentMetadata) – Agent metadataapi_host (
str) – API hostapi_port (
int) – API portexport_fastapi (
bool) – Whether to export as FastAPIexport_mcp (
bool) – Whether to export as MCP serverexport_chatgpt (
bool) – Whether to generate ChatGPT action
- Return type:
- Returns:
Dict with export artifacts
Example
>>> from ayn.controllers import GenericController >>> from ayn.core import AgentMetadata, AgentFramework, ControllerConfig >>> meta = AgentMetadata(name="test", description="test", framework=AgentFramework.CUSTOM) >>> controller = GenericController(meta, ControllerConfig()) >>> artifacts = export_agent_full_stack( ... controller, meta, ... export_fastapi=False, export_mcp=False, export_chatgpt=True ... ) >>> 'chatgpt_action' in artifacts True