2024-08-28 13:35:21 -04:00
# AutoGen Python packages
2024-06-20 15:19:56 -04:00
2024-11-26 11:04:59 -05:00
[](https://microsoft.github.io/autogen/dev/)
2025-01-09 15:29:54 -05:00
[](https://pypi.org/project/autogen-core/) [](https://pypi.org/project/autogen-agentchat/) [](https://pypi.org/project/autogen-ext/)
2024-08-29 09:46:06 -04:00
2024-11-26 11:04:59 -05:00
This directory works as a single `uv` workspace containing all project packages. See [`packages` ](./packages/ ) to discover all project packages.
2024-12-30 13:33:08 -08:00
## Migrating from 0.2.x?
Please refer to the [migration guide ](./migration_guide.md ) for how to migrate your code from 0.2.x to 0.4.x.
2024-08-29 09:46:06 -04:00
## Development
**TL;DR**, run all checks with:
```sh
2024-11-11 12:23:25 -08:00
uv sync --all-extras
2024-08-29 09:46:06 -04:00
source .venv/bin/activate
2024-08-29 17:58:00 -04:00
poe check
2024-08-29 09:46:06 -04:00
```
### Setup
2024-11-27 14:39:31 -08:00
2024-11-11 12:23:25 -08:00
`uv` is a package manager that assists in creating the necessary environment and installing packages to run AutoGen.
2024-11-27 14:39:31 -08:00
2024-08-29 09:46:06 -04:00
- [Install `uv` ](https://docs.astral.sh/uv/getting-started/installation/ ).
2025-02-25 14:47:20 -05:00
**Note:** To prevent incompatibilities between versions the same UV version as is running in CI should be used. Check the version in CI by looking the `setup-uv` action, [here ](https://github.com/microsoft/autogen/blob/main/.github/workflows/checks.yml#L40 ) for example.
For example, to change your version to `0.5.18` , run:
```sh
uv self update 0.5.18
```
2024-11-11 12:23:25 -08:00
### Virtual Environment
2024-11-27 14:39:31 -08:00
2024-11-11 12:23:25 -08:00
During development, you may need to test changes made to any of the packages.\
To do so, create a virtual environment where the AutoGen packages are installed based on the current state of the directory.\
Run the following commands at the root level of the Python directory:
2024-08-29 09:46:06 -04:00
```sh
2024-11-11 12:23:25 -08:00
uv sync --all-extras
2024-08-29 09:46:06 -04:00
source .venv/bin/activate
```
2024-11-27 14:39:31 -08:00
2024-11-11 12:23:25 -08:00
- `uv sync --all-extras` will create a `.venv` directory at the current level and install packages from the current directory along with any other dependencies. The `all-extras` flag adds optional dependencies.
- `source .venv/bin/activate` activates the virtual environment.
2024-08-29 09:46:06 -04:00
2024-11-11 12:23:25 -08:00
### Common Tasks
2024-11-27 14:39:31 -08:00
2024-11-11 12:23:25 -08:00
To create a pull request (PR), ensure the following checks are met. You can run each check individually:
2024-11-27 14:39:31 -08:00
2024-08-29 09:46:06 -04:00
- Format: `poe format`
- Lint: `poe lint`
- Test: `poe test`
- Mypy: `poe mypy`
- Pyright: `poe pyright`
- Build docs: `poe --directory ./packages/autogen-core/ docs-build`
- Auto rebuild+serve docs: `poe --directory ./packages/autogen-core/ docs-serve`
2025-02-04 11:35:51 -08:00
- Check samples in `python/samples` : `poe samples-code-check`
2024-11-11 12:23:25 -08:00
Alternatively, you can run all the checks with:
- `poe check`
2024-08-29 09:46:06 -04:00
> [!NOTE]
> These need to be run in the virtual environment.
2025-02-04 11:35:51 -08:00
### Syncing Dependencies
When you pull new changes, you may need to update the dependencies.
To do so, first make sure you are in the virtual environment, and then in the `python` directory, run:
```sh
uv sync --all-extras
```
This will update the dependencies in the virtual environment.
2024-11-11 12:23:25 -08:00
### Creating a New Package
2024-08-29 10:29:12 -04:00
2024-11-11 12:23:25 -08:00
To create a new package, similar to `autogen-core` or `autogen-chat` , use the following:
2024-08-29 10:29:12 -04:00
```sh
2025-01-08 12:59:05 -05:00
uv sync --python 3.12
2024-08-29 10:29:12 -04:00
source .venv/bin/activate
cookiecutter ./templates/new-package/
```