Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chatgpt4j AGI 74 #287

Draft
wants to merge 89 commits into
base: babybeeagi
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
4a8e5e7
Update inspired-projects.md
Josh-XT Apr 22, 2023
12bbb04
Update inspired-projects.md
Josh-XT Apr 22, 2023
2ff1dc7
Merge branch 'yoheinakajima:main' into main
Josh-XT Apr 23, 2023
f961434
Stub setup instructions
hsm207 Apr 24, 2023
d3a54f2
Add dependency to client
hsm207 Apr 24, 2023
7896c7e
Add weaviate env vars
hsm207 Apr 24, 2023
0e67a46
Implement weaviate storage
hsm207 Apr 24, 2023
79f5471
Use env to trigger weaviate storage use
hsm207 Apr 24, 2023
c7316e7
Refactor results storage init logic
hsm207 Apr 24, 2023
a7ada25
Add support for embedded weaviate
hsm207 Apr 25, 2023
ecd66e7
Update README
hsm207 Apr 25, 2023
d55504f
Merge branch 'yoheinakajima:main' into main
Josh-XT Apr 25, 2023
d78ec4f
weaviate as a vector db option
zainhas Apr 27, 2023
d95910b
Update weaviate.md
zainhas Apr 27, 2023
e27b65a
added general vector db image
zainhas Apr 28, 2023
4e1e858
Update weaviate.md
zainhas Apr 28, 2023
3e0b86f
Merge branch 'main' into weaviate
hsm207 Apr 28, 2023
dc7c3b1
Fix for silent llama
dibrale Apr 28, 2023
db4f1f6
Updated Translations in README.md for better visibility
TungusSs Apr 28, 2023
c37d129
Fixed typo
TungusSs Apr 28, 2023
c4c36f4
Fix newline before full-stop in prompt.
atharvashukla Apr 29, 2023
36c6391
Update Readme.
atharvashukla Apr 29, 2023
fc9df2b
load environment variables before loading openai module (and support …
matatonic Apr 30, 2023
e92e62c
Create BabyBeeAGI
yoheinakajima Apr 30, 2023
4617233
Fixing small typo in BabyBeeAGI
elliottburris Apr 30, 2023
b5f5b9c
Add Sharpagi to inspired-projects
sathyarajv Apr 30, 2023
a4a820b
Merge pull request #284 from matatonic/patch-1
francip May 1, 2023
25906ff
Merge pull request #285 from elliottburris/patch-1
francip May 1, 2023
337c198
Merge pull request #282 from Permissioned-AI/main
francip May 1, 2023
ff617bf
Merge pull request #286 from sathyarajv/patch-1
francip May 1, 2023
e092b9d
Merge pull request #280 from TungusSs/translation-ru
francip May 1, 2023
a3902c7
Merge pull request #254 from hsm207/weaviate
francip May 1, 2023
7faedc4
Merge branch 'yoheinakajima:main' into patch-1
dibrale May 1, 2023
e3d0f47
Revert prompt changes
dibrale May 1, 2023
1e1cd48
Further prompt changes
dibrale May 1, 2023
d434357
Add missing openai config in tools scripts
hoangdd May 1, 2023
65512f2
Update babyagi.py
dibrale May 1, 2023
0d5d764
Implement babycoder main parts
fschieber88 May 1, 2023
b8f41f9
Create README.md
fschieber88 May 1, 2023
bd61ad4
Update .gitignore
fschieber88 May 1, 2023
3061d0f
Update README.md
fschieber88 May 1, 2023
7a8981c
README weaviate instructions
zainhas May 2, 2023
befd22f
Added a section on the readme to link to the 7-day github activity re…
jheitzeb May 2, 2023
36f035b
Update README.md
jheitzeb May 2, 2023
39d53c2
Update README.md
jheitzeb May 2, 2023
4d50022
get os name
fschieber88 May 3, 2023
7c11ada
Update README.md
fschieber88 May 3, 2023
a7f3416
Change command to it's original
xgame92 May 4, 2023
c74ef96
Merge branch 'main' into main
Josh-XT May 4, 2023
dae7239
Bump llama-cpp-python
matthoffner May 5, 2023
16c9b12
Create README-in.md
zeelsheladiya May 5, 2023
112dfb3
Update README-in.md
zeelsheladiya May 5, 2023
25be078
Update README.md
zeelsheladiya May 5, 2023
64e0d55
Update README.md
zeelsheladiya May 5, 2023
285e9ff
Update README.md
zeelsheladiya May 5, 2023
bad7dc0
Update requirements.txt
matthoffner May 7, 2023
10292ed
Merge pull request #302 from zeelsheladiya/main
francip May 10, 2023
e30fa12
Merge pull request #298 from xgame92/main
francip May 10, 2023
5b63484
Merge pull request #295 from jheitzeb/main
francip May 10, 2023
bddd633
Merge pull request #290 from hoangdd/main
francip May 10, 2023
4a3e71e
Merge pull request #294 from zainhas/main
francip May 10, 2023
d0a8400
Merge pull request #279 from dibrale/patch-1
francip May 10, 2023
5ef3e9d
Merge pull request #293 from fschieber88/babycoder
francip May 10, 2023
4003a6b
Merge pull request #299 from matthoffner/patch-1
francip May 10, 2023
f3a60c6
Merge branch 'main' into patch-2
francip May 10, 2023
c4e000e
Merge pull request #289 from dibrale/patch-2
francip May 10, 2023
60b605d
Merge pull request #230 from DevXT-LLC/main
francip May 10, 2023
64e8bdb
Create BabyCatAGI.py
yoheinakajima May 12, 2023
b70c5a0
add twitter-agent to inspired projects lists
bigsky77 May 22, 2023
7274c7b
Added Bengali language
Sabbbir Jun 1, 2023
7e7a443
Update README.md
eltociear Jun 6, 2023
c59478a
Merge pull request #331 from eltociear/patch-2
francip Jun 6, 2023
efa06b6
Merge pull request #328 from Sabbbir/Sabbbir-Bengali
francip Jun 6, 2023
f00831b
Merge pull request #320 from bigsky77/main
francip Jun 6, 2023
cef1db8
Rename BabyBeeAGI to BabyBeeAGI.py
yoheinakajima Jun 7, 2023
0cf0f7e
Create BabyDeerAGI.py
yoheinakajima Jun 7, 2023
6ec8a3c
Uploading BabyElfAGI
yoheinakajima Jul 10, 2023
0044154
Reverting text_completion in BabyElfAGI to gpt3.5
yoheinakajima Jul 11, 2023
d10b08c
Reverting text_completion in BabyElfAGI to gpt3.5
yoheinakajima Jul 11, 2023
1218572
Fix typo
jiansong15 Aug 19, 2023
291fd93
Update Ray version
tonyjzhou Aug 19, 2023
464a824
Update chromadb usage
tonyjzhou Aug 19, 2023
4569caf
Add files via upload
yoheinakajima Sep 1, 2023
0781675
Update README.md
yoheinakajima Sep 1, 2023
989890e
Update README.md
yoheinakajima Sep 1, 2023
0690733
Create pretty_me.py
yoheinakajima Sep 7, 2023
e1d40c5
Merge pull request #358 from tonyzhoujingtao/main
yoheinakajima Sep 7, 2023
10e92eb
add Vietnamese translation to README
DuongVu39 May 13, 2024
11c853d
Merge pull request #385 from duongqvu/main
francip May 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ OPENAI_TEMPERATURE=0.0
# TABLE_NAME can be used instead
RESULTS_STORE_NAME=baby-agi-test-table

# Weaviate config
# Uncomment and fill these to switch from local ChromaDB to Weaviate
# WEAVIATE_USE_EMBEDDED=true
# WEAVIATE_URL=
# WEAVIATE_API_KEY=

# Pinecone config
# Uncomment and fill these to switch from local ChromaDB to Pinecone
# PINECONE_API_KEY=
Expand Down
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# Translations:

[<img title="عربي" alt="عربي" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/sa.svg" width="22">](docs/README-ar.md)
[<img title="Français" alt="Français" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/fr.svg" width="22">](docs/README-fr.md)
[<img title="Polski" alt="Polski" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/pl.svg" width="22">](docs/README-pl.md)
[<img title="Portuguese" alt="Portuguese" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/br.svg" width="22">](docs/README-pt-br.md)
[<img title="Romanian" alt="Romanian" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/ro.svg" width="22">](docs/README-ro.md)
[<img title="Russian" alt="Russian" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/ru.svg" width="22">](docs/README-ru.md)
[<img title="Slovenian" alt="Slovenian" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/si.svg" width="22">](docs/README-si.md)
[<img title="Spanish" alt="Spanish" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/es.svg" width="22">](docs/README-es.md)
[<img title="Turkish" alt="Turkish" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/tr.svg" width="22">](docs/README-tr.md)
[<img title="Ukrainian" alt="Ukrainian" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/ua.svg" width="22">](docs/README-ua.md)
[<img title="简体中文" alt="Simplified Chinese" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/cn.svg" width="22">](docs/README-cn.md)
[<img title="繁體中文 (Traditional Chinese)" alt="繁體中文 (Traditional Chinese)" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/tw.svg" width="22">](docs/README-zh-tw.md)
[<img title="日本語" alt="日本語" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/jp.svg" width="22">](docs/README-ja.md)
[<img title="한국어" alt="한국어" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/kr.svg" width="22">](docs/README-ko.md)
[<img title="Magyar" alt="Magyar" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/hu.svg" width="22">](docs/README-hu.md)
[<img title="فارسی" alt="فارسی" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/ir.svg" width="22">](docs/README-fa.md)
[<img title="German" alt="German" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/de.svg" width="22">](docs/README-de.md)
[<img title="عربي" alt="عربي" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/sa.svg" width="30">](docs/README-ar.md)
[<img title="Français" alt="Français" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/fr.svg" width="30">](docs/README-fr.md)
[<img title="Polski" alt="Polski" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/pl.svg" width="30">](docs/README-pl.md)
[<img title="Portuguese" alt="Portuguese" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/br.svg" width="30">](docs/README-pt-br.md)
[<img title="Romanian" alt="Romanian" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/ro.svg" width="30">](docs/README-ro.md)
[<img title="Russian" alt="Russian" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/ru.svg" width="30">](docs/README-ru.md)
[<img title="Slovenian" alt="Slovenian" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/si.svg" width="30">](docs/README-si.md)
[<img title="Spanish" alt="Spanish" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/es.svg" width="30">](docs/README-es.md)
[<img title="Turkish" alt="Turkish" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/tr.svg" width="30">](docs/README-tr.md)
[<img title="Ukrainian" alt="Ukrainian" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/ua.svg" width="30">](docs/README-ua.md)
[<img title="简体中文" alt="Simplified Chinese" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/cn.svg" width="30">](docs/README-cn.md)
[<img title="繁體中文 (Traditional Chinese)" alt="繁體中文 (Traditional Chinese)" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/tw.svg" width="30">](docs/README-zh-tw.md)
[<img title="日本語" alt="日本語" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/jp.svg" width="30">](docs/README-ja.md)
[<img title="한국어" alt="한국어" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/kr.svg" width="30">](docs/README-ko.md)
[<img title="Magyar" alt="Magyar" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/hu.svg" width="30">](docs/README-hu.md)
[<img title="فارسی" alt="فارسی" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/ir.svg" width="30">](docs/README-fa.md)
[<img title="German" alt="German" src="https://cdn.staticaly.com/gh/hjnilsson/country-flags/master/svg/de.svg" width="30">](docs/README-de.md)

# Objective

This Python script is an example of an AI-powered task management system. The system uses OpenAI and Chroma to create, prioritize, and execute tasks. The main idea behind this system is that it creates tasks based on the result of previous tasks and a predefined objective. The script then uses OpenAI's natural language processing (NLP) capabilities to create new tasks based on the objective, and Chroma to store and retrieve task results for context. This is a pared-down version of the original [Task-Driven Autonomous Agent](https://twitter.com/yoheinakajima/status/1640934493489070080?s=20) (Mar 28, 2023).
This Python script is an example of an AI-powered task management system. The system uses OpenAI and vector databases such as Chroma or Weaviate to create, prioritize, and execute tasks. The main idea behind this system is that it creates tasks based on the result of previous tasks and a predefined objective. The script then uses OpenAI's natural language processing (NLP) capabilities to create new tasks based on the objective, and Chroma/Weaviate to store and retrieve task results for context. This is a pared-down version of the original [Task-Driven Autonomous Agent](https://twitter.com/yoheinakajima/status/1640934493489070080?s=20) (Mar 28, 2023).

This README will cover the following:

Expand All @@ -38,19 +38,19 @@ The script works by running an infinite loop that does the following steps:

1. Pulls the first task from the task list.
2. Sends the task to the execution agent, which uses OpenAI's API to complete the task based on the context.
3. Enriches the result and stores it in [Chroma](https://docs.trychroma.com).
3. Enriches the result and stores it in [Chroma](https://docs.trychroma.com)/[Weaviate](https://weaviate.io/).
4. Creates new tasks and reprioritizes the task list based on the objective and the result of the previous task.
</br>

![image](https://user-images.githubusercontent.com/6764957/232961802-e4c4c17d-b520-4db1-827c-a218a1647c73.png)
![image](https://user-images.githubusercontent.com/21254008/235015461-543a897f-70cc-4b63-941a-2ae3c9172b11.png)

The `execution_agent()` function is where the OpenAI API is used. It takes two parameters: the objective and the task. It then sends a prompt to OpenAI's API, which returns the result of the task. The prompt consists of a description of the AI system's task, the objective, and the task itself. The result is then returned as a string.

The `task_creation_agent()` function is where OpenAI's API is used to create new tasks based on the objective and the result of the previous task. The function takes four parameters: the objective, the result of the previous task, the task description, and the current task list. It then sends a prompt to OpenAI's API, which returns a list of new tasks as strings. The function then returns the new tasks as a list of dictionaries, where each dictionary contains the name of the task.

The `prioritization_agent()` function is where OpenAI's API is used to reprioritize the task list. The function takes one parameter, the ID of the current task. It sends a prompt to OpenAI's API, which returns the reprioritized task list as a numbered list.

Finally, the script uses Chroma to store and retrieve task results for context. The script creates a Chroma collection based on the table name specified in the TABLE_NAME variable. Chroma is then used to store the results of the task in the collection, along with the task name and any additional metadata.
Finally, the script uses Chroma/Weaviate to store and retrieve task results for context. The script creates a Chroma/Weaviate collection based on the table name specified in the TABLE_NAME variable. Chroma/Weaviate is then used to store the results of the task in the collection, along with the task name and any additional metadata.

# How to Use<a name="how-to-use"></a>

Expand Down
34 changes: 24 additions & 10 deletions babyagi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env python3
from dotenv import load_dotenv
# Load default environment variables (.env)
load_dotenv()

import os
import time
import logging
Expand All @@ -10,15 +14,12 @@
import tiktoken as tiktoken
from chromadb.utils.embedding_functions import OpenAIEmbeddingFunction
from chromadb.api.types import Documents, EmbeddingFunction, Embeddings
from dotenv import load_dotenv
import re

# default opt out of chromadb telemetry.
from chromadb.config import Settings
client = chromadb.Client(Settings(anonymized_telemetry=False))

# Load default environment variables (.env)
load_dotenv()

# Engine configuration

Expand Down Expand Up @@ -237,20 +238,33 @@ def query(self, query: str, top_results_num: int) -> List[dict]:


# Initialize results storage
results_storage = DefaultResultsStorage()
PINECONE_API_KEY = os.getenv("PINECONE_API_KEY", "")
if PINECONE_API_KEY:
if can_import("extensions.pinecone_storage"):
def try_weaviate():
WEAVIATE_URL = os.getenv("WEAVIATE_URL", "")
WEAVIATE_USE_EMBEDDED = os.getenv("WEAVIATE_USE_EMBEDDED", "False").lower() == "true"
if (WEAVIATE_URL or WEAVIATE_USE_EMBEDDED) and can_import("extensions.weaviate_storage"):
WEAVIATE_API_KEY = os.getenv("WEAVIATE_API_KEY", "")
from extensions.weaviate_storage import WeaviateResultsStorage
print("\nUsing results storage: " + "\033[93m\033[1m" + "Weaviate" + "\033[0m\033[0m")
return WeaviateResultsStorage(OPENAI_API_KEY, WEAVIATE_URL, WEAVIATE_API_KEY, WEAVIATE_USE_EMBEDDED, LLM_MODEL, LLAMA_MODEL_PATH, RESULTS_STORE_NAME, OBJECTIVE)
return None

def try_pinecone():
PINECONE_API_KEY = os.getenv("PINECONE_API_KEY", "")
if PINECONE_API_KEY and can_import("extensions.pinecone_storage"):
PINECONE_ENVIRONMENT = os.getenv("PINECONE_ENVIRONMENT", "")
assert (
PINECONE_ENVIRONMENT
), "\033[91m\033[1m" + "PINECONE_ENVIRONMENT environment variable is missing from .env" + "\033[0m\033[0m"
from extensions.pinecone_storage import PineconeResultsStorage
print("\nUsing results storage: " + "\033[93m\033[1m" + "Pinecone" + "\033[0m\033[0m")
return PineconeResultsStorage(OPENAI_API_KEY, PINECONE_API_KEY, PINECONE_ENVIRONMENT, LLM_MODEL, LLAMA_MODEL_PATH, RESULTS_STORE_NAME, OBJECTIVE)
return None

results_storage = PineconeResultsStorage(OPENAI_API_KEY, PINECONE_API_KEY, PINECONE_ENVIRONMENT, LLM_MODEL,
LLAMA_MODEL_PATH, RESULTS_STORE_NAME, OBJECTIVE)
print("\nReplacing results storage: " + "\033[93m\033[1m" + "Pinecone" + "\033[0m\033[0m")
def use_chroma():
print("\nUsing results storage: " + "\033[93m\033[1m" + "Chroma (Default)" + "\033[0m\033[0m")
return DefaultResultsStorage()

results_storage = try_weaviate() or try_pinecone() or use_chroma()

# Task storage supporting only a single instance of BabyAGI
class SingleTaskListStorage:
Expand Down
Loading