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?
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?
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
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?
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