fluxion_ai.core.registry.agent_registry module

class fluxion_ai.core.registry.agent_registry.AgentRegistry[source]

Bases: object

A centralized registry for managing agents with modular names.

AgentRegistry: example-usage:

from fluxion_ai.core.registry.agent_registry import AgentRegistry
from fluxion_ai.core.agents.agent import Agent

class MyAgent(Agent):
    def __init__(self, name: str, description: str):
        super().__init__(name, description=description)

agent = MyAgent(name="MyAgent", description="My first agent")
AgentRegistry.register_agent("my_module.MyAgent", agent)

# Retrieve the agent
agent = AgentRegistry.get_agent("my_module.MyAgent")
print(agent)

# List all registered agents
agents = AgentRegistry.list_agents()
print(agents)

# Clear the agent registry
AgentRegistry.clear_registry()
classmethod clear_registry()[source]

Clear the agent registry.

classmethod get_agent(name: str) Agent[source]

Retrieve an agent by its modular name.

Parameters:

name (str) – The modular name of the agent.

Returns:

The agent instance, or None if not found.

Return type:

Agent

classmethod get_agent_metadata(group: str = None, sort: bool = False) List[Dict[str, Any]][source]

Retrieve metadata for all registered agents.

Parameters:

group (str, optional) – The group prefix to filter agents. If None, retrieves all agents.

Returns:

A dictionary containing metadata for all agents.

Return type:

Dict[str, Any]

classmethod group_tree() Dict[str, Any][source]

Generate a hierarchical representation of registered agents based on their modular names.

Returns:

A nested dictionary representing the hierarchy of agents.

Return type:

dict

classmethod list_agents(group: str = None) List[str][source]

List all registered agents, optionally filtered by a group prefix.

Parameters:

group (str, optional) – A group prefix to filter agents (e.g., “ml_agent.feature_extraction”).

Returns:

A list of agent names matching the group prefix.

Return type:

List[str]

classmethod register_agent(name: str, agent_instance: Agent)[source]

Register an agent with a modular name.

Parameters:
  • name (str) – The modular name of the agent (e.g., “ml_agent.feature_extraction.ImageFeatureExtraction”).

  • agent_instance (Agent) – The agent instance.

Raises:

ValueError – If the name is already registered.

classmethod unregister_agent(name: str)[source]

Unregister an agent by its modular name.

Parameters:

name (str) – The modular name of the agent.