-
Notifications
You must be signed in to change notification settings - Fork 423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Graph Support #528
Merged
Merged
Graph Support #528
Changes from all commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
68f5fe2
start pydantic-ai-graph
samuelcolvin 615c5e2
lower case state machine
samuelcolvin 9ffe8f0
starting tests
samuelcolvin dd60d15
add history and logfire
samuelcolvin 73db282
add example, alter types
samuelcolvin 03fcaf2
fix dependencies
samuelcolvin 1bae9bf
fix ci deps
samuelcolvin 61f3d2b
fix tests for other versions
samuelcolvin dc769c9
change node test times
samuelcolvin b03e7bc
pydantic-ai-graph - simplify public generics (#539)
dmontagu d0bdb87
Typo in Graph Documentation (#596)
izzyacademy 16ccd03
fix linting
samuelcolvin bda6dfb
separate mermaid logic
samuelcolvin cce71e1
fix graph type checking
samuelcolvin 2d9f9f3
bump
samuelcolvin 7e98bf7
adding node highlighting to mermaid, testing locally
samuelcolvin 743fa5a
bump
samuelcolvin f6aa929
fix type checking imports
samuelcolvin 246755d
fix for python 3.9
samuelcolvin d985db4
simplify mermaid config
samuelcolvin c325789
remove GraphRunner
samuelcolvin c41d59a
add Interrupt
samuelcolvin 0b19632
remove interrupt, replace with "next()"
samuelcolvin c1b8035
address comments
samuelcolvin 7e24d9d
switch name to pydantic-graph
samuelcolvin b74d0e4
allow labeling edges and notes for docstrings
samuelcolvin 7f34a0d
allow notes to be disabled
samuelcolvin 15573e9
adding graph tests
samuelcolvin de6b9e7
more mermaid tests, fix 3.9
samuelcolvin 08e87aa
rename node to start_node in graph.run()
samuelcolvin 25d79aa
more tests for graphs
samuelcolvin 6e62906
coverage in tests
samuelcolvin c9ebc49
cleanup graph properties
samuelcolvin 997ba99
infer graph name
samuelcolvin 3b22850
fix for 3.9
samuelcolvin 452a62f
adding API docs
samuelcolvin 707129f
fix state, more docs
samuelcolvin 80d4713
fix graph api examples
samuelcolvin be1563d
starting graph documentation
samuelcolvin 6fdd1e9
fix examples
samuelcolvin a882a6c
more graph documentation
samuelcolvin f2cd72a
add GenAI example
samuelcolvin 111f2d0
more graph docs
samuelcolvin 5d0a834
extending graph docs
samuelcolvin 9a7ab8e
fix history serialization
samuelcolvin 4cd9142
add history (de)serialization tests
samuelcolvin 598fdd6
add mermaid diagram section to graph docs
samuelcolvin bf8b824
fix tests
samuelcolvin aec8fab
add exceptions docs
samuelcolvin 7d4f31d
docs tweaks
samuelcolvin 79cb2b3
copy edits from @dmontagu
samuelcolvin 38a787e
fix pydantic-graph readme
samuelcolvin 6db58d6
snapshot state after node execution, not before
samuelcolvin 326e5f5
improve history (de)serialization
samuelcolvin 5b8433b
fix for older python
samuelcolvin b4e44bf
Graph deps (#693)
samuelcolvin a2144d6
docs comments, GraphContext -> GraphRunContext
samuelcolvin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ env*/ | |
examples/pydantic_ai_examples/.chat_app_messages.sqlite | ||
.cache/ | ||
.vscode/ | ||
/question_graph_history.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# `pydantic_graph.exceptions` | ||
|
||
::: pydantic_graph.exceptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# `pydantic_graph` | ||
|
||
::: pydantic_graph.graph |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# `pydantic_graph.mermaid` | ||
|
||
::: pydantic_graph.mermaid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# `pydantic_graph.nodes` | ||
|
||
::: pydantic_graph.nodes | ||
options: | ||
members: | ||
- GraphRunContext | ||
- BaseNode | ||
- End | ||
- Edge | ||
- DepsT | ||
- RunEndT | ||
- NodeRunEndT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# `pydantic_graph.state` | ||
|
||
::: pydantic_graph.state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Question Graph | ||
|
||
Example of a graph for asking and evaluating questions. | ||
|
||
Demonstrates: | ||
|
||
* [`pydantic_graph`](../graph.md) | ||
|
||
## Running the Example | ||
|
||
With [dependencies installed and environment variables set](./index.md#usage), run: | ||
|
||
```bash | ||
python/uv-run -m pydantic_ai_examples.question_graph | ||
``` | ||
|
||
## Example Code | ||
|
||
```python {title="question_graph.py"} | ||
#! examples/pydantic_ai_examples/question_graph.py | ||
``` | ||
|
||
The mermaid diagram generated in this example looks like this: | ||
|
||
```mermaid | ||
--- | ||
title: question_graph | ||
--- | ||
stateDiagram-v2 | ||
[*] --> Ask | ||
Ask --> Answer: ask the question | ||
Answer --> Evaluate: answer the question | ||
Evaluate --> Congratulate | ||
Evaluate --> Castigate | ||
Congratulate --> [*]: success | ||
Castigate --> Ask: try again | ||
``` |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this cover the
tests/
files? If so, was there a reason we didn't do this sooner?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no this just covers two specific files:
tests/typed_agent.py
andtests/typed_graph.py
, the only change here is to put the config intopyproject.toml
, notMakefile