From 67be242a84e993b00fb8f041ccbbf048c79ccb54 Mon Sep 17 00:00:00 2001 From: Chi Wang Date: Tue, 16 Jan 2024 02:53:03 +0000 Subject: [PATCH 1/3] add workdir in test --- test/agentchat/test_assistant_agent.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/agentchat/test_assistant_agent.py b/test/agentchat/test_assistant_agent.py index 0bd227851045..3cb112bd6ea3 100644 --- a/test/agentchat/test_assistant_agent.py +++ b/test/agentchat/test_assistant_agent.py @@ -142,6 +142,13 @@ def test_create_execute_script(human_input_mode="NEVER", max_consecutive_auto_re message="""Create and execute a script to plot a rocket without using matplotlib""", ) assistant.reset() + user = UserProxyAgent( + "user", + human_input_mode=human_input_mode, + code_execution_config={"work_dir": f"{here}/test_agent_scripts"}, + max_consecutive_auto_reply=max_consecutive_auto_reply, + is_termination_msg=lambda x: x.get("content", "").rstrip().endswith("TERMINATE"), + ) user.initiate_chat( assistant, message="""Create a temp.py file with the following content: @@ -197,8 +204,8 @@ def generate_init_message(self, question) -> str: if __name__ == "__main__": # test_gpt35() - # test_create_execute_script(human_input_mode="TERMINATE") + 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. - test_tsp(human_input_mode="NEVER", max_consecutive_auto_reply=10) + # test_tsp(human_input_mode="NEVER", max_consecutive_auto_reply=10) From dd490b73c7ed80adf5cd2db19f6fab8582f3025b Mon Sep 17 00:00:00 2001 From: Chi Wang Date: Tue, 16 Jan 2024 03:09:26 +0000 Subject: [PATCH 2/3] catch filenotfound --- notebook/agentchat_auto_feedback_from_code_execution.ipynb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/notebook/agentchat_auto_feedback_from_code_execution.ipynb b/notebook/agentchat_auto_feedback_from_code_execution.ipynb index 25207e54d07f..ac29ee4bfb16 100644 --- a/notebook/agentchat_auto_feedback_from_code_execution.ipynb +++ b/notebook/agentchat_auto_feedback_from_code_execution.ipynb @@ -514,7 +514,10 @@ } ], "source": [ - "Image(filename=\"coding/stock_price_ytd.png\")" + "try:\n", + " Image(filename=\"coding/stock_price_ytd.png\")\n", + "except FileNotFoundError:\n", + " print(\"Image not found. Please run the code in the next cell.\")" ] }, { From 8ab302ee1badf1a553b01a7a6a011226d4cb8acd Mon Sep 17 00:00:00 2001 From: Chi Wang Date: Tue, 16 Jan 2024 03:10:42 +0000 Subject: [PATCH 3/3] modify print msg --- notebook/agentchat_auto_feedback_from_code_execution.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebook/agentchat_auto_feedback_from_code_execution.ipynb b/notebook/agentchat_auto_feedback_from_code_execution.ipynb index ac29ee4bfb16..9c85fad57670 100644 --- a/notebook/agentchat_auto_feedback_from_code_execution.ipynb +++ b/notebook/agentchat_auto_feedback_from_code_execution.ipynb @@ -517,7 +517,7 @@ "try:\n", " Image(filename=\"coding/stock_price_ytd.png\")\n", "except FileNotFoundError:\n", - " print(\"Image not found. Please run the code in the next cell.\")" + " print(\"Image not found. Please check the file name and modify if necessary.\")" ] }, {