Find answers from the community

Updated 3 months ago

@WhiteFang_Jr @Logan M ```from llama_

Plain Text
from llama_index.retrievers import RecursiveRetriever

# note: can pass `agents` dict as `query_engine_dict` since every agent can be used as a query engine
recursive_retriever = RecursiveRetriever(
    "vector",
    retriever_dict={"vector": index_retriever, **retriever_dict},
    # query_engine_dict=query_engine_dict,
    verbose=True,
)
Plain Text
os.environ["OPENAI_API_KEY"] = "" nodes = recursive_retriever.retrieve("Tell me about some issues on 12/11")

print(f"Number of source nodes: {len(nodes)}")
nodes[0].node.metadata
gives error:
Plain Text
Retrieving with query id None: Tell me about some issues on 12/11
---------------------------------------------------------------------------
AuthenticationError                       Traceback (most recent call last)
<ipython-input-57-e465b1a12d99> in <cell line: 1>()
----> 1 nodes = recursive_retriever.retrieve("Tell me about some issues on 12/11")
      2 
      3 print(f"Number of source nodes: {len(nodes)}")
      4 nodes[0].node.metadata

15 frames
/usr/local/lib/python3.10/dist-packages/openai/_base_client.py in _request(self, cast_to, options, remaining_retries, stream, stream_cls)
    928                 err.response.read()
    929 
--> 930             raise self._make_status_error_from_response(err.response) from None
    931 
    932         return self._process_response(

AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-NgwJh***************************************ViNP. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}
L
a
7 comments
openai.api_key = openai_key does not do anything anymore in the latest openai client I think

os.environ["OPENAI_API_KEY"] = "sk-...." -- this should be at the start of your script, before loading anything πŸ€”
yes i have this
#Setup OPEN API Key
os.environ["OPENAI_API_KEY"] = ""
@Logan M but still the same error and the openai key is something different than what i have in the error
Maybe try restarting the notebook? Seems like it might be picking up a different key from somewhere
let me try, i will keep you updated
Add a reply
Sign up and join the conversation on Discord