arianneorpilla / jidoujisho

A full-featured immersion language learning suite for mobile.
GNU General Public License v3.0
974 stars 62 forks source link

ChatGPT source failing API call #397

Open GilgameshR opened 2 months ago

GilgameshR commented 2 months ago

This was encountered and tested using jidoujisho versions 2.9.0 (preview 1 and 2), and 2.8.9.

• After adding the API key to mediasource, i attempted to start the chat but was met with the following error message: Request failed or rate limited. Try again shortly or check your usage limits

• Despite verifying the API key, generating a new one, adjusting usage limits, and increasing credit, the issue persisted.

• I then ran the API key through Postman with the required JSON key/value pairs, and it worked fine.

• The API key is in other words fine, and the problem presumably lies either in the data key/value pairs pushed by jidoujisho, or i guess potentially the address where the data is being sent is outdated.

Heres what i ran when verifying through Postman:

https://api.openai.com/v1/chat/completions

Authorization: Bearer OPENAI_API_KEY 
/* specifically has to be project key, not user key due to additional authentication requirements with the latter. */

{ "model": "gpt-4o-mini", 
"messages": [ {
 "role": "system", 
"content": "Test" },
 { "role": "user", 
"content": "Write a short paragraph." } ] }

Note: A lazy and more permanent solution to this problem would be to add an input box for JSON which you fill once at the same time as adding the key. That way any arbitrary changes to the API can be resolved immediately by looking at the documentation.