theAbdoSabbagh / UnlimitedGPT

An unofficial Python wrapper for OpenAI's ChatGPT API
https://pypi.org/project/UnlimitedGPT/
GNU General Public License v3.0
346 stars 43 forks source link

Continue Generating #8

Closed Uranium2 closed 1 year ago

Uranium2 commented 1 year ago

I've been using your module to ask ChatGPT stuff, and sometimes ChatGPT will respond with a lot of text, and stops and will ask to continue generating or to regenerate.

In your case, api.send_message will return the truncated answer of ChatGPT, is it possible to detect when this button is here and press it? Maybe to mate it a default argument to send_message as True.

Maybe I'll try to make a PR to implement this.

api = ChatGPT(session_token, verbose=True)

message = api.send_message("My big question that will generate lot of text", continue_generating=True)
theAbdoSabbagh commented 1 year ago

Thats a very good suggestion, and yes its very much possible. I'll have a look into it soon.

theAbdoSabbagh commented 1 year ago

Version 0.1.5 is now out! You can view the changelog file here. As for updating the library, run the following command:

pip install UnlimitedGPT -U

View the docs here.

This version implements your suggestion :) Let me know if it works for you, I've tested it on my end and it works well. Closing the issue within the next 24 hours. Thanks for your suggestion btw!

Uranium2 commented 1 year ago

I was so close of making it! Never used selenium before, it's quite powerful!

It works perfectly thank you!

theAbdoSabbagh commented 1 year ago

Glad to hear that! If you like the project, I'd appreciate it if you star the repository :) Closing the issue now!

Uranium2 commented 1 year ago

I got an error in the case when I didn't had a long response:

     message = api.send_message(prompt_for_llm.to_string())
  File "E:\DEV\Open_Fit\.venv_win\lib\site-packages\UnlimitedGPT\UnlimitedGPT.py", line 418, in send_message
    continuation = self._continue_generating(timeout = timeout)
  File "E:\DEV\Open_Fit\.venv_win\lib\site-packages\UnlimitedGPT\UnlimitedGPT.py", line 302, in _continue_generating
    raise TimeoutException('Could not click continue regenerating button')
selenium.common.exceptions.TimeoutException: Message: Could not click continue regenerating button

I am sure that there were no continue regenerating button, the generation was over. Not sure what is the best way to handle this. A try execpt pass? That seems ugly and not very pythonic

theAbdoSabbagh commented 1 year ago

Ah yeah, I actually copied the code of regenerating the response and modified it to support the continue regeneration response, and the code included the error raising parts. For now just use try except, I'll fix it though and update the library soon. Shouldn't take long. Sorry for the inconvenience!

theAbdoSabbagh commented 1 year ago

The patch update is now pushed to pypi, update the package and it should fix the issue