docs: change query execution to use asyncio.run - #2532
Merged
Conversation
Updated the query execution to run asynchronously using asyncio.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Updated the query execution to run asynchronously using asyncio.
Issue Link / Problem Description
The issue on line 49 of the file
docs/howtos/applications/evaluate-and-improve-rag.mdis that it uses theawaitkeyword at the top level of the script.Description of the Issue:
In Python, the
awaitkeyword is only allowed within an asynchronous function (defined withasync def). When the code snippet provided in the documentation is run as a standard Python script (e.g.,python script.py), it will fail with the following error:SyntaxError: 'await' outside functionContext (Lines 33–51):
The code block imports
asyncio(line 35) but fails to use it to execute the asynchronousrag.query()method.Changes Made
To make the script runnable, the asynchronous logic should be executed using asyncio.run():
Testing
How to Test
References
Screenshots/Examples (if applicable)