CrustAGI is an Task-driven Autonomous Agent experiment written in Rust

Overview

CrustAGI 🦀

CrustAGI is an experimental Rust-based implementation of an AI-powered task management system that uses OpenAI and Pinecone APIs to create, prioritize, and execute tasks. The system generates tasks based on the results of previous tasks and a predefined objective. It leverages OpenAI's natural language processing (NLP) capabilities to create new tasks and Pinecone to store and retrieve task results for context.

How It Works

CrustAGI operates in an infinite loop, performing the following steps:

  1. Load environment variables.
  2. Create and connect to a Pinecone index.
  3. Initialize the task list.
  4. Enter the main loop:
    1. Execute the first task and store the enriched result in Pinecone.
    1. Use agents and modules to interact with OpenAI and Pinecone:
    • OpenAI is called to perform natural language processing tasks, generate embeddings, and assist with task creation and prioritization.
    • Pinecone is used for vector similarity search to query and retrieve contextually relevant information based on embeddings.
    1. Create and reprioritize tasks based on insights from OpenAI.
    1. Repeat the loop with the next task.
  1. Continue the loop until a termination condition is met.
graph TD
    A[Load Environment Variables] --> F[Create Pinecone Index]
    F -->|pinecone::create_index| FC[Pinecone Module]
    FC --> G[Connect to Pinecone Index]
    G -->|pinecone::list_indexes| GC[Pinecone Module]
    GC --> H[Initialize Task List]
    H --> I[Main Loop]
    I --> J[Pull First Task]
    J --> K[Execute Task]
    K --> L[Enrich Result and Store in Pinecone]
    L -->|pinecone::upsert| LC[Pinecone Module]
    LC --> M[Create New Tasks and Reprioritize Task List]
    M --> I
    K --> N[Execution Agent]
    N -->|openai::openai_call| NA[OpenAI Module]
    NA --> N
    N -->|openai::get_ada_embedding| NB[OpenAI Module]
    NB --> N
    N -->|context_agent| NC[Context Agent]
    NC --> N
    M --> O[Task Creation Agent]
    O -->|openai::openai_call| OA[OpenAI Module]
    OA --> O
    M --> P[Prioritization Agent]
    P -->|openai::openai_call| PA[OpenAI Module]
    PA --> P
    K --> Q[Context Agent]
    Q -->|openai::get_ada_embedding| QA[OpenAI Module]
    QA --> Q
    Q -->|pinecone::query_index| QC[Pinecone Module]
    QC --> Q
    L --> Q

    classDef modules fill:#f9,stroke:#f08080,stroke-width:2px;
    class FC,GC,LC,NA,NB,NC,OA,PA,QA,QC modules

The program uses Pinecone (a cloud-hosted VectorDB) to create an index for storing task results, along with task names and additional metadata. The context_agent function retrieves the context of previously completed tasks from Pinecone to inform the execution of the current task.

Getting Started with CrustAGI

To get started with CrustAGI, follow these steps:

  1. Clone the CrustAGI repository and navigate to the cloned directory.
  2. Ensure that you have the Rust environment set up
  3. Set up environment variables for OpenAI and Pinecone API keys, Pinecone region and project ID, Pinecone index name, initial task, and objective. You can use a .env file to store these variables. The dotenv crate is used to load environment variables from the .env file.
  4. Run the code using cargo run.

Example .env file:

OPENAI_API_KEY="<your openai api key>"
OPENAI_API_MODEL="gpt-3.5-turbo"
PINECONE_API_KEY="<pinecone api>"
PINECONE_PROJECT_ID="<your pinecone project id>"
PINECONE_REGION="<your pinecone region>"
PINECONE_INDEX_NAME="test"
OBJECTIVE="<your objective>"
INITIAL_TASK="<the initial task>"

Task Structure

Tasks are represented by the Task struct, which includes a task ID and task name. The task list is maintained as a VecDeque<Task>.

Functions

  • task_creation_agent: Generates new tasks based on the objective and result of the previous task.
  • prioritization_agent: Reprioritizes the task list based on the objective.
  • execution_agent: Executes the current task using OpenAI's API.
  • context_agent: Retrieves the context of previously completed tasks from Pinecone.
  • add_task: Adds a new task to the task list.

Main Loop

The main function contains the main loop that continuously executes tasks, generates new tasks, and reprioritizes the task list. The loop sleeps for one second before checking the task list again.

Why Rust and not Python?

  • Deployment Flexibility: Rust provides a wide range of deployment options, making it an ideal choice for our project. We can deploy Rust applications on servers, edge devices, and even browsers using WebAssembly. This flexibility allows us to target a diverse set of platforms and environments.
  • High Performance: Rust is known for its excellent performance characteristics, including efficient memory management and minimal runtime overhead. By choosing Rust, we can build applications that run faster and use resources more efficiently, which is especially important for AI and machine learning tasks.
  • Memory Safety: Rust's strong focus on memory safety and its ownership model help prevent common programming errors such as null pointer dereferences and buffer overflows. This safety aspect is crucial for building reliable and secure applications, reducing the likelihood of vulnerabilities and crashes.
  • Scalability: Rust's support for concurrency and parallelism allows us to build applications that scale effectively across multiple cores and processors. This scalability is essential for handling large workloads and ensuring that our applications can grow to meet increasing demands.
  • Interoperability: Rust's C-compatible FFI (Foreign Function Interface) allows us to easily integrate with existing C and C++ libraries, as well as other languages. This interoperability enables us to leverage a vast ecosystem of existing code and tools while benefiting from Rust's modern features.
  • Community and Ecosystem: Rust has a vibrant and growing community, along with a rich ecosystem of libraries and tools. By choosing Rust, we gain access to a wealth of resources and support that can help accelerate our development process and improve the quality of our applications.

