Skip to content

Commit cd47b0f

Browse files
authored
Add back api docs (#62)
1 parent 3c3041f commit cd47b0f

24 files changed

+200
-98
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ jobs:
5959
enable-cache: true
6060

6161
- run: uv sync --python 3.12 --frozen --group docs
62-
- run: docs
63-
if: github.repository_owner != 'pydantic'
62+
63+
# always build docs to check it works without insiders packages
64+
- run: make docs
6465

6566
- run: make docs-insiders
6667
if: github.repository_owner == 'pydantic'

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ docs-serve:
7171
.docs-insiders-install:
7272
ifeq ($(shell uv pip show mkdocs-material | grep -q insiders && echo 'installed'), installed)
7373
@echo 'insiders packages already installed'
74+
else ifeq ($(PPPR_TOKEN),)
75+
@echo "Error: PPPR_TOKEN is not set, can't install insiders packages"
76+
@exit 1
7477
else
7578
@echo 'installing insiders packages...'
7679
@uv pip install -U mkdocs-material mkdocstrings-python \
@@ -79,11 +82,11 @@ endif
7982

8083
.PHONY: docs-insiders # Build the documentation using insiders packages
8184
docs-insiders: .docs-insiders-install
82-
uv run --no-sync mkdocs build
85+
uv run --no-sync mkdocs build -f mkdocs.insiders.yml
8386

8487
.PHONY: docs-serve-insiders # Build and serve the documentation using insiders packages
8588
docs-serve-insiders: .docs-insiders-install
86-
uv run --no-sync mkdocs serve
89+
uv run --no-sync mkdocs serve -f mkdocs.insiders.yml
8790

8891
.PHONY: cf-pages-build # Install uv, install dependencies and build the docs, used on CloudFlare Pages
8992
cf-pages-build:

docs/agents.md

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The [`Agent`][pydantic_ai.Agent] class is well documented, but in essence you ca
1111
* One or more [retrievers](#retrievers) — functions that the LLM may call to get information while generating a response
1212
* An optional structured [result type](results.md) — the structured datatype the LLM must return at the end of a run
1313
* A [dependency](dependencies.md) type constraint — system prompt functions, retrievers and result validators may all use dependencies when they're run
14-
* Agents may optionally also have a default [model](models/index.md) associated with them, the model to use can also be defined when running the agent
14+
* Agents may optionally also have a default [model](api/models/base.md) associated with them, the model to use can also be defined when running the agent
1515

1616
In typing terms, agents are generic in their dependency and result types, e.g. an agent which required `#!python Foobar` dependencies and returned data of type `#!python list[str]` results would have type `#!python Agent[Foobar, list[str]]`.
1717

@@ -350,7 +350,9 @@ agent.run_sync('hello', model=FunctionModel(print_schema))
350350

351351
_(This example is complete, it can be run "as is")_
352352

353-
The return type of retriever can any valid JSON object ([`JsonData`][pydantic_ai.dependencies.JsonData]) as some models (e.g. Gemini) support semi-structured return values, some expect text (OpenAI) but seem to be just as good at extracting meaning from the data, if a Python is returned and the model expects a string, the value will be serialized to JSON
353+
The return type of retriever can any valid JSON object ([`JsonData`][pydantic_ai.dependencies.JsonData]) as some models (e.g. Gemini) support semi-structured return values, some expect text (OpenAI) but seem to be just as good at extracting meaning from the data, if a Python is returned and the model expects a string, the value will be serialized to JSON.
354+
355+
If a retriever has a single parameter that can be represented as an object in JSON schema (e.g. dataclass, TypedDict, pydantic model), the schema for the retriever is simplified to be just that object. (TODO example)
354356

355357
## Reflection and self-correction
356358

@@ -478,23 +480,3 @@ else:
478480
1. Define a retriever that will raise `ModelRetry` repeatedly in this case.
479481

480482
_(This example is complete, it can be run "as is")_
481-
482-
## API Reference
483-
484-
::: pydantic_ai.Agent
485-
options:
486-
members:
487-
- __init__
488-
- run
489-
- run_sync
490-
- run_stream
491-
- model
492-
- override_deps
493-
- override_model
494-
- last_run_messages
495-
- system_prompt
496-
- retriever_plain
497-
- retriever_context
498-
- result_validator
499-
500-
::: pydantic_ai.exceptions

docs/api/agent.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# `pydantic_ai.Agent`
2+
3+
::: pydantic_ai.Agent
4+
options:
5+
members:
6+
- __init__
7+
- run
8+
- run_sync
9+
- run_stream
10+
- model
11+
- override_deps
12+
- override_model
13+
- last_run_messages
14+
- system_prompt
15+
- retriever_plain
16+
- retriever_context
17+
- result_validator

docs/api/dependencies.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `pydantic_ai.dependencies`
2+
3+
::: pydantic_ai.dependencies

docs/api/exceptions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `pydantic_ai.exceptions`
2+
3+
::: pydantic_ai.exceptions

docs/api/messages.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# `pydantic_ai.messages`
2+
3+
::: pydantic_ai.messages
4+
options:
5+
members:
6+
- Message
7+
- SystemPrompt
8+
- UserPrompt
9+
- ToolReturn
10+
- RetryPrompt
11+
- ModelAnyResponse
12+
- ModelTextResponse
13+
- ModelStructuredResponse
14+
- ToolCall
15+
- ArgsJson
16+
- ArgsObject
17+
- MessagesTypeAdapter
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# FunctionModel
1+
# `pydantic_ai.models.function`
22

33
::: pydantic_ai.models.function
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# Gemini
1+
# `pydantic_ai.models.gemini`
22

33
::: pydantic_ai.models.gemini

0 commit comments

Comments
 (0)