diff --git a/README.md b/README.md index c2a02ce..7fc09d4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # natbot -Drive a browser with GPT-3 +Drive a browser with GPT-3 or [Text-Generator.io](https://text-generator.io) Here's a demo: https://twitter.com/natfriedman/status/1575631194032549888 @@ -12,3 +12,19 @@ Lots of ideas for improvement: - Let the agent use multiple tabs and switch between them Improvements welcome! + + +### Running + +#### Setup + +``` +pip install -r requirements.txt +playwright install +``` + +#### Run + +``` +python natbot.py +``` diff --git a/natbot.py b/natbot.py index 9842fbf..3181661 100755 --- a/natbot.py +++ b/natbot.py @@ -536,7 +536,11 @@ def add_to_hash_tree(hash_tree, tag, node_id, node_name, parent_id): ): _crawler = Crawler() openai.api_key = os.environ.get("OPENAI_API_KEY") - + # use text-generator.io instead of OpenAI if there is a environment var set + text_generator_api_key = os.getenv("TEXTGENERATOR_API_KEY") + if text_generator_api_key: + openai.api_key = text_generator_api_key + openai.api_base = "https://api.text-generator.io" def print_help(): print( "(g) to visit url\n(u) scroll up\n(d) scroll dow\n(c) to click\n(t) to type\n" + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..5c484d4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ + +openai +playwright +