Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ install: .uv .pre-commit
uv sync --frozen --all-extras --group lint --group docs
pre-commit install --install-hooks

.PHONY: sync # Update local packages and uv.lock
sync: .uv
uv sync --all-extras --group lint --group docs

.PHONY: format # Format the code
format:
uv run ruff format
Expand Down
8 changes: 5 additions & 3 deletions docs/.hooks/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@ def on_page_markdown(markdown: str, page: Page, config: Config, files: Files) ->


def replace_uv_python_run(markdown: str) -> str:
return re.sub(r'```bash\n(.*?)python/uv[\- ]run(.+?)\n```', sub_run, markdown)
return re.sub(r'```bash\n(.*?)(python/uv[\- ]run|pip/uv[\- ]add)(.+?)\n```', sub_run, markdown)


def sub_run(m: re.Match[str]) -> str:
prefix = m.group(1)
command = m.group(2)
install = 'pip' in command
suffix = m.group(3)
return f"""\
=== "pip"

```bash
{prefix}python{command}
{prefix}{'pip install' if install else 'python'}{suffix}
```

=== "uv"

```bash
{prefix}uv run{command}
{prefix}uv {'add' if install else 'run'}{suffix}
```"""


Expand Down
14 changes: 3 additions & 11 deletions docs/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,9 @@ Either way you'll need to install extra dependencies to run some examples, you j

If you've installed `pydantic-ai` via pip/uv, you can install the extra dependencies with:

=== "pip"

```bash
pip install 'pydantic-ai[examples]'
```

=== "uv"

```bash
uv add 'pydantic-ai[examples]'
```
```bash
pip/uv-add 'pydantic-ai[examples]'
```

If you clone the repo, you should instead use `uv sync --extra examples` to install extra dependencies.

Expand Down
38 changes: 17 additions & 21 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,36 @@

PydanticAI is available [on PyPI](https://pypi.org/project/pydantic-ai/) so installation is as simple as:

=== "pip"

```bash
pip install pydantic-ai
```

=== "uv"

```bash
uv add pydantic-ai
```
```bash
pip/uv-add pydantic-ai
```

It requires Python 3.9+.

!!! note "Use `--prerelease=allow` with uv"
Until Pydantic v2.10 is released (very soon), you'll need to use `--prerelease=allow` with `uv` to install PydanticAI.

## Use with Pydantic Logfire

PydanticAI has an excellent (but completely optional) integration with [Pydantic Logfire](https://pydantic.dev/logfire) to help you view and understand agent runs.

To use Logfire with PydanticAI, install PydanticAI with the `logfire` optional group:

=== "pip"
```bash
pip/uv-add 'pydantic-ai[logfire]'
```

```bash
pip install 'pydantic-ai[logfire]'
```
From there, follow the [Logfire setup cods](logfire.md#integrating-logfire) to configure Logfire.

=== "uv"
## Running Examples

```bash
uv add 'pydantic-ai[logfire]'
```
PydanticAI bundles its examples so you can run them very easily.

From there, follow the [Logfire setup cods](logfire.md#integrating-logfire) to configure Logfire.
To install extra dependencies required to run examples, install the `examples` optional group:

## Next Steps
```bash
pip/uv-add 'pydantic-ai[examples]'
```

To run PydanticAI, follow instructions [in examples](examples/index.md).
For next steps, follow instructions [in examples](examples/index.md).
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies = [

[project.optional-dependencies]
logfire = [
"logfire>=2",
"logfire>=2.3",
]
examples = [
"asyncpg>=0.30.0",
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading