From 1ffa91bd500c4052372d7d717020cf60b0743b96 Mon Sep 17 00:00:00 2001 From: yitong <2969413251@qq.com> Date: Tue, 10 Oct 2023 14:11:29 +0800 Subject: [PATCH 1/3] fix: complete the command line for agentverse's demos to make it more convenient for users to use --- .github/workflows/test.yml | 3 ++- agentverse_command/__init__.py | 0 benchmark.py => agentverse_command/benchmark.py | 6 ++++-- .../main_simulation_cli.py | 8 ++++++-- .../main_simulation_gui.py | 8 ++++++-- .../main_tasksolving_cli.py | 8 ++++++-- setup.py | 8 ++++++++ 7 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 agentverse_command/__init__.py rename benchmark.py => agentverse_command/benchmark.py (98%) rename main_simulation_cli.py => agentverse_command/main_simulation_cli.py (78%) rename main_simulation_gui.py => agentverse_command/main_simulation_gui.py (72%) rename main_tasksolving_cli.py => agentverse_command/main_tasksolving_cli.py (74%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa9454dfb..bf14b09df 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,5 +36,6 @@ jobs: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} OPENAI_ORGANIZATION: ${{ secrets.OPENAI_ORGANIZATION }} run: | - python benchmark.py --task tasksolving/mgsm/gpt-3.5 --dataset_path data/mgsm/test_sample.jsonl --overwrite --output_path ci_smoke_test_output + python setup.py develop + python agentverse_command/benchmark.py --task tasksolving/mgsm/gpt-3.5 --dataset_path data/mgsm/test_sample.jsonl --overwrite --output_path ci_smoke_test_output --tasks_dir ./agentverse/tasks python evaluate_math.py --path ci_smoke_test_output/results.jsonl --ci_smoke_test \ No newline at end of file diff --git a/agentverse_command/__init__.py b/agentverse_command/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/benchmark.py b/agentverse_command/benchmark.py similarity index 98% rename from benchmark.py rename to agentverse_command/benchmark.py index 01d2cb232..1748893f8 100644 --- a/benchmark.py +++ b/agentverse_command/benchmark.py @@ -31,8 +31,7 @@ def get_dataloader(task, dataset_path): return dataloader_registry.build(task, path=dataset_path) - -if __name__ == "__main__": +def cli_main(): dataloader = get_dataloader(args.task, args.dataset_path) if args.output_path is None: os.makedirs(f"./results/{args.task}", exist_ok=True) @@ -78,3 +77,6 @@ def get_dataloader(task, dataset_path): ) f.flush() f.close() + +if __name__ == "__main__": + cli_main() \ No newline at end of file diff --git a/main_simulation_cli.py b/agentverse_command/main_simulation_cli.py similarity index 78% rename from main_simulation_cli.py rename to agentverse_command/main_simulation_cli.py index 48f56e567..c22662511 100644 --- a/main_simulation_cli.py +++ b/agentverse_command/main_simulation_cli.py @@ -14,5 +14,9 @@ logger.set_level(logging.DEBUG if args.debug else logging.INFO) -agentverse = Simulation.from_task(args.task, args.tasks_dir) -agentverse.run() +def cli_main(): + agentverse = Simulation.from_task(args.task, args.tasks_dir) + agentverse.run() + +if __name__ == "__main__": + cli_main() \ No newline at end of file diff --git a/main_simulation_gui.py b/agentverse_command/main_simulation_gui.py similarity index 72% rename from main_simulation_gui.py rename to agentverse_command/main_simulation_gui.py index 576b980c5..a52bc3bd1 100644 --- a/main_simulation_gui.py +++ b/agentverse_command/main_simulation_gui.py @@ -8,5 +8,9 @@ os.path.dirname(__file__), "agentverse", "tasks")) args = parser.parse_args() -ui = GUI(args.task, args.tasks_dir) -ui.launch() +def cli_main(): + ui = GUI(args.task, args.tasks_dir) + ui.launch() + +if __name__ == "__main__": + cli_main() diff --git a/main_tasksolving_cli.py b/agentverse_command/main_tasksolving_cli.py similarity index 74% rename from main_tasksolving_cli.py rename to agentverse_command/main_tasksolving_cli.py index aea6d1433..ed06d6023 100644 --- a/main_tasksolving_cli.py +++ b/agentverse_command/main_tasksolving_cli.py @@ -18,5 +18,9 @@ logger.set_level(logging.DEBUG if args.debug else logging.INFO) -agentversepipeline = TaskSolving.from_task(args.task) -agentversepipeline.run() +def cli_main(): + agentversepipeline = TaskSolving.from_task(args.task) + agentversepipeline.run() + +if __name__ == "__main__": + cli_main() \ No newline at end of file diff --git a/setup.py b/setup.py index f4e8f2128..303e84e81 100644 --- a/setup.py +++ b/setup.py @@ -38,4 +38,12 @@ "langchain", ], include_package_data = True, + entry_points={ + "console_scripts": [ + "agentverse-benchmark = agentverse_command.benchmark:cli_main", + "agentverse-main_simulation_cli = agentverse_command.main_simulation_cli:cli_main", + "agentverse-main_simulation_gui = agentverse_command.main_simulation_gui:cli_main", + "agentverse-main_tasksolving_cli = agentverse_command.main_tasksolving_cli:cli_main", + ], + }, ) From eee16bc141681a8c9c1f1b9ce7f51f81d0820685 Mon Sep 17 00:00:00 2001 From: Weize Chen <32613237+chenweize1998@users.noreply.github.com> Date: Tue, 10 Oct 2023 14:48:13 +0800 Subject: [PATCH 2/3] fix: better cli command name --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 303e84e81..878fa015b 100644 --- a/setup.py +++ b/setup.py @@ -41,9 +41,9 @@ entry_points={ "console_scripts": [ "agentverse-benchmark = agentverse_command.benchmark:cli_main", - "agentverse-main_simulation_cli = agentverse_command.main_simulation_cli:cli_main", - "agentverse-main_simulation_gui = agentverse_command.main_simulation_gui:cli_main", - "agentverse-main_tasksolving_cli = agentverse_command.main_tasksolving_cli:cli_main", + "agentverse-simulation = agentverse_command.main_simulation_cli:cli_main", + "agentverse-simulation-gui = agentverse_command.main_simulation_gui:cli_main", + "agentverse-tasksolving = agentverse_command.main_tasksolving_cli:cli_main", ], }, ) From c460218d43ce06b763419293c07ce5b504a1b96c Mon Sep 17 00:00:00 2001 From: chenweize1998 Date: Tue, 10 Oct 2023 16:08:01 +0800 Subject: [PATCH 3/3] fix: change default tasks_dir --- agentverse_command/benchmark.py | 11 +++++--- agentverse_command/main_simulation_cli.py | 11 +++++--- agentverse_command/main_simulation_gui.py | 9 +++++-- agentverse_command/main_tasksolving_cli.py | 14 +++++++--- setup.py | 31 +++++++++++----------- 5 files changed, 50 insertions(+), 26 deletions(-) diff --git a/agentverse_command/benchmark.py b/agentverse_command/benchmark.py index 1748893f8..e9da7cf0a 100644 --- a/agentverse_command/benchmark.py +++ b/agentverse_command/benchmark.py @@ -13,8 +13,11 @@ parser = ArgumentParser() parser.add_argument("--task", type=str, default="tasksolving/responsegen") -parser.add_argument("--tasks_dir", type=str, default=os.path.join( - os.path.dirname(__file__), "agentverse", "tasks")) +parser.add_argument( + "--tasks_dir", + type=str, + default=os.path.join(os.path.dirname(__file__), "..", "agentverse", "tasks"), +) parser.add_argument("--dataset_path", type=str, required=True) parser.add_argument("--output_path", type=str, default=None) parser.add_argument("--has_tools", action="store_true") @@ -31,6 +34,7 @@ def get_dataloader(task, dataset_path): return dataloader_registry.build(task, path=dataset_path) + def cli_main(): dataloader = get_dataloader(args.task, args.dataset_path) if args.output_path is None: @@ -78,5 +82,6 @@ def cli_main(): f.flush() f.close() + if __name__ == "__main__": - cli_main() \ No newline at end of file + cli_main() diff --git a/agentverse_command/main_simulation_cli.py b/agentverse_command/main_simulation_cli.py index c22662511..af938e112 100644 --- a/agentverse_command/main_simulation_cli.py +++ b/agentverse_command/main_simulation_cli.py @@ -7,16 +7,21 @@ parser = ArgumentParser() parser.add_argument("--task", type=str, default="simulation/prisoner_dilemma") -parser.add_argument("--tasks_dir", type=str, default=os.path.join( - os.path.dirname(__file__), "agentverse", "tasks")) +parser.add_argument( + "--tasks_dir", + type=str, + default=os.path.join(os.path.dirname(__file__), "..", "agentverse", "tasks"), +) parser.add_argument("--debug", action="store_true") args = parser.parse_args() logger.set_level(logging.DEBUG if args.debug else logging.INFO) + def cli_main(): agentverse = Simulation.from_task(args.task, args.tasks_dir) agentverse.run() + if __name__ == "__main__": - cli_main() \ No newline at end of file + cli_main() diff --git a/agentverse_command/main_simulation_gui.py b/agentverse_command/main_simulation_gui.py index a52bc3bd1..b91df38c0 100644 --- a/agentverse_command/main_simulation_gui.py +++ b/agentverse_command/main_simulation_gui.py @@ -4,13 +4,18 @@ parser = ArgumentParser() parser.add_argument("--task", type=str, default="simulation/nlp_classroom_9players") -parser.add_argument("--tasks_dir", type=str, default=os.path.join( - os.path.dirname(__file__), "agentverse", "tasks")) +parser.add_argument( + "--tasks_dir", + type=str, + default=os.path.join(os.path.dirname(__file__), "..", "agentverse", "tasks"), +) args = parser.parse_args() + def cli_main(): ui = GUI(args.task, args.tasks_dir) ui.launch() + if __name__ == "__main__": cli_main() diff --git a/agentverse_command/main_tasksolving_cli.py b/agentverse_command/main_tasksolving_cli.py index ed06d6023..2382adf90 100644 --- a/agentverse_command/main_tasksolving_cli.py +++ b/agentverse_command/main_tasksolving_cli.py @@ -1,3 +1,4 @@ +import os import logging # from agentverse.agentverse import AgentVerse @@ -11,16 +12,23 @@ parser.add_argument( "--task", type=str, - default="tasksolving/pipeline_brainstorming", + default="tasksolving/brainstorming", ) parser.add_argument("--debug", action="store_true") +parser.add_argument( + "--tasks_dir", + type=str, + default=os.path.join(os.path.dirname(__file__), "..", "agentverse", "tasks"), +) args = parser.parse_args() logger.set_level(logging.DEBUG if args.debug else logging.INFO) + def cli_main(): - agentversepipeline = TaskSolving.from_task(args.task) + agentversepipeline = TaskSolving.from_task(args.task, args.tasks_dir) agentversepipeline.run() + if __name__ == "__main__": - cli_main() \ No newline at end of file + cli_main() diff --git a/setup.py b/setup.py index 878fa015b..4d6f5f474 100644 --- a/setup.py +++ b/setup.py @@ -2,8 +2,8 @@ from setuptools.command.develop import develop import subprocess -# with open("requirements.txt", "r") as f: -# requirements = f.read().splitlines() +with open("requirements.txt", "r") as f: + requirements = f.read().splitlines() with open("README.md", "r", encoding='utf8') as fh: long_description = fh.read() @@ -24,19 +24,20 @@ "Operating System :: OS Independent", ], python_requires=">=3.9", - install_requires=[ - "PyYAML", - "fastapi", - "uvicorn", - "py3langid", - "iso-639", - "openai", - "opencv-python", - "gradio", - "httpx[socks]", - "astunparse", - "langchain", - ], + # install_requires=[ + # "PyYAML", + # "fastapi", + # "uvicorn", + # "py3langid", + # "iso-639", + # "openai", + # "opencv-python", + # "gradio", + # "httpx[socks]", + # "astunparse", + # "langchain", + # ], + install_requires=requirements, include_package_data = True, entry_points={ "console_scripts": [