Giter VIP home page Giter VIP logo

babyagi-chroma-agent's Introduction

๐Ÿค– Baby AGI template with Langchain Tools and Chroma ๐ŸŸก โ›“๏ธ

babyagichrome.mp4

Inspired by Yoheina Kajima's BabyAGI

The babyagi-chroma repository offers a free vector storage solution, Chroma, which is run locally. This is particularly advantageous for users who want to avoid potential costs associated with other vector storage options such as Pinecone.

๐ŸŽฏ Objective

This Python script showcases an example of an AI-powered task management system that leverages Langchain, OpenAI, and Chroma's Vector Database to create, prioritize, and execute tasks. The system creates tasks based on the results of previous tasks and a predefined objective. The script then utilizes Langchain's OpenAI natural language processing (NLP) toolkit and search capabilities to create new tasks based on the objective, while Chroma stores and retrieves task results for context. This is a simplified version of the original Task-Driven Autonomous Agent (Mar 28, 2023).

This README covers the following topics:

๐Ÿ”ง How It Works

The script carries out the following steps in an infinite loop:

  1. Adds and retrieves the first task from the task list.
  2. Sends the task to the execution agent, which employs Langchain's tools and methods, including OpenAI, to complete the task based on the context.
  3. Enriches the result and stores it in Chroma.
  4. Creates new tasks and reorders the task list according to the objective and the result of the previous task.

๐Ÿ”— Execution Chain

The Execution Chain processes a given task by considering the objective and context. It utilizes Langchain's LLMChain to execute the task. The execute_task function takes a Chroma VectorStore, an execution chain, an objective, and task information as input. It retrieves a list of top k tasks from the VectorStore based on the objective, and then executes the task using the execution chain, storing the result in the VectorStore. The function returns the result.

The execution chain is not explicitly defined in this code block. However, it is passed as a parameter to execute_task and can be defined separately in the code. It is an instance of the LLMChain class from Langchain, which accepts a prompt and generates a response based on provided input variables.

โž• Task Creation Chain

The TaskCreationChain class employs LLMChain to create new tasks. The from_llm function takes in parameters using PromptTemplate from Langchain, returning a list of new tasks as strings. It then creates an instance of TaskCreationChain along with custom input variables and specified behavior.

๐Ÿ“ˆ Task Prioritization Chain

The TaskPrioritizationChain class uses LLMChain to prioritize tasks. The from_llm function accepts parameters through PromptTemplate from Langchain, returning a list of new tasks as strings. It then creates an instance of TaskPrioritizationChain along with custom input variables and specified behavior.

๐Ÿ’ฝ Chroma

The script leverages Chroma to store, similarity search, and retrieve task results for context. It creates a Chroma index based on the table name specified in the TABLE_NAME variable. Chroma subsequently stores the task results in the index, along with the task name and any additional metadata.

๐Ÿ“– How to Use

To utilize the script, perform the following steps:

  1. Clone the repository: git clone https://github.com/alexdphan/babyagi-chroma.git and cd into the cloned directory.
  2. Install the required packages: pip install -r requirements.txt
  3. Copy the .env.example file to .env: cp .env.example .env. Set the following variables in this file.
  4. Provide your api keys in the OPENAI_API_KEY and SERPAPI_API_KEY.
  5. Set the name of the table where task results will be stored in the TABLE_NAME variable.
  6. (Optional) Set the objective of the task management system in the OBJECTIVE variable.
  7. (Optional) Set the first task of the system in the INITIAL_TASK variable.
  8. Run the script using the command python babyagi-chroma.py.

All optional values above can also be specified on the command line.

๐Ÿงช Supported Models

This script works with all OpenAI models. The default model is gpt-3.5 (text-davinci-003). To use a different model, feel free to modify the code accordingly.

โš ๏ธ Warning

This script is designed to be run continuously as part of a task management system. Running the script continuously can result in high API usage, so please use it responsibly. Additionally, the script requires that the OpenAI API and Serp be set up correctly, so ensure that the APIs are configured before running the script.

๐Ÿค Contribution

To maintain simplicity, kindly adhere to the following guidelines when submitting PRs:

  • Focus on small, modular modifications rather than extensive refactoring.
  • When introducing new features, provide a detailed description of the specific use case you are addressing.

๐Ÿ“œ Backstory

With the costs of vector storage being expensive, the aim was to provide a free storage option when using BabyAGI. Hence, this template example demonstrates using BabyAGI with Chroma.

BabyAGI-Chroma is a pared-down version of BabyAGI, which is also a simplified version of the original Task-Driven Autonomous Agent (Mar 28, 2023) shared on Twitter.

babyagi-chroma-agent's People

Contributors

alexdphan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

babyagi-chroma-agent's Issues

OPENAI_API_KEY Error

Hi, firstly thanks for this awesome project! I've run into an issue when trying to run babyagi - I've followed each 'How to Use' step to a t (except for the Optionals), I've both my OpenAI and Serpapi API keys saved as follows in my .env file, yet I continue to get the error below, when trying to run the program:

API CONFIG

OPENAI_API_KEY=MYOPENAIAPIKEY
SERPAPI_API_KEY=MYSERPAPIAPIKEY

TABLE CONFIG

TABLE_NAME=Storagi-table

PROJECT CONFIG

OBJECTIVE=Write a weather report for SF today
FIRST_TASK=Develop a task list

C:\Baby-AGI\babyagi-chroma-agent>python babyagi-chroma.py
Traceback (most recent call last):
  File "C:\Baby-AGI\babyagi-chroma-agent\babyagi-chroma.py", line 25, in <module>
    assert OPENAI_API_KEY, "OPENAI_API_KEY environment variable is missing from .env"
AssertionError: OPENAI_API_KEY environment variable is missing from .env

I've no idea what I am doing wrong and I am quite noob when it comes to this sort of thing so my apologies if it's obvious what the issue is. I've my own OpenAI and SERPAPI API keys that I created just for this program.

Thank you in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.