-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
Description
Initial Checks
- I confirm that I'm using the latest version of Pydantic AI
- I confirm that I searched for my issue in https://github.com/pydantic/pydantic-ai/issues before opening this issue
Description
Hi team,
In the example code of ai_q_and_a_run.py from the Human-in-the-loop section, it seems that the following condition:
elif isinstance(node, Answer):
print(node.question)
#> What is the capital of France?
breakcauses the flow to break prematurely.
Since it breaks at the first Answer (which is actually a question prompt), the program only asks the first question and then stops — which might not be the intended behavior.
It looks like removing the break (and possibly the surrounding lines) would allow the flow to continue as expected.
If I misunderstood how this is supposed to work, please let me know.
Thanks again for this great package!
Example Code
async with question_graph.iter(node, state=state, persistence=persistence) as run:
while True:
node = await run.next()
if isinstance(node, End):
print('END:', node.data)
history = await persistence.load_all()
print([e.node for e in history])
break
elif isinstance(node, Answer):
print(node.question)
#> What is the capital of France?Python, Pydantic AI & LLM client version
python 3.11
pydantic 2.12.2
llm openai:gpt-4o