chatgpt-retrieval-plugin icon indicating copy to clipboard operation
chatgpt-retrieval-plugin copied to clipboard

Quickstart: BEARER_TOKEN vs OPENAI_API_KEY Needs Better Documentation

Open dbigham opened this issue 2 years ago • 9 comments

The Quickstart says that both of these environment variables need to be set, but it would seem that these two environment variables should both be set to one's Open AI API key?

If so, why are both environment variables needed? This caused confusion for me.

dbigham avatar Apr 08 '23 01:04 dbigham

I'm now seeing this part of the docs, below the Quickstart:

"This is a secret token that you need to authenticate your requests to the API. You can generate one using any tool or method you prefer, such as jwt.io."

Even with that additional information, it's not quite clear what I'm needing to do here.

dbigham avatar Apr 08 '23 02:04 dbigham

@dbigham Did you resolve this? I'm still not sure what to do here. I found a bearer token from chatgpt, that didn't work. Pasting stuff generated form jwt.io (after clicking share jwt) also didn't work.

Dyllanjrusher avatar Apr 25 '23 15:04 Dyllanjrusher

Starting out, you can use any arbitrary JWT bearer token. For example, using jwt.io, you can create some arbitrary payload and insert a key into "verify signature" and get a valid bearer token (the string with two .s) on the Encoded side, and set that as your BEARER_TOKEN environment variable.

Hope that helps with getting started -- I was a bit confused that the noauth method still required a bearer token.

thatperson42 avatar Apr 25 '23 16:04 thatperson42

Yes, what @thatperson42 states is consistent with what I did to get it working.

dbigham avatar Apr 26 '23 00:04 dbigham

I new to development, can someone assist me and tell em where I modify the environment variables? There's no .env file for this project.

KennethJefferson avatar May 03 '23 08:05 KennethJefferson

@shatterstar6457 , the environment variables could be set from the terminal window that you use to launch the application.

So for example, I'm on Windows, so I start powershell, and then I set my environment variables by typing / pasting into the terminal:

$env:DATASTORE="redis"
$env:BEARER_TOKEN="..."
$env:OPENAI_API_KEY="..."
$env:REDIS_HOST="localhost"
$env:REDIS_PORT="6379"
$env:REDIS_INDEX_NAME="index"
$env:REDIS_DOC_PREFIX="doc"
$env:REDIS_DISTANCE_METRIC="COSINE"
$env:REDIS_INDEX_TYPE="FLAT"

Then from the chatgpt-retrieval-plugin directory I run poetry run dev.

dbigham avatar May 03 '23 20:05 dbigham

@shatterstar6457 , the environment variables could be set from the terminal window that you use to launch the application.

So for example, I'm on Windows, so I start powershell, and then I set my environment variables by typing / pasting into the terminal:

$env:DATASTORE="redis"
$env:BEARER_TOKEN="..."
$env:OPENAI_API_KEY="..."
$env:REDIS_HOST="localhost"
$env:REDIS_PORT="6379"
$env:REDIS_INDEX_NAME="index"
$env:REDIS_DOC_PREFIX="doc"
$env:REDIS_DISTANCE_METRIC="COSINE"
$env:REDIS_INDEX_TYPE="FLAT"

Then from the chatgpt-retrieval-plugin directory I run poetry run dev.

Thank you so much!

KennethJefferson avatar May 04 '23 00:05 KennethJefferson

can someone explain what is this bearer token and why its needed ?

madruga8 avatar May 25 '23 00:05 madruga8

@madruga8 Your token should look like this :

BEARER_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.F3f0v8YA_RnW0wnNdkR_uuqD-GddzTDuB2W0lwAzL88

It is the concatenation of 3 string in base 64. First is header, second is payload, and third are data related to the security algorithm defined in the header. Go to https://jwt.io/ and you can replace with your own private key, instead of openai.

image

Using a JSON web token allows you to authenticate a user without querying the authentification server for verification.

But I am still stuck like you, my project runs good after poetry run start but the bound to chatGPT is refused: image

image

edits: typo

knoel99 avatar Jun 30 '23 07:06 knoel99