From 4b32bd2bdd3dc02e9415a162b93052f0d0ee907b Mon Sep 17 00:00:00 2001 From: Chi Wang Date: Sun, 12 Nov 2023 16:01:20 +0000 Subject: [PATCH 1/7] bump version --- autogen/version.py | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/autogen/version.py b/autogen/version.py index 16bf2ffe042..ad7ff4d08ab 100644 --- a/autogen/version.py +++ b/autogen/version.py @@ -1 +1 @@ -__version__ = "0.2.0b4" +__version__ = "0.2.0b5" diff --git a/setup.py b/setup.py index 6c2d3a07435..4dc5d4e9dd6 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ __version__ = version["__version__"] install_requires = [ - "openai==1.1.1", + "openai~=1.2", "diskcache", "termcolor", "flaml", From 9ba768455bd04d8ef67e02f1669d606adf402680 Mon Sep 17 00:00:00 2001 From: Qingyun Wu Date: Sun, 12 Nov 2023 13:58:06 -0500 Subject: [PATCH 2/7] use AssertionError --- autogen/oai/completion.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/autogen/oai/completion.py b/autogen/oai/completion.py index 2fe95e8f60c..b8a5a6ef133 100644 --- a/autogen/oai/completion.py +++ b/autogen/oai/completion.py @@ -13,6 +13,8 @@ try: import openai + + assert openai.__version__ < "1" from openai import ( RateLimitError, APIError, @@ -25,11 +27,9 @@ import diskcache ERROR = None -except ImportError: - ERROR = ImportError( - "(Deprecated) The autogen.Completion class requires openai<1 and diskcache. " - "Please switch to autogen.OpenAIWrapper for openai>=1." - ) +except AssertionError: + # The autogen.Completion class requires openai<1 + ERROR = AssertionError("(Deprecated) The autogen.Completion class requires openai<1 and diskcache. ") openai_Completion = object logger = logging.getLogger(__name__) if not logger.handlers: From 729a123d2e6d1a9d7897748a37794c8775cc548d Mon Sep 17 00:00:00 2001 From: Qingyun Wu Date: Sun, 12 Nov 2023 14:07:07 -0500 Subject: [PATCH 3/7] revise error --- autogen/oai/completion.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/autogen/oai/completion.py b/autogen/oai/completion.py index b8a5a6ef133..f8faae48246 100644 --- a/autogen/oai/completion.py +++ b/autogen/oai/completion.py @@ -14,7 +14,6 @@ try: import openai - assert openai.__version__ < "1" from openai import ( RateLimitError, APIError, @@ -27,10 +26,12 @@ import diskcache ERROR = None -except AssertionError: + assert openai.__version__ < "1" +except AssertionError or ImportError: + openai_Completion = object # The autogen.Completion class requires openai<1 ERROR = AssertionError("(Deprecated) The autogen.Completion class requires openai<1 and diskcache. ") - openai_Completion = object + logger = logging.getLogger(__name__) if not logger.handlers: # Add the console handler. From eb9d6bc7981189d56a1c1c031bb0b0f255bcb6fa Mon Sep 17 00:00:00 2001 From: Qingyun Wu Date: Sun, 12 Nov 2023 14:28:24 -0500 Subject: [PATCH 4/7] oai import --- autogen/oai/completion.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/autogen/oai/completion.py b/autogen/oai/completion.py index f8faae48246..3626eec05b0 100644 --- a/autogen/oai/completion.py +++ b/autogen/oai/completion.py @@ -10,10 +10,9 @@ from flaml.automl.logger import logger_formatter from .openai_utils import get_key from collections import defaultdict +import openai try: - import openai - from openai import ( RateLimitError, APIError, From b77f40953de1b400db29298053e3e9a765e0c4ab Mon Sep 17 00:00:00 2001 From: Qingyun Wu Date: Sun, 12 Nov 2023 14:40:06 -0500 Subject: [PATCH 5/7] ImportError --- autogen/oai/completion.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/autogen/oai/completion.py b/autogen/oai/completion.py index 3626eec05b0..78a31525703 100644 --- a/autogen/oai/completion.py +++ b/autogen/oai/completion.py @@ -10,7 +10,11 @@ from flaml.automl.logger import logger_formatter from .openai_utils import get_key from collections import defaultdict -import openai + +try: + import openai +except ImportError: + ERROR = ImportError("openai is required.") try: from openai import ( From 486c2fee1f747c1118d423809a2ad22ddff54e52 Mon Sep 17 00:00:00 2001 From: Qingyun Wu Date: Sun, 12 Nov 2023 14:41:38 -0500 Subject: [PATCH 6/7] error --- autogen/oai/completion.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/autogen/oai/completion.py b/autogen/oai/completion.py index 78a31525703..1e8740c2f04 100644 --- a/autogen/oai/completion.py +++ b/autogen/oai/completion.py @@ -13,10 +13,6 @@ try: import openai -except ImportError: - ERROR = ImportError("openai is required.") - -try: from openai import ( RateLimitError, APIError, @@ -30,7 +26,7 @@ ERROR = None assert openai.__version__ < "1" -except AssertionError or ImportError: +except (AssertionError, ImportError): openai_Completion = object # The autogen.Completion class requires openai<1 ERROR = AssertionError("(Deprecated) The autogen.Completion class requires openai<1 and diskcache. ") From d996eb527dd09ac2d56321c89dd0619aef741023 Mon Sep 17 00:00:00 2001 From: Chi Wang Date: Sun, 12 Nov 2023 20:26:44 +0000 Subject: [PATCH 7/7] use openai endpoint --- test/agentchat/contrib/test_gpt_assistant.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/agentchat/contrib/test_gpt_assistant.py b/test/agentchat/contrib/test_gpt_assistant.py index fab3fbb77db..59bad7c560e 100644 --- a/test/agentchat/contrib/test_gpt_assistant.py +++ b/test/agentchat/contrib/test_gpt_assistant.py @@ -13,6 +13,10 @@ except ImportError: skip_test = True +config_list = autogen.config_list_from_json( + OAI_CONFIG_LIST, file_location=KEY_LOC, filter_dict={"api_type": ["openai"]} +) + def ask_ossinsight(question): return f"That is a good question, but I don't know the answer yet. Please ask your human developer friend to help you. \n\n{question}" @@ -38,7 +42,6 @@ def test_gpt_assistant_chat(): "description": "This is an API endpoint allowing users (analysts) to input question about GitHub in text format to retrieve the realted and structured data.", } - config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, file_location=KEY_LOC) analyst = GPTAssistantAgent( name="Open_Source_Project_Analyst", llm_config={"tools": [{"type": "function", "function": ossinsight_api_schema}], "config_list": config_list}, @@ -73,7 +76,6 @@ def test_get_assistant_instructions(): and assert that the retrieved instructions match the set instructions. """ - config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, file_location=KEY_LOC) assistant = GPTAssistantAgent( "assistant", instructions="This is a test", @@ -107,7 +109,6 @@ def test_gpt_assistant_instructions_overwrite(): instructions1 = "This is a test #1" instructions2 = "This is a test #2" - config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, file_location=KEY_LOC) assistant = GPTAssistantAgent( "assistant", instructions=instructions1, @@ -144,7 +145,6 @@ def test_gpt_assistant_existing_no_instructions(): """ instructions = "This is a test #1" - config_list = autogen.config_list_from_json(OAI_CONFIG_LIST, file_location=KEY_LOC) assistant = GPTAssistantAgent( "assistant", instructions=instructions,