mpociot / chatgpt-vscode

A VSCode extension that allows you to use ChatGPT

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature: allow us to use api tokens

ollyde opened this issue · comments

commented

I wrote an Alfred script for chatgpt; so I know it’s possible to use the api key instead of the session token. Much more reliable.

Hi @OllyDixon, what exactly do you mean by api token? The official OpenAI API key or something else?

commented

In OpenAI we have API keys which how you're supposed to use their APIs.

Using the session key might get your account banned.

Screenshot 2023-01-03 at 19 54 57

You're right, that's the correct/official way of using OpenAI API, and I have a version of this extension that uses this method to query GPT3 here (but it does not always perform as well as ChatGPT).

However, there is currently no official way to connect to ChatGPT as opposed to GPT3 via their API, so we have to use some unofficial ones until they release it, hopefully soon.

commented

You can connect to ChatGPT 3

Here's an example using the API key.


curl https://api.openai.com/v1/completions \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer [api key]" \
  -d '{
  "model": "text-davinci-003",
  "prompt": "${query}",
  "max_tokens": 4000,
  "temperature": 0.9 
}' | /opt/homebrew/bin/jq '.choices[].text' | cut -c6- | sed 's/.$//' > temp.txt 

Your code does not connect to the same model that is available online via chat interface. The code you posted connects to code-davinci, a GPT3.5 model (that is used by my extension I linked above), but not ChatGPT which is a finetuned model based on it.

commented

Your code does not connect to the same model that is available online via chat interface. The code you posted connects to code-davinci, a GPT3.5 model (that is used by my extension I linked above), but not ChatGPT which is a finetuned model based on it.

Oh I didn't know

No problem! After the release of ChatGPT, many people online started calling Gpt3 ChatGpt to join the hype😆 That's why it's easy to mix them up

@OllyDixon Try latest update of my version's repo (the updated version is already on the Marketplace so just update it if you already have it installed)

It uses a method described in this tweet (simple Node.js implementation here), already implemented in the unofficial chatgpt api. Only the official API key from OpenAI needed.

This is exactly what you wanted I think