From f4c000a547e5351048eae8e6f919d268ffafd7e4 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Mon, 19 Jun 2023 16:21:40 -0700 Subject: [PATCH] Fixes LLM thinking command descriptions are orders Signed-off-by: Merwane Hamadi --- autogpt/commands/execute_code.py | 8 ++++---- autogpt/commands/file_operations.py | 8 ++++---- autogpt/commands/git_operations.py | 2 +- autogpt/commands/image_gen.py | 2 +- autogpt/commands/web_search.py | 2 +- autogpt/commands/web_selenium.py | 2 +- autogpt/llm/api_manager.py | 2 ++ autogpt/llm/providers/openai.py | 1 + tests/unit/test_api_manager.py | 2 +- 9 files changed, 16 insertions(+), 13 deletions(-) diff --git a/autogpt/commands/execute_code.py b/autogpt/commands/execute_code.py index 0b0f731c9..2db78ccca 100644 --- a/autogpt/commands/execute_code.py +++ b/autogpt/commands/execute_code.py @@ -18,7 +18,7 @@ DENYLIST_CONTROL = "denylist" @command( "execute_python_code", - "Create a Python file and execute it", + "Creates a Python file and executes it", { "code": { "type": "string", @@ -63,7 +63,7 @@ def execute_python_code(code: str, name: str, agent: Agent) -> str: @command( "execute_python_file", - "Execute an existing Python file", + "Executes an existing Python file", { "filename": { "type": "string", @@ -191,7 +191,7 @@ def validate_command(command: str, config: Config) -> bool: @command( "execute_shell", - "Execute Shell Command, non-interactive commands only", + "Executes a Shell Command, non-interactive commands only", { "command_line": { "type": "string", @@ -237,7 +237,7 @@ def execute_shell(command_line: str, agent: Agent) -> str: @command( "execute_shell_popen", - "Execute Shell Command, non-interactive commands only", + "Executes a Shell Command, non-interactive commands only", { "query": { "type": "string", diff --git a/autogpt/commands/file_operations.py b/autogpt/commands/file_operations.py index d059493f0..ca2487439 100644 --- a/autogpt/commands/file_operations.py +++ b/autogpt/commands/file_operations.py @@ -176,7 +176,7 @@ def ingest_file( @command( "write_to_file", - "Write to file", + "Writes to a file", { "filename": { "type": "string", @@ -216,7 +216,7 @@ def write_to_file(filename: str, text: str, agent: Agent) -> str: @command( "append_to_file", - "Append to file", + "Appends to a file", { "filename": { "type": "string", @@ -261,7 +261,7 @@ def append_to_file( @command( "delete_file", - "Delete file", + "Deletes a file", { "filename": { "type": "string", @@ -291,7 +291,7 @@ def delete_file(filename: str, agent: Agent) -> str: @command( "list_files", - "List Files in Directory", + "Lists Files in a Directory", { "directory": { "type": "string", diff --git a/autogpt/commands/git_operations.py b/autogpt/commands/git_operations.py index 3832ca885..fc967e40e 100644 --- a/autogpt/commands/git_operations.py +++ b/autogpt/commands/git_operations.py @@ -9,7 +9,7 @@ from autogpt.url_utils.validators import validate_url @command( "clone_repository", - "Clone Repository", + "Clones a Repository", { "url": { "type": "string", diff --git a/autogpt/commands/image_gen.py b/autogpt/commands/image_gen.py index d6bb73d8a..c295392c6 100644 --- a/autogpt/commands/image_gen.py +++ b/autogpt/commands/image_gen.py @@ -16,7 +16,7 @@ from autogpt.logs import logger @command( "generate_image", - "Generate Image", + "Generates an Image", { "prompt": { "type": "string", diff --git a/autogpt/commands/web_search.py b/autogpt/commands/web_search.py index 50b06e480..5af810586 100644 --- a/autogpt/commands/web_search.py +++ b/autogpt/commands/web_search.py @@ -15,7 +15,7 @@ DUCKDUCKGO_MAX_ATTEMPTS = 3 @command( "web_search", - "Search the web", + "Searches the web", { "query": { "type": "string", diff --git a/autogpt/commands/web_selenium.py b/autogpt/commands/web_selenium.py index 471e203b7..821957f3e 100644 --- a/autogpt/commands/web_selenium.py +++ b/autogpt/commands/web_selenium.py @@ -41,7 +41,7 @@ FILE_DIR = Path(__file__).parent.parent @command( "browse_website", - "Browse Website", + "Browses a Website", { "url": {"type": "string", "description": "The URL to visit", "required": True}, "question": { diff --git a/autogpt/llm/api_manager.py b/autogpt/llm/api_manager.py index afab6e4ae..4e2aba9d2 100644 --- a/autogpt/llm/api_manager.py +++ b/autogpt/llm/api_manager.py @@ -4,6 +4,7 @@ from typing import List, Optional import openai from openai import Model + from autogpt.llm.base import CompletionModelInfo from autogpt.logs import logger from autogpt.singleton import Singleton @@ -35,6 +36,7 @@ class ApiManager(metaclass=Singleton): """ # the .model property in API responses can contain version suffixes like -v2 from autogpt.llm.providers.openai import OPEN_AI_MODELS + model = model[:-3] if model.endswith("-v2") else model model_info = OPEN_AI_MODELS[model] diff --git a/autogpt/llm/providers/openai.py b/autogpt/llm/providers/openai.py index 707a7db8a..add9954c6 100644 --- a/autogpt/llm/providers/openai.py +++ b/autogpt/llm/providers/openai.py @@ -111,6 +111,7 @@ OPEN_AI_MODELS: dict[str, ChatModelInfo | EmbeddingModelInfo | TextModelInfo] = def meter_api(func): """Adds ApiManager metering to functions which make OpenAI API calls""" from autogpt.llm.api_manager import ApiManager + api_manager = ApiManager() openai_obj_processor = openai.util.convert_to_openai_object diff --git a/tests/unit/test_api_manager.py b/tests/unit/test_api_manager.py index 04242d576..615204d19 100644 --- a/tests/unit/test_api_manager.py +++ b/tests/unit/test_api_manager.py @@ -1,4 +1,4 @@ -from unittest.mock import MagicMock, patch +from unittest.mock import patch import pytest from pytest_mock import MockerFixture