Explanations

Agent Architecture

Moya's architecture is designed to be modular and flexible. Each agent can be configured with different models and tools, allowing for a wide range of applications.

How Agents Work

Agents in Moya operate by receiving messages, processing them, and generating responses. The flow typically involves:

  1. Receiving a Message: The agent listens for user input.
  2. Processing the Message: The agent analyzes the input and determines the appropriate response.
  3. Generating a Response: The agent uses its configured model to create a reply.

Example of an Agent


from moya.agents.openai_agent import OpenAIAgent, OpenAIAgentConfig

# Set up the agent configuration
agent_config = OpenAIAgentConfig(
    system_prompt="You are a helpful AI assistant.",
    model_name="gpt-4o",
    temperature=0.7,
    max_tokens=2000
)

# Create the agent
agent = OpenAIAgent(
    agent_name="my_agent",
    description="A simple AI assistant",
    agent_config=agent_config
)

# Set up the agent
agent.setup()

# Handle a message
response = agent.handle_message("Hello, how can I help you?")
print(response)
            

Multi-Agent Systems

Moya supports multi-agent systems where multiple specialized agents work together to handle different types of queries. The key components include:

Agent Types

Moya supports several types of agents, each with its own capabilities and use cases:

Memory Management

Moya provides built-in memory management through the MemoryTool, allowing agents to:

This memory system enables agents to maintain context across multiple interactions, creating more coherent and contextually relevant responses.

Orchestrators

Orchestrators in Moya manage the flow of messages between users and agents. They handle:

Moya provides different types of orchestrators:

Tool Registry and Tool Calling

The Tool Registry in Moya allows agents to discover and call external tools. This enables agents to:

Tools are registered with the Tool Registry and can be called by agents using the call_tool method:


# Register a tool
tool_registry.register_tool(memory_tool)

# Call a tool from an agent
agent.call_tool(
    tool_name="MemoryTool",
    method_name="store_message",
    thread_id="thread_1",
    sender="user",
    content="Hello, how are you?"
)