A programming framework for agentic AI
Add repo doc for examples #86 (#88)
Eric Zhu6d7cbe0027b1
diff --git a/examples/README.md b/examples/README.mdindex e69de29bb..f218fa356 100644--- a/examples/README.md+++ b/examples/README.md@@ -0,0 +1,25 @@+# Examples++This directory contains examples of how to use AGNext.++First, you need to install AGNext and development dependencies by running the+following command:++```bash+pip install -e '.[dev]'+```++To run an example, just run the corresponding Python script. For example, to run the `coder_reviewer.py` example, run:++```bash+python coder_reviewer.py+```++To enable logging, turn on verbose mode by setting `--verbose` flag:++```bash+python coder_reviewer.py --verbose+```++By default the log file is saved in the same directory with the same filename+as the script, e.g., "coder_reviewer.log".diff --git a/examples/assistant.py b/examples/assistant.pyindex d325b02a4..a3b1afebb 100644--- a/examples/assistant.py+++ b/examples/assistant.py@@ -238,4 +238,6 @@ if __name__ == "__main__":if args.verbose:logging.basicConfig(level=logging.WARNING)logging.getLogger("agnext").setLevel(logging.DEBUG)+ handler = logging.FileHandler("assistant.log")+ logging.getLogger("agnext").addHandler(handler)asyncio.run(main())diff --git a/examples/chess_game.py b/examples/chess_game.pyindex 3e4c61fee..230d46d0e 100644--- a/examples/chess_game.py+++ b/examples/chess_game.py@@ -210,5 +210,7 @@ if __name__ == "__main__":if args.verbose:logging.basicConfig(level=logging.WARNING)logging.getLogger("agnext").setLevel(logging.DEBUG)+ handler = logging.FileHandler("chess_game.log")+ logging.getLogger("agnext").addHandler(handler)asyncio.run(main())diff --git a/examples/futures.py b/examples/inner_outter.pysimilarity index 79%rename from examples/futures.pyrename to examples/inner_outter.pyindex 7e7cac1ed..5de492dee 100644--- a/examples/futures.py+++ b/examples/inner_outter.py@@ -1,4 +1,6 @@+import argparseimport asyncio+import loggingfrom dataclasses import dataclassfrom agnext.application import SingleThreadedAgentRuntime@@ -47,4 +49,12 @@ async def main() -> None:if __name__ == "__main__":+ parser = argparse.ArgumentParser(description="Inner-Outter agent example.")+ parser.add_argument("--verbose", action="store_true", help="Enable verbose logging.")+ args = parser.parse_args()+ if args.verbose:+ logging.basicConfig(level=logging.WARNING)+ logging.getLogger("agnext").setLevel(logging.DEBUG)+ handler = logging.FileHandler("inner_outter.log")+ logging.getLogger("agnext").addHandler(handler)asyncio.run(main())diff --git a/examples/orchestrator.py b/examples/orchestrator.pyindex 8eb8bf011..43111d0b1 100644--- a/examples/orchestrator.py+++ b/examples/orchestrator.py@@ -158,6 +158,7 @@ async def run(message: str, user: str, scenario: Callable[[AgentRuntime], Orchesif __name__ == "__main__":parser = argparse.ArgumentParser(description="Run a orchestrator demo.")choices = {"software_development": software_development}+ parser.add_argument("--verbose", action="store_true", help="Enable verbose logging.")parser.add_argument("--scenario",choices=list(choices.keys()),@@ -171,4 +172,9 @@ if __name__ == "__main__":)parser.add_argument("--message", help="The message to send.", required=True)args = parser.parse_args()+ if args.verbose:+ logging.basicConfig(level=logging.WARNING)+ logging.getLogger("agnext").setLevel(logging.DEBUG)+ handler = logging.FileHandler("inner_outter.log")+ logging.getLogger("agnext").addHandler(handler)asyncio.run(run(args.message, args.user, choices[args.scenario]))diff --git a/pyproject.toml b/pyproject.tomlindex 0e93dee87..8abfc9d30 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -50,7 +50,7 @@ line-length = 120fix = trueexclude = ["build", "dist", "my_project/__init__.py", "my_project/main.py"]target-version = "py310"-include = ["src/**", "examples/**"]+include = ["src/**", "examples/*.py"][tool.ruff.format]docstring-code-format = true