Skip to content

A programming framework for agentic AI

create basic package structure, checks, readme

Jack Gerritsf5f0a5185513
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
new file mode 100644
index 000000000..d64ee6f55
--- /dev/null
+++ b/.github/workflows/checks.yml
@@ -0,0 +1,62 @@
+name: Checks
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+ branches:
+ - main
+
+jobs:
+ lint:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-python@v5
+ with:
+ python-version: '3.10'
+ - run: pip install ".[dev]"
+ - run: ruff --check
+
+ format:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-python@v5
+ with:
+ python-version: '3.10'
+ - run: pip install ".[dev]"
+ - run: ruff format --check
+
+ mypy:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-python@v5
+ with:
+ python-version: '3.10'
+ - run: pip install ".[dev]"
+ - run: mypy
+
+ pyright:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-python@v5
+ with:
+ python-version: '3.10'
+ - run: pip install ".[dev]"
+ - uses: jakebailey/pyright-action@v2
+
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-python@v5
+ with:
+ python-version: '3.10'
+ - run: pip install ".[dev]"
+ - run: pytest
diff --git a/.gitignore b/.gitignore
index 68bc17f9f..ec3e5ffaf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -158,3 +158,5 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
+
+.ruff_cache/
\ No newline at end of file
diff --git a/README.md b/README.md
index 5cd7cecfc..0713bf167 100644
--- a/README.md
+++ b/README.md
@@ -1,33 +1,40 @@
-# Project
+# AutoGenNext
-> This repo has been populated by an initial template to help get you started. Please
-> make sure to update the content to build a great experience for community-building.
+## Development
-As the maintainer of this project, please make a few updates:
+### Setup
-- Improving this README.MD file to provide a great experience
-- Updating SUPPORT.MD with content about this project's support experience
-- Understanding the security reporting process in SECURITY.MD
-- Remove this section from the README
+```sh
+python -m venv .venv
+source .venv/bin/activate
-## Contributing
+pip install -e ".[dev]"
+```
-This project welcomes contributions and suggestions. Most contributions require you to agree to a
-Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
-the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
+### Running tests
-When you submit a pull request, a CLA bot will automatically determine whether you need to provide
-a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
-provided by the bot. You will only need to do this once across all repos using our CLA.
+```sh
+pytest
+```
-This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
-For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
-contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
+### Type checking
-## Trademarks
+```sh
+mypy
+```
-This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
-trademarks or logos is subject to and must follow
-[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
-Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
-Any use of third-party trademarks or logos are subject to those third-party's policies.
+```sh
+pyright
+```
+
+### Linting
+
+```sh
+ruff check
+```
+
+### Formatting
+
+```sh
+ruff format
+```
diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 000000000..7f55f9de4
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,60 @@
+[build-system]
+requires = ["setuptools>=61.0"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "agnext"
+version = "0.0.1"
+description = "A small example package"
+readme = "README.md"
+requires-python = ">=3.10"
+classifiers = [
+ "Programming Language :: Python :: 3",
+ "License :: OSI Approved :: MIT License",
+ "Operating System :: OS Independent",
+]
+
+[project.optional-dependencies]
+dev = ["ruff", "pyright", "mypy", "pytest"]
+
+[tool.setuptools.package-data]
+agnext = ["py.typed"]
+
+[tool.ruff]
+line-length = 120
+fix = true
+exclude = ["build", "dist", "my_project/__init__.py", "my_project/main.py"]
+target-version = "py310"
+
+[tool.ruff.lint]
+select = ["E", "F", "W", "B", "Q", "I"]
+ignore = ["F401", "E501"]
+
+[tool.mypy]
+files = [
+ "src"
+]
+
+strict = true
+python_version = "3.10"
+ignore_missing_imports = true
+
+# from https://blog.wolt.com/engineering/2021/09/30/professional-grade-mypy-configuration/
+disallow_untyped_defs = true
+no_implicit_optional = true
+check_untyped_defs = true
+warn_return_any = true
+show_error_codes = true
+warn_unused_ignores = false
+
+disallow_incomplete_defs = true
+disallow_untyped_decorators = true
+disallow_any_unimported = true
+
+[tool.pyright]
+include = [
+ "src"
+]
+typeCheckingMode = "strict"
+reportUnnecessaryIsInstance = false
+reportMissingTypeStubs = false
diff --git a/src/agnext/__init__.py b/src/agnext/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/prototype.py b/src/agnext/prototype.py
similarity index 97%
rename from prototype.py
rename to src/agnext/prototype.py
index f1773bd4a..548033de0 100644
--- a/prototype.py
+++ b/src/agnext/prototype.py
@@ -1,13 +1,8 @@
-from dataclasses import dataclass
-from typing import Any, Awaitable, Callable, Dict, List, Optional, Protocol, Sequence, Type, cast
-
import asyncio
-
-from abc import ABC, abstractmethod
-
import random
-
-
+from abc import ABC, abstractmethod
+from dataclasses import dataclass
+from typing import Any, Awaitable, Callable, Dict, List, Optional, Protocol, Sequence, Type, cast
# Type based routing for event
@@ -28,6 +23,8 @@ import random
class Event(Protocol):
sender: str
+ # reply_to: Optional[str]
+
# T must encompass all subscribed types for a given agent
@@ -45,6 +42,13 @@ class EventBasedAgent[T: Event](Agent):
async def on_event(self, event: T) -> None:
...
+ # async def _send_event(self, event: T) -> None:
+ # ...
+
+ # async def _broadcast_message(self, event: T) -> None:
+ # ...
+
+
# NOTE: this works on concrete types and not inheritance
def event_handler[T: Event](target_type: Type[T]):
def decorator(func: Callable[..., Awaitable[None]]) -> Callable[..., Awaitable[None]]: