The community member is using Google Vertex AI API as an LLM and HF embedding, and they are trying to retrieve the stored files using load_index_from_storage. However, they are encountering an error related to the OpenAI API key. The community members discuss that the service context needs to have the llm_predictor object pointing to the Google Vertex class, and that the service context needs to be passed when loading the indexes as well. The solution provided is to change the code to index = load_index_from_storage(storage_context=storage_context, service_context=service_context), which resolves the issue.
i am using Google Vertex AI API as LLM and using HF embedding. After completing the embedding and the file stored on local drive. i try to retrive those file using following instructions:
index = load_index_from_storage(storage_context=storage_context)
and got follow error: --------------------------------------------------------------------------- ValidationError Traceback (most recent call last) <ipython-input-12-a5b638486930> in <cell line: 4>() 2 storage_context = StorageContext.from_defaults(persist_dir='/content/drive/MyDrive/data/vectordb') 3 # load index ----> 4 index = load_index_from_storage(storage_context=storage_context)
7 frames /usr/local/lib/python3.10/dist-packages/pydantic/main.cpython-310-x86_64-linux-gnu.so in pydantic.main.BaseModel.init()
ValidationError: 1 validation error for OpenAI root 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)
How i can setup load_index_from_storage and not using OPENAI as default ? thx.
Yea. I did it. there is no issue if I directly use the index after index file being generated in memory. But facing issue if I save the file locally and load them again. I feel there is a bug in that load_index_from_storage and use openai as default and didn't consider other llm and embedding tool will be used.
you are correct. after i changing the code as: index = load_index_from_storage(storage_context=storage_context,service_context=service_context) it works now. thanks.