Nagato-AI: Your Intuitive AI Agent Library

Oct 27, 2020 | Educational

Nagato-AI is like having a powerful toolkit at your disposal, inspired by the dynamic world of anime. Just as the character Nagato from Naruto harnesses immense abilities to coordinate multiple ninjas, Nagato-AI allows you to effortlessly manage and utilize various Large Language Models (LLMs). This blog will walk you through how to use this incredible library to create and manage AI agents effectively.

How to Use Nagato-AI

Installation

Before diving into creating your agents, you’ll need to set up Nagato-AI on your system. There are two methods to install it: directly from the source repository or via pip. Here’s how you can do both:

Working with the Source Repository

If you prefer to work directly with the source code, ensure you have Poetry installed. Once you have it, navigate to the root folder of the Nagato codebase in your terminal, and run the following command:

poetry install

Installing via pip

Simply run this command in your terminal:

pip install nagatoai_core

And voilà! Nagato AI is ready for action in your code.

Configuring Environment Variables

Nagato-AI relies on specific environment variables to create AI agents and tools. Start by creating a .env file and populate it with your desired API keys:

OPENAI_API_KEY=
ANTHROPIC_API_KEY=
GROQ_API_KEY=
GOOGLE_API_KEY=
READWISE_API_KEY=
SERPER_API_KEY=
ELEVENLABS_API_KEY=

For example, if you’re focusing solely on GPT-based agents and the Readwise tool, only set the OPENAI_API_KEY and READWISE_API_KEY.

Running Python Code

Assuming your starting point is a file named main.py, run your program using:

poetry run python main.py

Supported LLMs

Nagato currently supports an array of powerful language models:

  • Claude 3 (Anthropic)
  • GPT-3 to GPT-4 (OpenAI)
  • Groq for Llama 3.1
  • Google Gemini

Agent Configuration Examples

Creating AI agents with Nagato is flexible. You can structure agents as coordinators, workers, or critics, much like a well-organized task force:

1. Coordinator, Worker, and Critic Agents

Think of this setup as a project team:

  • Coordinator: Breaks down the project into manageable tasks.
  • Researcher: Takes responsibilities for researching.
  • Critic: Evaluates task completions and performances.

Here’s an example code snippet for this configuration:

# Using Claude-3 Opus as the coordinator agent
coordinator_agent: Agent = create_agent(
    anthropic_api_key,
    claude-3-opus-20240229,
    Coordinator,
    COORDINATOR_SYSTEM_PROMPT,
    Coordinator Agent,
)

# Using GPT-4 turbo as the researcher agent
researcher_agent = create_agent(
    anthropic_api_key,
    gpt-4-turbo-2024-04-09,
    Researcher,
    RESEARCHER_SYSTEM_PROMPT,
    Researcher Agent,
)

# Use Google Gemini 1.5 Flash as the critic
critic_agent = create_agent(
    google_api_key,
    gemini-1.5-flash,
    Critic,
    CRITIC_SYSTEM_PROMPT,
    Critic Agent,
)

This code represents an orchestra with each agent playing their part to perfection.

2. Worker and Critic Agents

Alternatively, you can deploy workers and critics without a coordinator by directly submitting tasks:

task_list: List[Task] = [
    Task(
        goal=Fetch last 100 user tweets,
        description=Fetch the tweets from the user using the Twitter API. Limit the number of tweets fetched to 100 only.
    ),
    Task(
        goal=Perform sentiment analysis on the tweets,
        description=Feed the tweets to the AI Agent for sentiment analysis. Possible values: Positive, Negative, or Neutral.
    )
]

critic_agent = create_agent(
    anthropic_api_key,
    claude-3-haiku-20240307,
    Critic,
    CRITIC_SYSTEM_PROMPT,
    Critic Agent,
)

for task in task_list:
    # Insert the task into the prompt
    worker_prompt = ...
    worker_exchange = researcher_agent.chat(worker_prompt, task, 0.7, 2000)
    # Insert the response from the agent into the prompt for the critic
    critic_prompt = ...
    critic_exchange = critic_agent(critic_prompt, task, 0.7, 2000)
    # Evaluate the task based on the critic's response...

Troubleshooting Tips

  • If Nagato-AI doesn’t seem to recognize your environment variables, double-check the spelling and format in your .env file.
  • If you run into installation issues, ensure that you have the correct version of Poetry installed.
  • For any bugs or feature requests, consider raising them on the repository’s GitHub page.
  • Lastly, stay connected with **[fxis.ai](https://fxis.ai)** for insights on AI developments or project collaborations.

What’s Next for Nagato-AI

Nagato-AI is continuously evolving. Future updates may include:

  • Function calling implementation
  • Basic tools like web surfing capabilities
  • Support for additional modalities such as images and sound

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Conclusion

Nagato-AI offers powerful features for developers and AI enthusiasts alike, making it an ideal companion for creating dynamic agents capable of tackling complex tasks. With just a few commands and configurations, you can unlock the potential of advanced AI models at your fingertips!

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox