From d2fab041f6df109b7b737beafd4deeccae1992a3 Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Wed, 13 Nov 2024 18:33:01 +0000 Subject: [PATCH 1/3] add docs stubs --- docs/concepts/dependencies.md | 0 docs/concepts/index.md | 0 docs/concepts/message-history.md | 0 docs/concepts/result-validation.md | 0 docs/concepts/retrievers.md | 0 docs/concepts/streaming.md | 0 docs/concepts/system-prompt.md | 0 docs/concepts/testing-evals.md | 0 docs/examples/{chat_app.md => chat-app.md} | 0 docs/examples/index.md | 2 +- .../{pydantic_model.md => pydantic-model.md} | 0 docs/examples/rag.md | 2 +- docs/examples/{sql_gen.md => sql-gen.md} | 0 ...{stream_markdown.md => stream-markdown.md} | 0 .../{stream_whales.md => stream-whales.md} | 0 .../{weather_agent.md => weather-agent.md} | 0 docs/index.md | 8 +++++-- mkdocs.yml | 21 +++++++++++++------ 18 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 docs/concepts/dependencies.md create mode 100644 docs/concepts/index.md create mode 100644 docs/concepts/message-history.md create mode 100644 docs/concepts/result-validation.md create mode 100644 docs/concepts/retrievers.md create mode 100644 docs/concepts/streaming.md create mode 100644 docs/concepts/system-prompt.md create mode 100644 docs/concepts/testing-evals.md rename docs/examples/{chat_app.md => chat-app.md} (100%) rename docs/examples/{pydantic_model.md => pydantic-model.md} (100%) rename docs/examples/{sql_gen.md => sql-gen.md} (100%) rename docs/examples/{stream_markdown.md => stream-markdown.md} (100%) rename docs/examples/{stream_whales.md => stream-whales.md} (100%) rename docs/examples/{weather_agent.md => weather-agent.md} (100%) diff --git a/docs/concepts/dependencies.md b/docs/concepts/dependencies.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/concepts/index.md b/docs/concepts/index.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/concepts/message-history.md b/docs/concepts/message-history.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/concepts/result-validation.md b/docs/concepts/result-validation.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/concepts/retrievers.md b/docs/concepts/retrievers.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/concepts/streaming.md b/docs/concepts/streaming.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/concepts/system-prompt.md b/docs/concepts/system-prompt.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/concepts/testing-evals.md b/docs/concepts/testing-evals.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs/examples/chat_app.md b/docs/examples/chat-app.md similarity index 100% rename from docs/examples/chat_app.md rename to docs/examples/chat-app.md diff --git a/docs/examples/index.md b/docs/examples/index.md index ae1ee0a67f..e5f2ce89a3 100644 --- a/docs/examples/index.md +++ b/docs/examples/index.md @@ -57,7 +57,7 @@ To run the examples (this will work whether you installed `pydantic_ai`, or clon python/uv-run -m pydantic_ai_examples. ``` -For examples, to run the very simple [`pydantic_model`](./pydantic_model.md) example: +For examples, to run the very simple [`pydantic_model`](./pydantic-model.md) example: ```bash python/uv-run -m pydantic_ai_examples.pydantic_model diff --git a/docs/examples/pydantic_model.md b/docs/examples/pydantic-model.md similarity index 100% rename from docs/examples/pydantic_model.md rename to docs/examples/pydantic-model.md diff --git a/docs/examples/rag.md b/docs/examples/rag.md index 22900e3d88..6fc72779a5 100644 --- a/docs/examples/rag.md +++ b/docs/examples/rag.md @@ -29,7 +29,7 @@ docker run --rm \ pgvector/pgvector:pg17 ``` -As with the [SQL gen](./sql_gen.md) example, we run postgres on port `54320` to avoid conflicts with any other postgres instances you may have running. +As with the [SQL gen](./sql-gen) example, we run postgres on port `54320` to avoid conflicts with any other postgres instances you may have running. We also mount the PostgreSQL `data` directory locally to persist the data if you need to stop and restart the container. With that running and [dependencies installed and environment variables set](./index.md#usage), we can build the search database with (**WARNING**: this requires the `OPENAI_API_KEY` env variable and will calling the OpenAI embedding API around 300 times to generate embeddings for each section of the documentation): diff --git a/docs/examples/sql_gen.md b/docs/examples/sql-gen.md similarity index 100% rename from docs/examples/sql_gen.md rename to docs/examples/sql-gen.md diff --git a/docs/examples/stream_markdown.md b/docs/examples/stream-markdown.md similarity index 100% rename from docs/examples/stream_markdown.md rename to docs/examples/stream-markdown.md diff --git a/docs/examples/stream_whales.md b/docs/examples/stream-whales.md similarity index 100% rename from docs/examples/stream_whales.md rename to docs/examples/stream-whales.md diff --git a/docs/examples/weather_agent.md b/docs/examples/weather-agent.md similarity index 100% rename from docs/examples/weather_agent.md rename to docs/examples/weather-agent.md diff --git a/docs/index.md b/docs/index.md index 478ba9f226..0548fbc986 100644 --- a/docs/index.md +++ b/docs/index.md @@ -32,7 +32,7 @@ PydanticAI tries to make working with LLMs feel similar to building a web applic PydanticAI is in early beta, the API is subject to change and there's a lot more to do. [Feedback](https://github.com/pydantic/pydantic-ai/issues) is very welcome! -## Retrievers and Dependency Injection +## Example — Retrievers and Dependency Injection Partial example of using retrievers to help an LLM respond to a user's query about the weather: @@ -92,4 +92,8 @@ async def main(): 10. `result.all_messages()` includes details of messages exchanged, this is useful both to understand the conversation that took place and useful if you want to continue the conversation later — messages can be passed back to later `run/sync_run` calls. !!! tip "Complete `weather_agent.py` example" - The above `weather_agent.py` example is complete for the sake of brevity, but you can find a complete example [here](examples/weather_agent.md). + This example is incomplete for the sake of brevity; you can find a complete `weather_agent.py` example [here](examples/weather-agent.md). + +## Example — Result Validation + +TODO diff --git a/mkdocs.yml b/mkdocs.yml index 81b54f8258..4f02e014ff 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -15,13 +15,22 @@ nav: - install.md - Examples: - examples/index.md - - examples/pydantic_model.md - - examples/weather_agent.md - - examples/sql_gen.md + - examples/pydantic-model.md + - examples/weather-agent.md + - examples/sql-gen.md - examples/rag.md - - examples/stream_markdown.md - - examples/stream_whales.md - - examples/chat_app.md + - examples/stream-markdown.md + - examples/stream-whales.md + - examples/chat-app.md + - Concepts: + - concepts/index.md + - concepts/dependencies.md + - concepts/retrievers.md + - concepts/system-prompt.md + - concepts/result-validation.md + - concepts/message-history.md + - concepts/streaming.md + - concepts/testing-evals.md - API Reference: - api/agent.md - api/result.md From 4b2e84ab7868af81601e98a8e987e4e62c1dd55b Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Wed, 13 Nov 2024 18:33:39 +0000 Subject: [PATCH 2/3] fix link --- docs/examples/rag.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/rag.md b/docs/examples/rag.md index 6fc72779a5..20e77b526a 100644 --- a/docs/examples/rag.md +++ b/docs/examples/rag.md @@ -29,7 +29,7 @@ docker run --rm \ pgvector/pgvector:pg17 ``` -As with the [SQL gen](./sql-gen) example, we run postgres on port `54320` to avoid conflicts with any other postgres instances you may have running. +As with the [SQL gen](./sql-gen.md) example, we run postgres on port `54320` to avoid conflicts with any other postgres instances you may have running. We also mount the PostgreSQL `data` directory locally to persist the data if you need to stop and restart the container. With that running and [dependencies installed and environment variables set](./index.md#usage), we can build the search database with (**WARNING**: this requires the `OPENAI_API_KEY` env variable and will calling the OpenAI embedding API around 300 times to generate embeddings for each section of the documentation): From 8f1c3b6f3d4b0ae337eabe7dcfe63edb85509fcd Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Wed, 13 Nov 2024 18:34:43 +0000 Subject: [PATCH 3/3] fix menu order --- mkdocs.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index 4f02e014ff..66aaefbbb1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -13,15 +13,6 @@ nav: - Introduction: - Introduction: index.md - install.md - - Examples: - - examples/index.md - - examples/pydantic-model.md - - examples/weather-agent.md - - examples/sql-gen.md - - examples/rag.md - - examples/stream-markdown.md - - examples/stream-whales.md - - examples/chat-app.md - Concepts: - concepts/index.md - concepts/dependencies.md @@ -31,6 +22,15 @@ nav: - concepts/message-history.md - concepts/streaming.md - concepts/testing-evals.md + - Examples: + - examples/index.md + - examples/pydantic-model.md + - examples/weather-agent.md + - examples/sql-gen.md + - examples/rag.md + - examples/stream-markdown.md + - examples/stream-whales.md + - examples/chat-app.md - API Reference: - api/agent.md - api/result.md