Skip to content

Added asyncio.run method as alternative to using await to execute async conversations #46

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

IAmNo1Special
Copy link

@IAmNo1Special IAmNo1Special commented Apr 11, 2025

Added commented "asyncio.run()" to places where raw "await" is being used.
This fixes the "SyntaxError: 'await' outside function" error.

Same as closed unmerged PR #31.

@IAmNo1Special
Copy link
Author

@lavinigam-gcp
Had to resubmit after fixing my own branches but this PR changes are the same as what was approved.

Copy link
Collaborator

@Sita04 Sita04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing to the docs and making it better! @IAmNo1Special

@polong-lin
Copy link
Collaborator

@lavinigam-gcp Did you want to double-check anything here because I think you're mirroring everything in tutorial.md with the Colab notebook therein? If not, feel free to merge.

@lavinigam-gcp
Copy link
Collaborator

I have suggested few changes @IAmNo1Special - I am making the same on the notebook. Kindly update the PR and let me know if you have questions.

More importantly, while asyncio run in Colab, but when you try to call asyncio.run() inside a Colab/Jupyter cell, you are telling Python to create a new event loop while one is already running (the one started by Colab/Jupyter), so user will get error.

So our suggestions should be to use await on Colab/Notebook and asyncio for .py, jsut to avoid DX issues.

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.

4 participants