Skip to content
Merged
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: 2 additions & 2 deletions docs/graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ from ai_q_and_a_graph import Ask, question_graph, Evaluate, QuestionState, Answe


async def main():
answer: str | None = sys.argv[2] if len(sys.argv) > 2 else None # (1)!
answer: str | None = sys.argv[1] if len(sys.argv) > 1 else None # (1)!
persistence = FileStatePersistence(Path('question_graph.json')) # (2)!
persistence.set_graph_types(question_graph) # (3)!

Expand Down Expand Up @@ -797,7 +797,7 @@ async def main():
8. To demonstrate the state persistence, we call [`load_all`][pydantic_graph.persistence.BaseStatePersistence.load_all] to get all the snapshots from the persistence instance. This will return a list of [`Snapshot`][pydantic_graph.persistence.Snapshot] objects.
9. If the node is an `Answer` object, we print the question and break out of the loop to end the process and wait for user input.

_(This example is complete, it can be run "as is" with Python 3.10+ — you'll need to add `asyncio.run(main(answer))` to run `main`)_
_(This example is complete, it can be run "as is" with Python 3.10+ — you'll need to add `asyncio.run(main())` to run `main`)_

For a complete example of this graph, see the [question graph example](examples/question-graph.md).

Expand Down