DevMiser / DaVinci

DaVinci - The ChatGPT AI Virtual Assistant
172 stars 21 forks source link

API error #24

Open thamm98 opened 10 months ago

thamm98 commented 10 months ago

so close to getting it running, responds with wake word but then says api error

admin@raspberrypi:~ $ cd /home/admin/DaVinci admin@raspberrypi:~/DaVinci $ python3 DaVinci.py

jarvis detected

Listening... Voice detected End of query detected

What would happen if the moon were to disappear.

There was an API error. Please try again in a few minutes.

pandreas21 commented 9 months ago

I am experiencing the same issue.

DevMiser commented 9 months ago

If you are a new OpenAI API user, you may have exceeded your free credits. Please check your OpenAI account.

Also, the installation is not working well with the new Raspberry Pi OS released on December 5, 2023. For best results, please use a Raspberry Pi 4 (not Raspberry Pi 5) and the legacy OS. Please refer to the new Important - Please read file on this repository.

SprocketHub commented 8 months ago

Hi, I followed your guide yesterday using a Pi 4 and the legacy 64bit OS with a brand new unused OpenAI account and I'm having this exact same issue. I also went back and made new AWS keys using the addendum but to no avail. Do you have any more possible suggestions as to what the cause might be?

DevMiser commented 8 months ago

Please tell me more about the error so that I can see if I can help. Are you getting a voice response when you first say "DaVinci". If not, what is the exact written error that is displayed in your terminal?

SprocketHub commented 8 months ago

Thank you for responding, originally I got exactly the same error as the original poster of this thread. I also since did the whole process again from scratch (I even reinstalled the OS) but got the same result "There was an API error. Please try again in a few minutes.".

However, after you replied I tried it again to take a picture for you and got a new error - DaVinci error

After getting this error I installed everything from scratch again but I'm still getting the new error pictured above.

P.S. Just to warn you I have absolutely no knowledge of linux or python, sorry

Update: I got a new picovoice key and got a new error concerning my AWS so I reverted to the original AWS keys I got before trying addendum I and now I'm back to the original error DaVinci error II

LavaSlider commented 8 months ago

I ran into this. The problem was that with a new free OpenAI account you do not have access to GPT-4, change it to GPT_model = "gpt-3.5-turbo" and the protocol error goes away. Or better yet, the code can be modified to print the error object when there is an API error for debugging. It can also be modified to look at the error code and type then switch the model to gpt-3.5-turbo automatically and ask the user to try again like this:

print("\ne.message: ")
print(e.message)   
if "model_not_found" == e.code and "invalid_request_error" == e.type:               
        print("It is an invalid_request_error")
        voice("\nThere was an open A I    model not found error with type invalid request. This probably means you do not have access to G P T  4, I will change to G P T three point five turbo. Please try again.")
        GPT_model = "gpt-3.5-turbo" # Try gpt-3.5-turbo to see if it fixes the problem
else:                                               
        voice("\nThere was an open A I  A P I error.  Please try again in a few minutes.")
SprocketHub commented 8 months ago

I changed to gpt-3.5-turbo but still get the same error.

DevMiser commented 8 months ago

@LavaSlider - Thank you for figuring this out and for the suggested code snippet.

@SprocketHub - Please send a copy of the code change for verification. Or sign up with OpenAI for a paid account. With normal usage, you should incur just a few dollars charge per month (much less expensive than ChatGPT Plus).

SprocketHub commented 8 months ago

Ok so, I've been busy for a few days and just came back to this and it's now working! I bought some credit so that must have been the issue I guess, thank you so much for helping Dev and Lava.

As a side note, when I ssh into my pi and manually run this script I get a text output of the interaction which is great. However I made a shortcut on the pi desktop to run the script but now I don't get that text output which is very handy to save me repeating questions, is there a way to run this from the desktop and have a terminal open with a chat transcrcipt? Or maybe even output the text to a pi screen?

DevMiser commented 8 months ago

Are you getting any error messages?

If not, you can enable VNC [https://www.raspberrypi.com/documentation/computers/remote-access.html#vnc] to remotely log into the Raspberry Pi from your computer. That will allow you to check the audio settings and adjust the volume. Additionally, this will allow you to keep a terminal open with a chat transcript.

SprocketHub commented 8 months ago

No error messages at all now. I did try it straight away after buying credit a few days ago and it didn't work but today it has been flawless so I guess it takes a little time to register that you've just paid.

VNC was very helpful and I have it added to my teamviewer account now, thank you.

DevMiser commented 8 months ago

Very happy to hear that you got it working. Enjoy.

kubbcanada commented 6 months ago

Jan 22, 2024

I added this to my code and it helped greatly. Thank you!