Skip to content

Commit

Permalink
Add repo doc for examples autogenhub#86 (autogenhub#88)
Browse files Browse the repository at this point in the history
* Add repo doc for examples

* fox
  • Loading branch information
ekzhu authored Jun 18, 2024
1 parent 51c8b67 commit 6d7cbe0
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 1 deletion.
25 changes: 25 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -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".
2 changes: 2 additions & 0 deletions examples/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,6 @@ async def main() -> None:
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())
2 changes: 2 additions & 0 deletions examples/chess_game.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,5 +210,7 @@ async def main() -> None:
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())
10 changes: 10 additions & 0 deletions examples/futures.py → examples/inner_outter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import argparse
import asyncio
import logging
from dataclasses import dataclass

from agnext.application import SingleThreadedAgentRuntime
Expand Down Expand Up @@ -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())
6 changes: 6 additions & 0 deletions examples/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand All @@ -171,4 +172,9 @@ async def run(message: str, user: str, scenario: Callable[[AgentRuntime], Orches
)
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]))
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6d7cbe0

Please sign in to comment.