Skip to content

Commit

Permalink
Requirements for cooperative mode
Browse files Browse the repository at this point in the history
  • Loading branch information
francip committed Apr 6, 2023
1 parent 352c25e commit 3fdd6d4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
52 changes: 39 additions & 13 deletions babyagi.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env python3
import os
import openai
import pinecone
import time
import argparse
import importlib
import openai
import pinecone
from collections import deque
from typing import Dict, List
from dotenv import load_dotenv
import os

#Set Variables
load_dotenv()
Expand All @@ -30,26 +30,39 @@

# Run configuration

parser = argparse.ArgumentParser(add_help=False)
parser = argparse.ArgumentParser(
add_help=False,
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
examples:
* start solving world hunger by creating initial list of tasks using GPT-4:
%(prog)s -t "Create initial list of tasks" -4 Solve world hunger
* join the work on solving world hunger using GPT-3:
%(prog)s -j Solve world hunger
"""
)
parser.add_argument('objective', nargs='*', metavar='<objective>', help='''
Main objective description. Doesn\'t need to be quoted.
If not specified, get OBJECTIVE in environment.
main objective description. Doesn\'t need to be quoted.
if not specified, get OBJECTIVE from environment.
''', default=[os.getenv("OBJECTIVE", "")])
parser.add_argument('-n', '--name', required=False, help='''
BabyAGI instance name.
If not specified, get BABY_NAME in environment.
babyagi instance name.
if not specified, get BABY_NAME from environment.
''', default=os.getenv("BABY_NAME", "BabyAGI"))
group = parser.add_mutually_exclusive_group()
group.add_argument('-t', '--task', metavar='<initial task>', help='''
Initial task description. Must be quoted.
If not specified, get INITIAL_TASK in environment.
initial task description. must be quoted.
if not specified, get INITIAL_TASK from environment.
''', default=os.getenv("INITIAL_TASK", os.getenv("FIRST_TASK", "")))
group.add_argument('-j', '--join', action='store_true', help='''
Join an existing objective.
join an existing objective.
install cooperative requirements.
''')
parser.add_argument('-4', '--gpt-4', dest='use_gpt4', action='store_true', help='''
use GPT-4 instead of GPT-3
''')
parser.add_argument('-4', '--gpt-4', dest='use_gpt4', action='store_true', help='Use GPT-4 instead of GPT-3')
parser.add_argument('-h', '-?', '--help', action='help', help='''
Show this help message and exit
show this help message and exit
''')

args = parser.parse_args()
Expand All @@ -60,7 +73,20 @@
parser.print_help()
parser.exit()

def can_import(module_name):
try:
importlib.import_module(module_name)
return True
except ImportError:
return False

module_name = "ray"
JOIN_EXISTING_OBJECTIVE = args.join
if JOIN_EXISTING_OBJECTIVE and not can_import(module_name):
print("\033[91m\033[1m"+f"Package {module_name} not installed\nInstall: pip install -r requirements-cooperative.txt\n"+"\033[0m\033[0m")
parser.print_help()
parser.exit()

USE_GPT4 = args.use_gpt4

OBJECTIVE = ' '.join(args.objective).strip()
Expand Down
2 changes: 2 additions & 0 deletions requirements-cooperative.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-r requirements.txt
ray==2.3.1

0 comments on commit 3fdd6d4

Please sign in to comment.