openai / chatgpt-retrieval-plugin

The ChatGPT Retrieval Plugin lets you easily find personal or work documents by asking questions in natural language.
MIT License
21.06k stars 3.69k forks source link

Quickstart: BEARER_TOKEN vs OPENAI_API_KEY Needs Better Documentation #155

Open dbigham opened 1 year ago

dbigham commented 1 year ago

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 commented 1 year ago

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.

Dyllanjrusher commented 1 year ago

@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.

thatperson42 commented 1 year ago

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.

dbigham commented 1 year ago

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

KennethJefferson commented 1 year ago

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.

dbigham commented 1 year ago

@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.

KennethJefferson commented 1 year ago

@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!

madruga8 commented 1 year ago

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

knoel99 commented 1 year ago

@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