Find answers from the community

Updated 2 years ago

Hello everyone I am trying to follow the

Hello everyone. I am trying to follow the basic tutorial to implement a vector store index to a pdf (Lyft's 2021 10k), and I am getting an error. It is only a few lines of code and I followed the tutorial as closely as possible and am not sure why it gets this Retry Error when I run the line index = VectorStoreIndex.from_documents(documents). If anyone has any ideas please reach out!
L
a
a
24 comments
Looks like an authentication error. Did you set your openai key properly?
At first glance anyways, thats what I noticed
I am pretty certain it is set up right. I tried two accounts (one paid version) and set a name and copied the code on openai's website. That was it for the setup right?
Attachments
scrn2.png
scrnn.png
and I'm assuming you copy/pasted that key and set it in your env? (sorry I know this is basic, just narrowing it down haha)

import os
os.environ["OPENAI_API_KEY"] = "sk-........."
All good, Ive been banging my head on my desk all day over these few lines of code that look almost exactly like the tutorials / website lol
Maybe try setting it outside of the notebook? In bash, I would do export OPENAI_API_KEY="sk-..." before starting jupyter
Very weird that it's not working lol
Not sure how to do that in bash, but when I type %env in jupyter I see 'OPENAI_API_KEY': '<hidden> in the dictionary output so I think it wouldnt make a difference if I set in in bash or not but Im not sure. Also if I dont run the line os.environ["OPENAI_API_KEY"] = "sk-........." (and the next two ones), then I get a different error when I run the line index = VectorStoreIndex.from_documents(documents) saying "ValidationError: 1 validation error for OpenAI
Did not find openai_api_key, please add an environment variable OPENAI_API_KEY which contains it, or pass openai_api_key as a named parameter. (type=value_error)". This indicates that the key is already initiated correctly so I am confused why it is still giving an error. Do you have any other ideas?
My only other idea is the langchain version is causing issues? I would try upgrading it, or downgrading to 0.0.154
@aidan im getting the same issue. i tried integrating my api key in a lot of different ways but it still doesn't read it.
did you end up fixing it?
Not yet 😦
did you try using a model other than openai?
I have not, I think the error is in setting the api key environment variable which does not make sense since I copied it directly from LlamaIndex's documentation
I was thinking of trying to use a local model instead which might work
openai keys have been wonky with some langchain versions lately

You can set the key more directly like this

Plain Text
import openai

openai.api_key = ".."
I found I had to set it both like that and in my terminal env
I broke the problem down to the simplest component. There is an error running this line openai.Embedding.create(input = inputstring, model = "text-embedding-ada-002"). LLamaIndex calls this function from openai so it makes sense that we see the same error here. I have a gpt plus account and a normal one and I tried several api keys for this and they all give the same error. I am sure that the api key is correct bc when I change one letter from it, I also get an authentication error in addition to the ratelimit error. Do you know why this function is not working?
Are you running in colab? Or local machine?
local (jupyter notebook)
Does it work if you run it outside of notebook, like in a script?

I'll have to try a few things tomorrow, but it sounds more like something is just wonky with openai
I just copied the code and downloaded it as a python file then ran it in my terminal. It gives me the same error
Add a reply
Sign up and join the conversation on Discord