Merge branch 'master' into browse_scrape_links_test_and_validate

This commit is contained in:
Itamar Friedman
2023-04-12 23:51:53 +03:00
15 changed files with 29 additions and 19 deletions

View File

@@ -7,7 +7,19 @@ body:
value: | value: |
Please provide a searchable summary of the issue in the title above ⬆️. Please provide a searchable summary of the issue in the title above ⬆️.
Thanks for contributing by creating an issue! ❤️ ⚠️ SUPER-busy repo, please help the volunteer maintainers.
The less time we spend here, the more time we spend building AutoGPT.
Please help us help you:
- Does it work on `stable` branch (https://github.com/Torantulino/Auto-GPT/tree/stable)?
- Does it work on current `master` (https://github.com/Torantulino/Auto-GPT/tree/master)?
- Search for existing issues, "add comment" is tidier than "new issue"
- Ask on our Discord (https://discord.gg/autogpt)
- Provide relevant info:
- Provide commit-hash (`git rev-parse HEAD` gets it)
- If it's a pip/packages issue, provide pip version, python version
- If it's a crash, provide traceback.
- type: checkboxes - type: checkboxes
attributes: attributes:
label: Duplicates label: Duplicates
@@ -32,8 +44,8 @@ body:
attributes: attributes:
label: Your prompt 📝 label: Your prompt 📝
description: | description: |
Please provide the prompt you are using. You can find your last-used prompt in last_run_ai_settings.yaml. If applicable please provide the prompt you are using. You can find your last-used prompt in last_run_ai_settings.yaml.
value: | value: |
```yaml ```yaml
# Paste your prompt here # Paste your prompt here
``` ```

View File

@@ -31,8 +31,8 @@ jobs:
pip install -r requirements.txt pip install -r requirements.txt
- name: Lint with flake8 - name: Lint with flake8
continue-on-error: true continue-on-error: false
run: flake8 scripts/ tests/ run: flake8 scripts/ tests/ --select E303,W293,W291,W292,E305
- name: Run unittest tests with coverage - name: Run unittest tests with coverage
run: | run: |

View File

@@ -341,4 +341,7 @@ This project uses [flake8](https://flake8.pycqa.org/en/latest/) for linting. To
``` ```
flake8 scripts/ tests/ flake8 scripts/ tests/
# Or, if you want to run flake8 with the same configuration as the CI:
flake8 scripts/ tests/ --select E303,W293,W291,W292,E305
``` ```

View File

@@ -45,8 +45,6 @@ def improve_code(suggestions: List[str], code: str) -> str:
result_string = call_ai_function(function_string, args, description_string) result_string = call_ai_function(function_string, args, description_string)
return result_string return result_string
def write_tests(code: str, focus: List[str]) -> str: def write_tests(code: str, focus: List[str]) -> str:
""" """
A function that takes in code and focus topics and returns a response from create chat completion api call. A function that takes in code and focus topics and returns a response from create chat completion api call.

View File

@@ -33,6 +33,7 @@ def get_response(url, headers=cfg.user_agent_header, timeout=10):
if not url.startswith('http://') and not url.startswith('https://'): if not url.startswith('http://') and not url.startswith('https://'):
raise ValueError('Invalid URL format') raise ValueError('Invalid URL format')
sanitized_url = sanitize_url(url) sanitized_url = sanitize_url(url)
response = requests.get(sanitized_url, headers=headers, timeout=timeout) response = requests.get(sanitized_url, headers=headers, timeout=timeout)

View File

@@ -61,7 +61,7 @@ class Config(metaclass=Singleton):
self.use_mac_os_tts = False self.use_mac_os_tts = False
self.use_mac_os_tts = os.getenv("USE_MAC_OS_TTS") self.use_mac_os_tts = os.getenv("USE_MAC_OS_TTS")
self.google_api_key = os.getenv("GOOGLE_API_KEY") self.google_api_key = os.getenv("GOOGLE_API_KEY")
self.custom_search_engine_id = os.getenv("CUSTOM_SEARCH_ENGINE_ID") self.custom_search_engine_id = os.getenv("CUSTOM_SEARCH_ENGINE_ID")

View File

@@ -80,4 +80,4 @@ def search_files(directory):
relative_path = os.path.relpath(os.path.join(root, file), working_directory) relative_path = os.path.relpath(os.path.join(root, file), working_directory)
found_files.append(relative_path) found_files.append(relative_path)
return found_files return found_files

View File

@@ -159,6 +159,7 @@ class ConsoleHandler(logging.StreamHandler):
except Exception: except Exception:
self.handleError(record) self.handleError(record)
''' '''
Allows to handle custom placeholders 'title_color' and 'message_no_color'. Allows to handle custom placeholders 'title_color' and 'message_no_color'.
To use this formatter, make sure to pass 'color', 'title' as log extras. To use this formatter, make sure to pass 'color', 'title' as log extras.

View File

@@ -44,6 +44,7 @@ def get_memory(cfg, init=False):
def get_supported_memory_backends(): def get_supported_memory_backends():
return supported_memory return supported_memory
__all__ = [ __all__ = [
"get_memory", "get_memory",
"LocalCache", "LocalCache",

View File

@@ -61,7 +61,7 @@ def gtts_speech(text):
def macos_tts_speech(text, voice_index=0): def macos_tts_speech(text, voice_index=0):
if voice_index == 0: if voice_index == 0:
os.system(f'say "{text}"') os.system(f'say "{text}"')
else: else:
if voice_index == 1: if voice_index == 1:
os.system(f'say -v "Ava (Premium)" "{text}"') os.system(f'say -v "Ava (Premium)" "{text}"')
else: else:
@@ -79,7 +79,7 @@ def say_text(text, voice_index=0):
success = eleven_labs_speech(text, voice_index) success = eleven_labs_speech(text, voice_index)
if not success: if not success:
gtts_speech(text) gtts_speech(text)
queue_semaphore.release() queue_semaphore.release()
queue_semaphore.acquire(True) queue_semaphore.acquire(True)

View File

@@ -45,5 +45,6 @@ class TestLocalCache(unittest.TestCase):
self.assertEqual(len(relevant_texts), k) self.assertEqual(len(relevant_texts), k)
self.assertIn(self.example_texts[1], relevant_texts) self.assertIn(self.example_texts[1], relevant_texts)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@@ -47,5 +47,6 @@ class TestLocalCache(unittest.TestCase):
stats = self.cache.get_stats() stats = self.cache.get_stats()
self.assertEqual(stats, (1, self.cache.data.embeddings.shape)) self.assertEqual(stats, (1, self.cache.data.embeddings.shape))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@@ -66,8 +66,6 @@ class TestParseJson(unittest.TestCase):
# Assert that this raises an exception: # Assert that this raises an exception:
self.assertEqual(fix_and_parse_json(json_str, try_to_fix_with_gpt=False), good_obj) self.assertEqual(fix_and_parse_json(json_str, try_to_fix_with_gpt=False), good_obj)
def test_invalid_json_leading_sentence_with_gpt(self): def test_invalid_json_leading_sentence_with_gpt(self):
# Test that a REALLY invalid JSON string raises an error when try_to_fix_with_gpt is False # Test that a REALLY invalid JSON string raises an error when try_to_fix_with_gpt is False
json_str = """I will first need to browse the repository (https://github.com/Torantulino/Auto-GPT) and identify any potential bugs that need fixing. I will use the "browse_website" command for this. json_str = """I will first need to browse the repository (https://github.com/Torantulino/Auto-GPT) and identify any potential bugs that need fixing. I will use the "browse_website" command for this.
@@ -108,6 +106,5 @@ class TestParseJson(unittest.TestCase):
self.assertEqual(fix_and_parse_json(json_str, try_to_fix_with_gpt=False), good_obj) self.assertEqual(fix_and_parse_json(json_str, try_to_fix_with_gpt=False), good_obj)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@@ -68,8 +68,6 @@ class TestParseJson(unittest.TestCase):
# Assert that this raises an exception: # Assert that this raises an exception:
self.assertEqual(fix_and_parse_json(json_str, try_to_fix_with_gpt=False), good_obj) self.assertEqual(fix_and_parse_json(json_str, try_to_fix_with_gpt=False), good_obj)
def test_invalid_json_leading_sentence_with_gpt(self): def test_invalid_json_leading_sentence_with_gpt(self):
# Test that a REALLY invalid JSON string raises an error when try_to_fix_with_gpt is False # Test that a REALLY invalid JSON string raises an error when try_to_fix_with_gpt is False
json_str = """I will first need to browse the repository (https://github.com/Torantulino/Auto-GPT) and identify any potential bugs that need fixing. I will use the "browse_website" command for this. json_str = """I will first need to browse the repository (https://github.com/Torantulino/Auto-GPT) and identify any potential bugs that need fixing. I will use the "browse_website" command for this.
@@ -110,6 +108,5 @@ class TestParseJson(unittest.TestCase):
self.assertEqual(fix_and_parse_json(json_str, try_to_fix_with_gpt=False), good_obj) self.assertEqual(fix_and_parse_json(json_str, try_to_fix_with_gpt=False), good_obj)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@@ -33,8 +33,6 @@ Additional aspects:
- The function uses a generator expression to split the text into lines and chunks, which can improve performance for large amounts of text. - The function uses a generator expression to split the text into lines and chunks, which can improve performance for large amounts of text.
""" """
class TestScrapeText: class TestScrapeText:
# Tests that scrape_text() returns the expected text when given a valid URL. # Tests that scrape_text() returns the expected text when given a valid URL.