From 16c0dc9267135a2b168bfcca3a29eedc573c02e0 Mon Sep 17 00:00:00 2001 From: CalCameron Date: Fri, 14 Apr 2023 17:47:16 -0500 Subject: [PATCH 01/19] Filer Logger that tracks changes to file operations to prevent looping --- autogpt/file_operations.py | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/autogpt/file_operations.py b/autogpt/file_operations.py index 22fd57ab..9f0697ff 100644 --- a/autogpt/file_operations.py +++ b/autogpt/file_operations.py @@ -4,11 +4,35 @@ import os.path # Set a dedicated folder for file I/O working_directory = "auto_gpt_workspace" +log_file = "file_logger.txt" + + # Create the directory if it doesn't exist if not os.path.exists(working_directory): os.makedirs(working_directory) + +def log_operation(operation, filename): + """Log the file operation to the file_logger.txt""" + log_entry = f"{operation}: {filename}\n" + + log_filepath = safe_join(working_directory, log_file) + + # Create the log file if it doesn't exist + if not os.path.exists(log_filepath): + with open(log_filepath, "w", encoding="utf-8") as f: + f.write("File Operation Logger ") + + append_to_file(log_file, log_entry) + + +def check_duplicate_operation(operation, filename): + """Check if the operation has already been performed on the given file""" + log_content = read_file(log_file) + log_entry = f"{operation}: {filename}\n" + return log_entry in log_content + def safe_join(base, *paths): """Join one or more path components intelligently.""" new_path = os.path.join(base, *paths) @@ -87,7 +111,10 @@ def ingest_file(filename, memory, max_length=4000, overlap=200): def write_to_file(filename, text): - """Write text to a file""" + """Write text to a file and log the operation""" + if check_duplicate_operation("write", filename): + return "Error: File has already been updated." + try: filepath = safe_join(working_directory, filename) directory = os.path.dirname(filepath) @@ -95,6 +122,7 @@ def write_to_file(filename, text): os.makedirs(directory) with open(filepath, "w", encoding="utf-8") as f: f.write(text) + log_operation("write", filename) return "File written to successfully." except Exception as e: return "Error: " + str(e) @@ -112,10 +140,14 @@ def append_to_file(filename, text): def delete_file(filename): - """Delete a file""" + """Delete a file and log the operation""" + if check_duplicate_operation("delete", filename): + return "Error: File has already been deleted." + try: filepath = safe_join(working_directory, filename) os.remove(filepath) + log_operation("delete", filename) return "File deleted successfully." except Exception as e: return "Error: " + str(e) From 8293d96f24484ccb22556a2fc6f61e804f754820 Mon Sep 17 00:00:00 2001 From: Omri Grossman Date: Sat, 15 Apr 2023 23:15:28 +0300 Subject: [PATCH 02/19] Added tests for `create_chat_message` and `generate_context` methods of the chat module --- tests/test_chat.py | 116 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 tests/test_chat.py diff --git a/tests/test_chat.py b/tests/test_chat.py new file mode 100644 index 00000000..5bf652e6 --- /dev/null +++ b/tests/test_chat.py @@ -0,0 +1,116 @@ + +# Generated by CodiumAI +import unittest +import time +from unittest.mock import patch + +from autogpt.chat import create_chat_message, generate_context + + + +""" +Code Analysis + +Objective: +The objective of the function is to create a chat message with the given role and content and return it as a dictionary. + +Inputs: +The function takes two inputs: +- role (str): The role of the message sender, e.g., "system", "user", or "assistant". +- content (str): The content of the message. + +Flow: +The function takes the role and content as input and creates a dictionary containing the role and content of the message. It then returns the dictionary as output. + +Outputs: +The function returns a dictionary containing the role and content of the message. + +""" + + +class TestChat(unittest.TestCase): + + # Tests that the function returns a dictionary with the correct keys and values when valid strings are provided for role and content. + def test_happy_path_role_content(self): + result = create_chat_message("system", "Hello, world!") + self.assertEqual(result, {"role": "system", "content": "Hello, world!"}) + + # Tests that the function returns a dictionary with the correct keys and values when empty strings are provided for role and content. + def test_empty_role_content(self): + result = create_chat_message("", "") + self.assertEqual(result, {"role": "", "content": ""}) + + # Tests the behavior of the generate_context function when all input parameters are empty. + @patch("time.strftime") + def test_generate_context_empty_inputs(self, mock_strftime): + # Mock the time.strftime function to return a fixed value + mock_strftime.return_value = "Sat Apr 15 00:00:00 2023" + # Arrange + prompt = "" + relevant_memory = "" + full_message_history = [] + model = "gpt-3.5-turbo-0301" + + # Act + result = generate_context(prompt, relevant_memory, full_message_history, model) + + # Assert + expected_result = (-1, 47, 3, [ + {"role": "system", "content": ""}, + {"role": "system", "content": f"The current time and date is {time.strftime('%c')}"}, + {"role": "system", "content": f"This reminds you of these events from your past:\n\n\n"}, + ]) + self.assertEqual(result, expected_result) + + # Tests that the function successfully generates a current_context given valid inputs. + def test_generate_context_valid_inputs(self): + # Given + prompt = "What is your favorite color?" + relevant_memory = "You once painted your room blue." + full_message_history = [ + create_chat_message("user", "Hi there!"), + create_chat_message("assistant", "Hello! How can I assist you today?"), + create_chat_message("user", "Can you tell me a joke?"), + create_chat_message("assistant", "Why did the tomato turn red? Because it saw the salad dressing!"), + create_chat_message("user", "Haha, that's funny."), + ] + model = "gpt-3.5-turbo-0301" + + # When + result = generate_context(prompt, relevant_memory, full_message_history, model) + + # Then + self.assertIsInstance(result[0], int) + self.assertIsInstance(result[1], int) + self.assertIsInstance(result[2], int) + self.assertIsInstance(result[3], list) + self.assertGreaterEqual(result[0], 0) + self.assertGreaterEqual(result[1], 0) + self.assertGreaterEqual(result[2], 0) + self.assertGreaterEqual(len(result[3]), 3) # current_context should have at least 3 messages + self.assertLessEqual(result[1], 2048) # token limit for GPT-3.5-turbo-0301 is 2048 tokens + + # Tests that the function works correctly with valid inputs. + def test_generate_context_valid_inputs(self): + # Arrange + prompt = "Hello, how can I assist you today?" + relevant_memory = "You previously mentioned needing help with a software issue." + full_message_history = [ + create_chat_message("user", "Can you help me with a software issue?"), + create_chat_message("assistant", "Of course, what seems to be the problem?"), + create_chat_message("user", "I keep getting an error message."), + create_chat_message("assistant", "Let's try some troubleshooting steps."), + ] + model = "gpt-3.5-turbo-0301" + + # Act + next_message_index, tokens_used, insertion_index, context = generate_context( + prompt, relevant_memory, full_message_history, model + ) + + # Assert + self.assertEqual(next_message_index, 3) + self.assertGreater(tokens_used, 0) + self.assertLessEqual(tokens_used, 2048) + self.assertEqual(insertion_index, 3) + self.assertEqual(len(context), 3) From e3751f0e36fe741d5385783d0ac18a541d6879fd Mon Sep 17 00:00:00 2001 From: Omri Grossman Date: Sat, 15 Apr 2023 23:23:37 +0300 Subject: [PATCH 03/19] Removed comments --- tests/test_chat.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/tests/test_chat.py b/tests/test_chat.py index 5bf652e6..f81b1869 100644 --- a/tests/test_chat.py +++ b/tests/test_chat.py @@ -7,27 +7,6 @@ from unittest.mock import patch from autogpt.chat import create_chat_message, generate_context - -""" -Code Analysis - -Objective: -The objective of the function is to create a chat message with the given role and content and return it as a dictionary. - -Inputs: -The function takes two inputs: -- role (str): The role of the message sender, e.g., "system", "user", or "assistant". -- content (str): The content of the message. - -Flow: -The function takes the role and content as input and creates a dictionary containing the role and content of the message. It then returns the dictionary as output. - -Outputs: -The function returns a dictionary containing the role and content of the message. - -""" - - class TestChat(unittest.TestCase): # Tests that the function returns a dictionary with the correct keys and values when valid strings are provided for role and content. From accec9ab75f99af796c6b08f2a99e2d1e233c743 Mon Sep 17 00:00:00 2001 From: Omri Grossman Date: Sat, 15 Apr 2023 23:32:22 +0300 Subject: [PATCH 04/19] Lint fixes - extra whitespace --- tests/test_chat.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/test_chat.py b/tests/test_chat.py index f81b1869..d3e84a3c 100644 --- a/tests/test_chat.py +++ b/tests/test_chat.py @@ -9,17 +9,17 @@ from autogpt.chat import create_chat_message, generate_context class TestChat(unittest.TestCase): - # Tests that the function returns a dictionary with the correct keys and values when valid strings are provided for role and content. + # Tests that the function returns a dictionary with the correct keys and values when valid strings are provided for role and content. def test_happy_path_role_content(self): result = create_chat_message("system", "Hello, world!") self.assertEqual(result, {"role": "system", "content": "Hello, world!"}) - # Tests that the function returns a dictionary with the correct keys and values when empty strings are provided for role and content. + # Tests that the function returns a dictionary with the correct keys and values when empty strings are provided for role and content. def test_empty_role_content(self): result = create_chat_message("", "") self.assertEqual(result, {"role": "", "content": ""}) - # Tests the behavior of the generate_context function when all input parameters are empty. + # Tests the behavior of the generate_context function when all input parameters are empty. @patch("time.strftime") def test_generate_context_empty_inputs(self, mock_strftime): # Mock the time.strftime function to return a fixed value @@ -41,7 +41,7 @@ class TestChat(unittest.TestCase): ]) self.assertEqual(result, expected_result) - # Tests that the function successfully generates a current_context given valid inputs. + # Tests that the function successfully generates a current_context given valid inputs. def test_generate_context_valid_inputs(self): # Given prompt = "What is your favorite color?" @@ -69,7 +69,7 @@ class TestChat(unittest.TestCase): self.assertGreaterEqual(len(result[3]), 3) # current_context should have at least 3 messages self.assertLessEqual(result[1], 2048) # token limit for GPT-3.5-turbo-0301 is 2048 tokens - # Tests that the function works correctly with valid inputs. + # Tests that the function works correctly with valid inputs. def test_generate_context_valid_inputs(self): # Arrange prompt = "Hello, how can I assist you today?" From 167d1be130c683fe6c2af82f1ca4e2864b1911ec Mon Sep 17 00:00:00 2001 From: Omri Grossman Date: Sat, 15 Apr 2023 23:40:03 +0300 Subject: [PATCH 05/19] Moved test_chat to /unit --- tests/{ => unit}/test_chat.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{ => unit}/test_chat.py (100%) diff --git a/tests/test_chat.py b/tests/unit/test_chat.py similarity index 100% rename from tests/test_chat.py rename to tests/unit/test_chat.py From 5495d6c0d38b4ac922aeab7b8f43d26a211f6fec Mon Sep 17 00:00:00 2001 From: Omri Grossman Date: Sun, 16 Apr 2023 00:09:33 +0300 Subject: [PATCH 06/19] Removed redundant test --- tests/unit/test_chat.py | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/tests/unit/test_chat.py b/tests/unit/test_chat.py index d3e84a3c..258ed62b 100644 --- a/tests/unit/test_chat.py +++ b/tests/unit/test_chat.py @@ -68,28 +68,3 @@ class TestChat(unittest.TestCase): self.assertGreaterEqual(result[2], 0) self.assertGreaterEqual(len(result[3]), 3) # current_context should have at least 3 messages self.assertLessEqual(result[1], 2048) # token limit for GPT-3.5-turbo-0301 is 2048 tokens - - # Tests that the function works correctly with valid inputs. - def test_generate_context_valid_inputs(self): - # Arrange - prompt = "Hello, how can I assist you today?" - relevant_memory = "You previously mentioned needing help with a software issue." - full_message_history = [ - create_chat_message("user", "Can you help me with a software issue?"), - create_chat_message("assistant", "Of course, what seems to be the problem?"), - create_chat_message("user", "I keep getting an error message."), - create_chat_message("assistant", "Let's try some troubleshooting steps."), - ] - model = "gpt-3.5-turbo-0301" - - # Act - next_message_index, tokens_used, insertion_index, context = generate_context( - prompt, relevant_memory, full_message_history, model - ) - - # Assert - self.assertEqual(next_message_index, 3) - self.assertGreater(tokens_used, 0) - self.assertLessEqual(tokens_used, 2048) - self.assertEqual(insertion_index, 3) - self.assertEqual(len(context), 3) From a6432e6ce48ee16017c7e3f6fb2f8273c9a21cc6 Mon Sep 17 00:00:00 2001 From: Ding3LI Date: Sat, 15 Apr 2023 16:26:42 -0500 Subject: [PATCH 07/19] [template] env template: added clarification, optional usages --- .env.template | 5 ++++- README.md | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.env.template b/.env.template index 6565dfdc..a030a939 100644 --- a/.env.template +++ b/.env.template @@ -50,7 +50,10 @@ SMART_TOKEN_LIMIT=8000 ### MEMORY ################################################################################ -# MEMORY_BACKEND - Memory backend type (Default: local) +### MEMORY_BACKEND - Memory backend type +# local - Default +# pinecone - Pinecone (if configured) +# redis - Redis (if configured) MEMORY_BACKEND=local ### PINECONE diff --git a/README.md b/README.md index f2ad74e5..16dcbc5f 100644 --- a/README.md +++ b/README.md @@ -124,8 +124,8 @@ pip install -r requirements.txt - `smart_llm_model_deployment_id` - your gpt-4 deployment ID - `embedding_model_deployment_id` - your text-embedding-ada-002 v2 deployment ID - Please specify all of these values as double-quoted strings - > Replace string in angled brackets (<>) to your own ID ```yaml + # Replace string in angled brackets (<>) to your own ID azure_model_map: fast_llm_model_deployment_id: "" ... @@ -323,9 +323,9 @@ By default, Auto-GPT is going to use LocalCache instead of redis or Pinecone. To switch to either, change the `MEMORY_BACKEND` env variable to the value that you want: -`local` (default) uses a local JSON cache file -`pinecone` uses the Pinecone.io account you configured in your ENV settings -`redis` will use the redis cache that you configured +* `local` (default) uses a local JSON cache file +* `pinecone` uses the Pinecone.io account you configured in your ENV settings +* `redis` will use the redis cache that you configured ## View Memory Usage From f57e3cfecbbc9901d52ecb531aa6ed1f8ee85457 Mon Sep 17 00:00:00 2001 From: Domenico Giambra Date: Sun, 16 Apr 2023 00:27:16 +0200 Subject: [PATCH 08/19] Typo in prompt start - missing space resulted in joined words in the prompt --- autogpt/config/ai_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogpt/config/ai_config.py b/autogpt/config/ai_config.py index c72b088b..014e360f 100644 --- a/autogpt/config/ai_config.py +++ b/autogpt/config/ai_config.py @@ -100,7 +100,7 @@ class AIConfig: prompt_start = ( "Your decisions must always be made independently without" - "seeking user assistance. Play to your strengths as an LLM and pursue" + " seeking user assistance. Play to your strengths as an LLM and pursue" " simple strategies with no legal complications." "" ) From 9e4cc5cc784be121af87cfd90befce3aa4285608 Mon Sep 17 00:00:00 2001 From: Mike M Date: Sat, 15 Apr 2023 17:31:36 -0500 Subject: [PATCH 09/19] Fix update bracket_termination.py with f string --- autogpt/json_fixes/bracket_termination.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogpt/json_fixes/bracket_termination.py b/autogpt/json_fixes/bracket_termination.py index 13c2ccfd..692461aa 100644 --- a/autogpt/json_fixes/bracket_termination.py +++ b/autogpt/json_fixes/bracket_termination.py @@ -37,7 +37,7 @@ def attempt_to_fix_json_by_finding_outermost_brackets(json_string: str): except (json.JSONDecodeError, ValueError): if CFG.debug_mode: - logger.error("Error: Invalid JSON: %s\n", json_string) + logger.error(f"Error: Invalid JSON: {json_string}\n") if CFG.speak_mode: say_text("Didn't work. I will have to ignore this response then.") logger.error("Error: Invalid JSON, setting it to empty JSON now.\n") From 04189de9c552cf3852d00440dfafdedeab1e1ca8 Mon Sep 17 00:00:00 2001 From: Domenico Giambra Date: Sun, 16 Apr 2023 00:32:26 +0200 Subject: [PATCH 10/19] Prints to console what the assistant wants to say --- autogpt/logs.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/autogpt/logs.py b/autogpt/logs.py index a34d89b1..c644c5ea 100644 --- a/autogpt/logs.py +++ b/autogpt/logs.py @@ -272,6 +272,10 @@ def print_assistant_thoughts(ai_name, assistant_reply): # Speak the assistant's thoughts if CFG.speak_mode and assistant_thoughts_speak: say_text(assistant_thoughts_speak) + else: + logger.typewriter_log( + "SPEAK:", Fore.YELLOW, f"{assistant_thoughts_speak}" + ) return assistant_reply_json except json.decoder.JSONDecodeError: From bdb93631d666c9973f6d21e0dc04b2727e9b6094 Mon Sep 17 00:00:00 2001 From: Danyal Mohaddes Date: Sat, 15 Apr 2023 21:23:32 -0400 Subject: [PATCH 11/19] added packages necessary to run docker from terminal --- requirements-docker.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requirements-docker.txt b/requirements-docker.txt index fecbd0a6..eeca3982 100644 --- a/requirements-docker.txt +++ b/requirements-docker.txt @@ -23,3 +23,6 @@ numpy pre-commit black isort +gitpython +tweepy +pymilvus From d5ae51aab050513f7bfcccb0989645e042e420b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A6=83=E7=A7=89=E4=B8=B0?= <114479602@qq.com> Date: Sun, 16 Apr 2023 11:18:48 +0800 Subject: [PATCH 12/19] add tweepy module --- requirements-docker.txt | 1 + requirements.txt | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/requirements-docker.txt b/requirements-docker.txt index fecbd0a6..937f58ab 100644 --- a/requirements-docker.txt +++ b/requirements-docker.txt @@ -23,3 +23,4 @@ numpy pre-commit black isort +tweepy \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 210f06d0..503d4a2a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,4 +26,5 @@ sourcery isort gitpython==3.1.31 pytest -pytest-mock \ No newline at end of file +pytest-mock +tweepy \ No newline at end of file From a2000b4b9d03ac4eeeb8099cf4ce269523c22796 Mon Sep 17 00:00:00 2001 From: Ayush Kumar Date: Sun, 16 Apr 2023 09:53:51 +0530 Subject: [PATCH 13/19] resolved tweepy not in requirements.txt --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 210f06d0..503d4a2a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,4 +26,5 @@ sourcery isort gitpython==3.1.31 pytest -pytest-mock \ No newline at end of file +pytest-mock +tweepy \ No newline at end of file From b64a4881d99ed1d5b466aed4457501da7fbfa434 Mon Sep 17 00:00:00 2001 From: John <81686492+Explorergt92@users.noreply.github.com> Date: Sun, 16 Apr 2023 01:05:51 -0400 Subject: [PATCH 14/19] Update README.md clarifying the .env.template step --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f4c6bbc..d3d91f0c 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,16 @@ cd Auto-GPT pip install -r requirements.txt ``` -5. Rename `.env.template` to `.env` and fill in your `OPENAI_API_KEY`. If you plan to use Speech Mode, fill in your `ELEVENLABS_API_KEY` as well. +5. Locate the file named '.env.template' in the 'Auto-GPT' folder. + Open the ".env.template" file in a text editor. + Find the line that says "OPENAI_API_KEY=". + After the "=", enter your unique OpenAI API Key (without any quotes or spaces). + Enter any other API keys or Tokens for services you would like to utilize. + Rename this file to ".env" by removing the ".template" extension. + Use the 'Save as..' option and chose 'No Extension' from the 'Save as type:' dropdown menu below the file name. + Save and close the ".env" file. + By completing these steps, you have properly configured the API Keys for your project. + - See [OpenAI API Keys Configuration](#openai-api-keys-configuration) to obtain your OpenAI API key. - Obtain your ElevenLabs API key from: https://elevenlabs.io. You can view your xi-api-key using the "Profile" tab on the website. - If you want to use GPT on an Azure instance, set `USE_AZURE` to `True` and then follow these steps: From 4374e4a43fab643ff666c8d859447fe176f145de Mon Sep 17 00:00:00 2001 From: John <81686492+Explorergt92@users.noreply.github.com> Date: Sun, 16 Apr 2023 01:31:00 -0400 Subject: [PATCH 15/19] Update to README.md fixed syntax --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d3d91f0c..619ca547 100644 --- a/README.md +++ b/README.md @@ -115,14 +115,14 @@ cd Auto-GPT pip install -r requirements.txt ``` -5. Locate the file named '.env.template' in the 'Auto-GPT' folder. - Open the ".env.template" file in a text editor. - Find the line that says "OPENAI_API_KEY=". - After the "=", enter your unique OpenAI API Key (without any quotes or spaces). +5. Locate the file named `.env.template` in the main `/Auto-GPT` folder. + Open the `.env.template` file in a text editor. + Find the line that says `OPENAI_API_KEY=`. + After the `"="`, enter your unique OpenAI API Key (without any quotes or spaces). Enter any other API keys or Tokens for services you would like to utilize. - Rename this file to ".env" by removing the ".template" extension. - Use the 'Save as..' option and chose 'No Extension' from the 'Save as type:' dropdown menu below the file name. - Save and close the ".env" file. + Rename this file to `.env` by removing the `.template` extension. + Use the `"Save as.."` option and chose `"No Extension"` from the "`Save as type:"` dropdown menu below the file name. + Save and close the `".env"` file. By completing these steps, you have properly configured the API Keys for your project. - See [OpenAI API Keys Configuration](#openai-api-keys-configuration) to obtain your OpenAI API key. From 17f3df0a04985ad1e4b6b110b7f7f55ad805aad9 Mon Sep 17 00:00:00 2001 From: Richard Beales Date: Sun, 16 Apr 2023 06:31:17 +0100 Subject: [PATCH 16/19] Create Docker Image CI Github action to build the docker image on CI --- .github/workflows/docker-image.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 00000000..9c77098e --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,18 @@ +name: Docker Image CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag autogpt:$(date +%s) From ca47a58a5db6bb467b70d219df70c836fe0f21de Mon Sep 17 00:00:00 2001 From: Yue Liu <41297969+YueLiu-coder@users.noreply.github.com> Date: Sun, 16 Apr 2023 13:47:13 +0800 Subject: [PATCH 17/19] Catch exception of repository clone --- autogpt/commands/git_operations.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/autogpt/commands/git_operations.py b/autogpt/commands/git_operations.py index 3483474b..3ff35cf3 100644 --- a/autogpt/commands/git_operations.py +++ b/autogpt/commands/git_operations.py @@ -16,5 +16,8 @@ def clone_repository(repo_url: str, clone_path: str) -> str: str: The result of the clone operation""" split_url = repo_url.split("//") auth_repo_url = f"//{CFG.github_username}:{CFG.github_api_key}@".join(split_url) - git.Repo.clone_from(auth_repo_url, clone_path) - return f"""Cloned {repo_url} to {clone_path}""" + try: + git.Repo.clone_from(auth_repo_url, clone_path) + return f"""Cloned {repo_url} to {clone_path}""" + except Exception as e: + return f"Error: {str(e)}" From 7872c4ecf466b20d8022cfe5042b24f1ad37b9ab Mon Sep 17 00:00:00 2001 From: Richard Beales Date: Sun, 16 Apr 2023 06:48:03 +0100 Subject: [PATCH 18/19] clarify/tweak instructions and wording --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 619ca547..d9c887d6 100644 --- a/README.md +++ b/README.md @@ -116,12 +116,11 @@ pip install -r requirements.txt ``` 5. Locate the file named `.env.template` in the main `/Auto-GPT` folder. - Open the `.env.template` file in a text editor. + Create a copy of this file, called `.env` by removing the `template` extension. The easiest way is to do this in a command prompt/terminal window `cp .env.template .env` + Open the `.env` file in a text editor. Note: Files starting with a dot might be hidden by your Operating System. Find the line that says `OPENAI_API_KEY=`. After the `"="`, enter your unique OpenAI API Key (without any quotes or spaces). Enter any other API keys or Tokens for services you would like to utilize. - Rename this file to `.env` by removing the `.template` extension. - Use the `"Save as.."` option and chose `"No Extension"` from the "`Save as type:"` dropdown menu below the file name. Save and close the `".env"` file. By completing these steps, you have properly configured the API Keys for your project. From e61c48ea854f28a9b6b359b8aaebdea2965f1f67 Mon Sep 17 00:00:00 2001 From: chyezh Date: Sun, 16 Apr 2023 12:01:17 +0800 Subject: [PATCH 19/19] README fix, update Table Of Contents, fix and better memory backend setup guide --- README.md | 54 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index de418ae9..cad5699f 100644 --- a/README.md +++ b/README.md @@ -48,19 +48,20 @@ Your support is greatly appreciated - [Docker](#docker) - [Command Line Arguments](#command-line-arguments) - [🗣️ Speech Mode](#️-speech-mode) + - [List of IDs with names from eleven labs, you can use the name or ID:](#list-of-ids-with-names-from-eleven-labs-you-can-use-the-name-or-id) + - [OpenAI API Keys Configuration](#openai-api-keys-configuration) - [🔍 Google API Keys Configuration](#-google-api-keys-configuration) - [Setting up environment variables](#setting-up-environment-variables) - [Memory Backend Setup](#memory-backend-setup) - [Redis Setup](#redis-setup) - [🌲 Pinecone API Key Setup](#-pinecone-api-key-setup) - [Milvus Setup](#milvus-setup) - - [Setting up environment variables](#setting-up-environment-variables-1) - - [Setting Your Cache Type](#setting-your-cache-type) - [View Memory Usage](#view-memory-usage) - [🧠 Memory pre-seeding](#-memory-pre-seeding) - [💀 Continuous Mode ⚠️](#-continuous-mode-️) - [GPT3.5 ONLY Mode](#gpt35-only-mode) - [🖼 Image Generation](#-image-generation) + - [Selenium](#selenium) - [⚠️ Limitations](#️-limitations) - [🛡 Disclaimer](#-disclaimer) - [🐦 Connect with Us on Twitter](#-connect-with-us-on-twitter) @@ -262,7 +263,18 @@ export GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY" export CUSTOM_SEARCH_ENGINE_ID="YOUR_CUSTOM_SEARCH_ENGINE_ID" ``` -## Redis Setup +## Memory Backend Setup + +By default, Auto-GPT is going to use LocalCache. +To switch to either, change the `MEMORY_BACKEND` env variable to the value that you want: + +- `local` (default) uses a local JSON cache file +- `pinecone` uses the Pinecone.io account you configured in your ENV settings +- `redis` will use the redis cache that you configured +- `milvus` will use the milvus that you configured + +### Redis Setup + > _**CAUTION**_ \ This is not intended to be publicly accessible and lacks security measures. Therefore, avoid exposing Redis to the internet without a password or at all 1. Install docker desktop @@ -301,20 +313,6 @@ Pinecone enables the storage of vast amounts of vector-based memory, allowing fo 2. Choose the `Starter` plan to avoid being charged. 3. Find your API key and region under the default project in the left sidebar. -### Milvus Setup - -[Milvus](https://milvus.io/) is a open-source, high scalable vector database to storage huge amount of vector-based memory and provide fast relevant search. - -- setup milvus database, keep your pymilvus version and milvus version same to avoid compatible issues. - - setup by open source [Install Milvus](https://milvus.io/docs/install_standalone-operator.md) - - or setup by [Zilliz Cloud](https://zilliz.com/cloud) -- set `MILVUS_ADDR` in `.env` to your milvus address `host:ip`. -- set `MEMORY_BACKEND` in `.env` to `milvus` to enable milvus as backend. -- optional - - set `MILVUS_COLLECTION` in `.env` to change milvus collection name as you want, `autogpt` is the default name. - -### Setting up environment variables - In the `.env` file set: - `PINECONE_API_KEY` - `PINECONE_ENV` (example: _"us-east4-gcp"_) @@ -338,15 +336,17 @@ export PINECONE_ENV="" # e.g: "us-east4-gcp" export MEMORY_BACKEND="pinecone" ``` -## Setting Your Cache Type +### Milvus Setup -By default, Auto-GPT is going to use LocalCache instead of redis or Pinecone. +[Milvus](https://milvus.io/) is a open-source, high scalable vector database to storage huge amount of vector-based memory and provide fast relevant search. -To switch to either, change the `MEMORY_BACKEND` env variable to the value that you want: - -* `local` (default) uses a local JSON cache file -* `pinecone` uses the Pinecone.io account you configured in your ENV settings -* `redis` will use the redis cache that you configured +- setup milvus database, keep your pymilvus version and milvus version same to avoid compatible issues. + - setup by open source [Install Milvus](https://milvus.io/docs/install_standalone-operator.md) + - or setup by [Zilliz Cloud](https://zilliz.com/cloud) +- set `MILVUS_ADDR` in `.env` to your milvus address `host:ip`. +- set `MEMORY_BACKEND` in `.env` to `milvus` to enable milvus as backend. +- optional + - set `MILVUS_COLLECTION` in `.env` to change milvus collection name as you want, `autogpt` is the default name. ## View Memory Usage @@ -355,7 +355,8 @@ To switch to either, change the `MEMORY_BACKEND` env variable to the value that ## 🧠 Memory pre-seeding -# python autogpt/data_ingestion.py -h + python autogpt/data_ingestion.py -h + usage: data_ingestion.py [-h] (--file FILE | --dir DIR) [--init] [--overlap OVERLAP] [--max_length MAX_LENGTH] Ingest a file or a directory with multiple files into memory. Make sure to set your .env before running this script. @@ -368,7 +369,8 @@ options: --overlap OVERLAP The overlap size between chunks when ingesting files (default: 200) --max_length MAX_LENGTH The max_length of each chunk when ingesting files (default: 4000) -# python autogpt/data_ingestion.py --dir seed_data --init --overlap 200 --max_length 1000 + python autogpt/data_ingestion.py --dir seed_data --init --overlap 200 --max_length 1000 + This script located at autogpt/data_ingestion.py, allows you to ingest files into memory and pre-seed it before running Auto-GPT. Memory pre-seeding is a technique that involves ingesting relevant documents or data into the AI's memory so that it can use this information to generate more informed and accurate responses.