Closed Harry-Jing closed 1 year ago
I'm unsure how to use async. Do you mind adding it to https://github.com/acheong08/ChatGPT/blob/main/src/revChatGPT/__main__.py under a --async
argument?
I think that using async by default is probably the best idea. I was about to propose some changes to the async version of the library as well that I think could be bundled up with this:
I think that using async by default is probably the best idea
As long as it's stable, that's fine. --stream
can probably be used to handle the current method of using generators
Consider using uvloop. It shouldn't change anything in your codebase besides the import and the loop setup while providing a basically free speedup to the library (check how to implement it here) Consider using aiofiles for file operations
Those also look good. However, I would rather not add too many dependencies as this will only be used for CLI whereas the intent for this project is for use as a library.
seem like it is really easy to use uvloop you only need add
import asyncio
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
without chaning anything
But there is some problem when using uvloop "It not support Windows", whitch this is the information I got from the Internet.
The main problem here isn't whether or not it's easy to use them. It's more of that it bloats the dependencies which won't be used by most users (of the library as a dependency)
seem like it is really easy to use uvloop
Yup. Aiofiles would require changing your file operarions, but it's really simple to do. Operating files asynchronously isn't necessarily faster but it'll free your thread to do something else in the meantime which can be useful for developers cycling through multiple accounts.
this will only be used for CLI whereas the intent for this project is for use as a library.
The changes I proposed are general changes to the async library, they wouldn't be restricted to CLI usage.
The changes I proposed are general changes to the async library, they wouldn't be restricted to CLI usage.
There read/write is not the concern of the Chatbot classes. It should be handled by the users. The __main__.py
is a demo.
UVloop does seem useful but
"It not support Windows", whitch this is the information I got from the Internet.
If that is the case, I would rather not risk it
If that is the case, I would rather not risk it
Fair point. Devs can always setup the async loop themselves and override the library behavior.
It uses streaming generator by default which gets data as soon as it arrives. Same speed (maybe faster) than async
This can get quicker response, when receive first data, it can show it immediately