Add repo doc for examples #86 (#88)

* Add repo doc for examples

* fox
This commit is contained in:
Eric Zhu 2024-06-17 17:54:27 -07:00 committed by GitHub
parent 51c8b678de
commit 6d7cbe0027
6 changed files with 46 additions and 1 deletions

View File

@ -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".

View File

@ -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())

View File

@ -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())

View File

@ -1,4 +1,6 @@
import argparse
import asyncio
import logging
from dataclasses import dataclass
from 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())

View File

@ -158,6 +158,7 @@ async def run(message: str, user: str, scenario: Callable[[AgentRuntime], Orches
if __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]))

View File

@ -50,7 +50,7 @@ line-length = 120
fix = true
exclude = ["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