Disclaimer

CrustAGI is designed to run continuously as part of a task management system. Running this program continuously can result in high API usage, so please use it responsibly. Ensure that you have set up the OpenAI and Pinecone APIs correctly before running the program.

License

CrustAGI is open-source software. For more information, please see the LICENSE file in the CrustAGI repository.

Acknowledgments

We would like to acknowledge and thank @yoheinakajima for creating the original BabyAGI project, which inspired the creation of CrustAGI. We also want to thank the contributors and community members who have supported and contributed to the development of both projects.

Contact

For questions, issues, or contributions, please feel free to open an issue or pull request in the CrustAGI GitHub repository. We welcome feedback and contributions from the community.

Contributing to CrustAGI

Contributions to CrustAGI are welcome! If you have an idea for improving the project or want to fix a bug, please open an issue or submit a pull request on the CrustAGI GitHub repository. When submitting a pull request, please provide a clear description of the changes you have made and the rationale behind them.

You might also like...
A prototype implementation of the Host Identity Protocol v2 for bare-metal systems, written in pure-rust.
A prototype implementation of the Host Identity Protocol v2 for bare-metal systems, written in pure-rust.

Host Identity Protocol for bare-metal systems, using Rust I've been evaluating TLS replacements in constrained environments for a while now. Embedded

A fast tool to scan prototype pollution vulnerability written in Rust. 🦀
A fast tool to scan prototype pollution vulnerability written in Rust. 🦀

ppfuzz Prototype Pollution Fuzzer A fast tool to scan prototype pollution vulnerability written in Rust. 🦀 Installation Binary Source Dependencies Us

A simple password manager written in rust

Passman - A password manager written in rust. How to use?: USAGE: passman option Currently available options are: new - initalize passman with a new m

A simple password manager written in Rust
A simple password manager written in Rust

ripasso A simple password manager written in Rust. The root crate ripasso is a library for accessing and decrypting passwords stored in pass format (G

Ruo is a dictionary-based password cracker written in rust 🦀 .

Ruo is a dictionary-based password cracker written in rust 🦀 . The primary purpose is to crack weak hashes/commonly used passwords.

Keyhouse is a skeleton of general-purpose Key Management System written in Rust.

Keyhouse Keyhouse is a skeleton of general-purpose Key Management System. Keyhouse is not an off-the-shelf system, and it's not ready for production.

Solana Escrow Program written by RUST.

Environment Setup Install Rust from https://rustup.rs/ Install Solana from https://docs.solana.com/cli/install-solana-cli-tools#use-solanas-install-to

A wallet library for Elements / Liquid written in Rust!

EDK Elements Dev Kit A modern, lightweight, descriptor-based wallet library for Elements / Liquid written in Rust! Inspired by BDK for Elements & Liqu

An encrypted multi client messaging system written in pure Rust

🚩 Preamble This is a pure Rust multi-client encrypted messaging system, also known as Edode's Secured Messaging System. It is an end-to-end(s) commun

Owner
Lukas Schmyrczyk
Lukas Schmyrczyk
Rust compile-time type information experiment

Compile-Time Type Information This crate is an experimental standard library side implementation of potential ctti language feature. The idea is to pr

Auri 12 Jan 20, 2023
A challenge agent for Optimism written in pure Rust.

op-challenger • Note Work in progress. A set-and-forget challenge agent for the OP Stack written in pure Rust ?? Usage op-challenger [OPTIONS] \ --l

null 18 Apr 6, 2023
This is an experiment in designing a distributed connected garden experience.

This is an experiment in designing a distributed connected garden experience. It started as an implementation of a blockchain, but has moved on to be a bit more than that. There is no proof of work like a cryptocurrency, but plays with the idea of a distributed consensus-building system.

Greg Tatum 4 Feb 28, 2022
Holochain + ZKP usage experiment in the form of battleships

Battleships Circuits Circuits nabbed from https://github.com/kunalmodi/battlesnark/tree/master. Circuits require circom to compile. cd circuits sh bui

null 4 Aug 24, 2023
A terminal-based daily task management tool with minimal overhead

Arenta A terminal-based daily task management tool with minimal overhead. Demo Features Complete CRUD support of daily tasks with intuitive syntax Vis

Tao Bocheng 4 Feb 25, 2023
Ingraind - a security monitoring agent built around RedBPF for complex containerized environments and endpoints.

ingraind is a security monitoring agent built around RedBPF for complex containerized environments and endpoints. The ingraind agent uses eBPF probes to provide safe and performant instrumentation for any Linux-based environment.

KingoOo 5 Apr 6, 2022
An open source Rust high performance cryptocurrency trading API with support for multiple exchanges and language wrappers. written in rust(🦀) with ❤️

Les.rs - Rust Cryptocurrency Exchange Library An open source Rust high performance cryptocurrency trading API with support for multiple exchanges and

Crabby AI 4 Jan 9, 2023
Collection of cryptographic hash functions written in pure Rust

RustCrypto: hashes Collection of cryptographic hash functions written in pure Rust. All algorithms reside in the separate crates and implemented using

Rust Crypto 1.2k Jan 8, 2023
rabe is an Attribute Based Encryption library, written in Rust

Rabe rabe is a rust library implementing several Attribute Based Encryption (ABE) schemes using a modified version of the bn library of zcash (type-3

Fraunhofer AISEC 52 Dec 15, 2022
An extremely high performance matching engine written in Rust.

Galois Introduction Galois is an extremely high performance matching engine written in Rust, typically used for the crypto currency exchange service.

UINB Tech 66 Jan 7, 2023