How to Build Durable AI Agents Using Chidori v2

Jul 2, 2022 | Educational

Welcome to the world of Chidori, a powerful reactive runtime designed to help you build durable AI agents seamlessly. With its open-source nature and friendly user interface, Chidori allows developers to interact with AI tools effortlessly. In this guide, we’ll walk you through the installation, setup, and provide a hands-on example to unleash your creativity in AI.

Getting Started with Chidori

Installation

To get started with Chidori, you need Rust and Cargo installed on your machine. Here’s how you can install it:

bash
xcode-select --install
brew install cmake
brew install protobuf
brew install libiconv
brew install python@3.12
cargo install chidori-debugger

Remember that if you prefer a different Python interpreter, you can set PYO3_PYTHON=python3.12 to adapt the installation.

Setting Up the Runtime Environment

Chidori uses HTTP at http://localhost:4000 by default, connecting to LiteLLMs proxy. To leverage GPT-3.5-turbo, follow these steps:

bash
pip install litellm[proxy]
uv sync
export OPENAI_API_KEY=...
uv run litellm --config .litellm_config.yaml

Developing Your First Agent

Example: A Simple Hacker News Agent

This example illustrates how to create a Chidori agent that fetches the top stories from Hacker News, filtering them to only showcase AI-related launches.

The code structure is akin to following a recipe. You gather ingredients (data), mix them (code logic), and serve the dish (output). Here is how it looks:

javascript
const axios = require('https://deno.land/x/axios/mod.ts');
const HN_URL_TOP_STORIES = 'https://hacker-news.firebaseio.com/v0/topstories.json';

function fetchStory(id) {
    return axios.get(`https://hacker-news.firebaseio.com/v0/item/${id}.json?print=pretty`)
        .then(response => response.data);
}

async function fetchHN() {
    const stories = await axios.get(HN_URL_TOP_STORIES);
    const storyIds = stories.data;
    // Only the first 30
    const tasks = storyIds.slice(0, 30).map(id => fetchStory(id));
    return Promise.all(tasks)
        .then(stories => {
            return stories.map(story => {
                const { title, url, score } = story;
                return { title, url, score };
            });
        });
}

Prompt interpret_the_group
prompt (interpret_the_group) {
    // Based on the following list of HackerNews threads, filter this list to only launches of new AI projects
};

Prompt format_and_rank
prompt (format_and_rank) {
    // Format this list of new AI projects in markdown, ranking the most interesting projects from most interesting to least.
};

Using a python cell as our entrypoint, demonstrating inter-language execution:
python
articles = await fetchHN();
format_and_rank(articles=articles);

In the analogy, the agent acts like a chef who gathers ingredients (data) from sources (APIs), processes them (fetching and filtering), and then dishes out a well-formatted output (markdown list) based on certain criteria.

Troubleshooting Tips

  • If you encounter issues during installation, ensure all necessary dependencies are correctly installed. Use brew install for Homebrew users.
  • Check if the API keys are correctly set and the server is running on the expected port.
  • For further assistance on configurations or to engage with community discussions, visit our Discord.
  • For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

About Chidori

Chidori offers a multitude of features, including a robust reactive runtime that orchestrates agent interactions, comprehensive monitoring, branching, and time-travel capabilities. With first-class support for Python and JavaScript, it paves the way for an innovative coding experience.

Roadmap Ahead

  • Short term:
    • Reactive subscriptions between nodes
    • Node.js, Python, and Rust support
  • Medium term:
    • Analysis tools for execution comparison
    • Supporting more vector databases and sources

Final Thoughts

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.

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

Tech News and Blog Highlights, Straight to Your Inbox