From 5c58be65f4e1456df64806db53488c8a3f8119cb Mon Sep 17 00:00:00 2001 From: Chi Wang Date: Mon, 12 Feb 2024 10:26:15 -0800 Subject: [PATCH 1/3] remove print config list (#1637) --- autogen/version.py | 2 +- test/oai/test_client_stream.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/autogen/version.py b/autogen/version.py index 11ef0928681..f3291e93b7d 100644 --- a/autogen/version.py +++ b/autogen/version.py @@ -1 +1 @@ -__version__ = "0.2.13" +__version__ = "0.2.14" diff --git a/test/oai/test_client_stream.py b/test/oai/test_client_stream.py index 63ee782f68e..a3bfc6161a6 100644 --- a/test/oai/test_client_stream.py +++ b/test/oai/test_client_stream.py @@ -254,7 +254,6 @@ def test_chat_tools_stream() -> None: }, }, ] - print(f"{config_list=}") client = OpenAIWrapper(config_list=config_list) response = client.create( # the intention is to trigger two tool invocations as a response to a single message @@ -294,7 +293,8 @@ def test_completion_stream() -> None: if __name__ == "__main__": - test_aoai_chat_completion_stream() - test_chat_completion_stream() - test_chat_functions_stream() - test_completion_stream() + # test_aoai_chat_completion_stream() + # test_chat_completion_stream() + # test_chat_functions_stream() + # test_completion_stream() + test_chat_tools_stream() From 6d93765b964ff0f0023eeff26db73fa1c8d9557e Mon Sep 17 00:00:00 2001 From: Chi Wang Date: Mon, 12 Feb 2024 11:58:30 -0800 Subject: [PATCH 2/3] return None instead of tuple in _generate_oai_reply_from_client (#1644) * return None instead of tuple * return final=False if extracted response is None --- autogen/agentchat/conversable_agent.py | 8 ++++---- test/agentchat/test_assistant_agent.py | 17 +++------------- test/agentchat/test_cache_agent.py | 28 ++++---------------------- test/oai/test_client_stream.py | 2 +- 4 files changed, 12 insertions(+), 43 deletions(-) diff --git a/autogen/agentchat/conversable_agent.py b/autogen/agentchat/conversable_agent.py index 895eb7b5122..1f1b2ff489f 100644 --- a/autogen/agentchat/conversable_agent.py +++ b/autogen/agentchat/conversable_agent.py @@ -1108,9 +1108,9 @@ def generate_oai_reply( extracted_response = self._generate_oai_reply_from_client( client, self._oai_system_message + messages, self.client_cache ) - return True, extracted_response + return (False, None) if extracted_response is None else (True, extracted_response) - def _generate_oai_reply_from_client(self, llm_client, messages, cache): + def _generate_oai_reply_from_client(self, llm_client, messages, cache) -> Union[str, Dict, None]: # unroll tool_responses all_messages = [] for message in messages: @@ -1132,8 +1132,8 @@ def _generate_oai_reply_from_client(self, llm_client, messages, cache): extracted_response = llm_client.extract_text_or_completion_object(response)[0] if extracted_response is None: - warnings.warn("Extracted_response is None.", UserWarning) - return False, None + warnings.warn("Extracted_response from {response} is None.", UserWarning) + return None # ensure function and tool calls will be accepted when sent back to the LLM if not isinstance(extracted_response, str) and hasattr(extracted_response, "model_dump"): extracted_response = model_dump(extracted_response) diff --git a/test/agentchat/test_assistant_agent.py b/test/agentchat/test_assistant_agent.py index 63cfff5e22a..af953d47c8a 100644 --- a/test/agentchat/test_assistant_agent.py +++ b/test/agentchat/test_assistant_agent.py @@ -68,18 +68,7 @@ def test_gpt35(human_input_mode="NEVER", max_consecutive_auto_reply=5): config_list = autogen.config_list_from_json( OAI_CONFIG_LIST, file_location=KEY_LOC, - filter_dict={ - "model": { - "gpt-3.5-turbo", - "gpt-35-turbo", - "gpt-3.5-turbo-16k", - "gpt-3.5-turbo-16k-0613", - "gpt-3.5-turbo-0301", - "chatgpt-35-turbo-0301", - "gpt-35-turbo-v0301", - "gpt", - }, - }, + filter_dict={"tags": ["gpt-3.5-turbo", "gpt-3.5-turbo-16k"]}, ) llm_config = { "cache_seed": 42, @@ -206,8 +195,8 @@ def generate_init_message(self, question) -> str: if __name__ == "__main__": - # test_gpt35() - test_create_execute_script(human_input_mode="TERMINATE") + test_gpt35() + # test_create_execute_script(human_input_mode="TERMINATE") # when GPT-4, i.e., the DEFAULT_MODEL, is used, conversation in the following test # should terminate in 2-3 rounds of interactions (because is_termination_msg should be true after 2-3 rounds) # although the max_consecutive_auto_reply is set to 10. diff --git a/test/agentchat/test_cache_agent.py b/test/agentchat/test_cache_agent.py index 8da9a919f84..52d5a11e102 100644 --- a/test/agentchat/test_cache_agent.py +++ b/test/agentchat/test_cache_agent.py @@ -6,6 +6,7 @@ import autogen from autogen.agentchat import AssistantAgent, UserProxyAgent from autogen.cache import Cache +from test_assistant_agent import KEY_LOC, OAI_CONFIG_LIST, here sys.path.append(os.path.join(os.path.dirname(__file__), "..")) from conftest import skip_openai, skip_redis # noqa: E402 @@ -107,23 +108,11 @@ def test_disk_cache(): def run_conversation(cache_seed, human_input_mode="NEVER", max_consecutive_auto_reply=5, cache=None): - KEY_LOC = "notebook" - OAI_CONFIG_LIST = "OAI_CONFIG_LIST" - here = os.path.abspath(os.path.dirname(__file__)) config_list = autogen.config_list_from_json( OAI_CONFIG_LIST, file_location=KEY_LOC, filter_dict={ - "model": { - "gpt-3.5-turbo", - "gpt-35-turbo", - "gpt-3.5-turbo-16k", - "gpt-3.5-turbo-16k-0613", - "gpt-3.5-turbo-0301", - "chatgpt-35-turbo-0301", - "gpt-35-turbo-v0301", - "gpt", - }, + "tags": ["gpt-3.5-turbo", "gpt-3.5-turbo-16k"], }, ) llm_config = { @@ -159,7 +148,7 @@ def run_conversation(cache_seed, human_input_mode="NEVER", max_consecutive_auto_ # track how long this takes user.initiate_chat(assistant, message=coding_task, cache=cache) - return user.chat_messages[list(user.chat_messages.keys())[-0]] + return user.chat_messages[assistant] def run_groupchat_conversation(cache, human_input_mode="NEVER", max_consecutive_auto_reply=5): @@ -170,16 +159,7 @@ def run_groupchat_conversation(cache, human_input_mode="NEVER", max_consecutive_ OAI_CONFIG_LIST, file_location=KEY_LOC, filter_dict={ - "model": { - "gpt-3.5-turbo", - "gpt-35-turbo", - "gpt-3.5-turbo-16k", - "gpt-3.5-turbo-16k-0613", - "gpt-3.5-turbo-0301", - "chatgpt-35-turbo-0301", - "gpt-35-turbo-v0301", - "gpt", - }, + "tags": ["gpt-3.5-turbo", "gpt-3.5-turbo-16k"], }, ) llm_config = { diff --git a/test/oai/test_client_stream.py b/test/oai/test_client_stream.py index a3bfc6161a6..af03824495c 100644 --- a/test/oai/test_client_stream.py +++ b/test/oai/test_client_stream.py @@ -233,7 +233,7 @@ def test_chat_tools_stream() -> None: config_list = config_list_from_json( env_or_file=OAI_CONFIG_LIST, file_location=KEY_LOC, - filter_dict={"model": ["gpt-3.5-turbo", "gpt-35-turbo"]}, + filter_dict={"tags": ["multitool"]}, ) tools = [ { From d01063d23122ae2a4bbaa3014519d6ae75e95de1 Mon Sep 17 00:00:00 2001 From: Bob Gregor Date: Mon, 12 Feb 2024 15:10:00 -0500 Subject: [PATCH 3/3] remove duplicates (#1646) --- samples/apps/autogen-studio/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/samples/apps/autogen-studio/README.md b/samples/apps/autogen-studio/README.md index 48b8883bc1f..72dc2b9a427 100644 --- a/samples/apps/autogen-studio/README.md +++ b/samples/apps/autogen-studio/README.md @@ -34,8 +34,6 @@ Project Structure: There are two ways to install AutoGen Studio - from PyPi or from source. We **recommend installing from PyPi** unless you plan to modify the source code. -There are two ways to install AutoGen Studio - from PyPi or from source. We **recommend installing from PyPi** unless you plan to modify the source code. - 1. **Install from PyPi** We recommend using a virtual environment (e.g., conda) to avoid conflicts with existing Python packages. With Python 3.10 or newer active in your virtual environment, use pip to install AutoGen Studio: