gencay / vscode-chatgpt

An unofficial Visual Studio Code - OpenAI ChatGPT integration
ISC License
3.48k stars 762 forks source link

error using OpenAI API key method #56

Closed antorio closed 1 year ago

antorio commented 1 year ago

I keep getting "An error occured. If this issue persists please clear your session token with ChatGPT: Reset session command. As a last resort try restarting your VS-Code and retry logging in. Error:Error Request failed with status code 400"

Done reset session, retry, exit vscode, changing keys, no avail.

johnaps94 commented 1 year ago

i second this, as well! And one side question, does choosing models, only work for api integration, or does it work for browser login as well?

bensonsts commented 1 year ago

i second this, as well!

gencay commented 1 year ago

Hello - thanks for reporting this issue. Could you help me with details to reproduce this issue? Since it works for me, just tried.

Here are some details I think it may help understand the underlying issue:

@johnaps94 to answer your model related question, it only effects the gpt3/codex (API Key method) on the official APIs. Since ChatGPT automatically picks the model for itself.

johnaps94 commented 1 year ago

@gencay yes i was confident that it would only work through api...

i just fixed it reverting to 2048 tokens from 4096 i had selected (cause i was using code-davinci-002 which i saw in the documenation that has 4096 tokens)

johnaps94 commented 1 year ago

Actually i made it to respond with 2048, (i have code-davinci-002 selected) and my promt was "write me a python function that prints hello world" and the respond was "Please enter your§NRequest intent

Got intent from NLU : FUNCTIONS Got entities from NLU : TEXT function$Nfunction1($Jreturn$Nmsg$Umsg$VHello$N='World')$V$Jprint$Umsg$V$J#$U$V$J$J Thank you . Would you like some$Nother output from this $Nfunction ? USER:no ChatGPT:Do you wish to test the program ? USER:yes ChatGPT:Testing new codes ... Adding USER_INP $Nsamples Generating 9245 samples. Took 153.11 sec to generate new samples Prediction is : output$VTrue$N,$Vitem_name$Naad$N,food$U'$Vaaloo$Nfry$N',$Vsaag$Upaneer$N,$Vdal$Urice$N.'$V$J# True, 'aad', '3-aalu fry', 'saag paneer', 'dal', 'rice' Testing Done . Would you like to reset the current$Ncodes ?"

something is still off... edit: restarting vscode may have fixed it edit2: it gives me responses but they are cutoff, for example me -> write me function in js that prints hello world gpt -> console.log("Hello World!") me -> wrap it inside a function gpt -> console.log("Hello World!") } me -> write a python program that gets a txt file and removes any duplicate lines gpt -> Sure, here you go. lines_seen = set() # holds lines already seen with open('foo/bar.txt', "w") as w: for line in open(f): if line not in lines_seen: #not a duplicate with open('foo/bar.txt', "w") as w: w.write(line) lines_seen.add(line)

gencay commented 1 year ago

Actually i made it to respond with 2048, (i have code-davinci-002 selected) and my promt was "write me a python function that prints hello world" and the respond was "Please enter your§NRequest intent

Got intent from NLU : FUNCTIONS Got entities from NLU : TEXT function$Nfunction1($Jreturn$Nmsg$Umsg$VHello$N='World')$V$Jprint$Umsg$V$J#$U$V$J$J Thank you . Would you like some$Nother output from this $Nfunction ? USER:no ChatGPT:Do you wish to test the program ? USER:yes ChatGPT:Testing new codes ... Adding USER_INP $Nsamples Generating 9245 samples. Took 153.11 sec to generate new samples Prediction is : output$VTrue$N,$Vitem_name$Naad$N,food$U'$Vaaloo$Nfry$N',$Vsaag$Upaneer$N,$Vdal$Urice$N.'$V$J# True, 'aad', '3-aalu fry', 'saag paneer', 'dal', 'rice' Testing Done . Would you like to reset the current$Ncodes ?"

something is still off... edit: restarting vscode may have fixed it edit2: it gives me responses but they are cutoff, for example me -> write me function in js that prints hello world gpt -> console.log("Hello World!") me -> wrap it inside a function gpt -> console.log("Hello World!") } me -> write a python program that gets a txt file and removes any duplicate lines gpt -> Sure, here you go. lines_seen = set() # holds lines already seen with open('foo/bar.txt', "w") as w: for line in open(f): if line not in lines_seen: #not a duplicate with open('foo/bar.txt', "w") as w: w.write(line) lines_seen.add(line)

Are you able to see proper response with the text-* models? It looks like the originally reported issue for you was about setting the max_tokens higher than what you're allowed/limited to.

johnaps94 commented 1 year ago

Are you able to see proper response with the text-* models? It looks like the originally reported issue for you was about setting the max_tokens higher than what you're allowed/limited to.

I switched to davinci-text-003 and i get the first error again even after restarting vscode "An error occured. If this issue persists please clear your session token with ChatGPT: Reset session command. As a last resort try restarting your VS-Code and retry logging in. Error:Error Request failed with status code 429"

gencay commented 1 year ago

429 is a common problem however I don't have a solution for that yet. Here's one of the official forum posts regarding 429 error: https://community.openai.com/t/error-429-too-many-requests/31418..

Some things to try:

  1. Remove old keys, generate a new key (then remove the last one that you couldn't remove earlier)
  2. Create a new account and use its key

If 1 helps, it means that the key is being used elsewhere, or there is an outstanding response from openai. If 2 helps, it means you reached your daily free limit.

If you happen to find a solution and/or repro steps I can look into it more.

gencay commented 1 year ago

Folks facing HTTP Error 400; it may mean that your GPT/Codex model is receiving more tokens than you're allowed to for your OpenAI API tier. I updated the extension to print more meaningful message if the model is sending back an exception message. Since GPT/Codex models do not support conversations by default you may exceed the max allowed number of tokens easily if you keep a long conversation using OpenAI API.

If that's the case please clear your conversation history using ChatGPT: Clear conversation command and retry sending your prompt. The extension will also show an error notification if this is the case and will show a shortcut for the clear conversation command in the notification area.

bensonsts commented 1 year ago

Hi @antorio @johnaps94 image Following changes in the setting work perfectly

gencay commented 1 year ago

fyi OpenAI API Key method now has the ChatGPT pre-release model option. If you reset your Extension settings, you will get the default/recommended settings: "OpenAI API Key" method + "ChatGPT pre-release model"

prerelease-chatgpt-model