Skip to content

Conversation

sarunas-llm
Copy link
Contributor

@sarunas-llm sarunas-llm commented Mar 28, 2025

With ai_q_and_a_graph.py given above ai_q_and_a_run.py code is wrong

answer: str | None = sys.argv[2] if len(sys.argv) > 2 else None
should be
answer: str | None = sys.argv[1] if len(sys.argv) > 1 else None
We only need 1 argument for answer

(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) is wrong.
asyncio.run(main(answer)) should be asyncio.run(main()) because main() in ai_q_and_a_run.py does not accept arguments.

Issue: #1279

The https://ai.pydantic.dev/graph/#example-human-in-the-loop example is a little bit wrong.
With ai_q_and_a_graph.py given above ai_q_and_a_run.py code is wrong
answer: str | None = sys.argv[2] if len(sys.argv) > 2 else None should be answer: str | None = sys.argv[1] if len(sys.argv) > 1 else None because we only need 1 argument for answer
So explanation bellow (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) is wrong
Also asyncio.run(main(answer)) should be asyncio.run(main()) because main() in ai_q_and_a_run.py does not accept arguments
So its not can be run "as is" because either ai_q_and_a_run.py needs changes or above ai_q_and_a_graph.py example should include
sub_command = sys.argv[1]
assert sub_command in ('continuous', 'cli', 'mermaid')
Copy link
Contributor

hyperlint-ai bot commented Mar 28, 2025

PR Change Summary

Corrected the argument handling in the example code for the AI Q&A documentation and updated the accompanying explanation.

  • Fixed the argument index for the answer in the example code.
  • Updated the documentation to reflect the correct usage of the asyncio.run(main()) function.

Modified Files

  • docs/graph.md

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

@samuelcolvin samuelcolvin merged commit bfa0329 into pydantic:main Mar 28, 2025
17 checks passed
@samuelcolvin
Copy link
Member

thanks so much

@sarunas-llm sarunas-llm deleted the docs-example-fix branch April 1, 2025 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants