This code works fine in windows but the same fails in Linux. I get
RetryError[<Future at 0x7f75dfcc6fb0 state=finished raised AuthenticationError>]
error in linux.
I have no idea why this is the case.
from llama_index import SimpleDirectoryReader, GPTVectorStoreIndex, MockLLMPredictor, StorageContext, load_index_from_storage, ServiceContext
from llama_index.storage.index_store import SimpleIndexStore
from llama_index.vector_stores import SimpleVectorStore
from llama_index.storage.docstore import SimpleDocumentStore
import os
os.environ['OPENAI_API_KEY'] = 'openapi_key'
class LLamaIndexEngine:
def __init__(self):
# Setup service context
self.storage_context = StorageContext.from_defaults(
index_store=SimpleIndexStore.from_persist_dir('csvindex'),
vector_store=SimpleVectorStore.from_persist_dir('csvindex'),
docstore=SimpleDocumentStore.from_persist_dir('csvindex')
)
print(self.storage_context.to_dict())
# self.service_context = ServiceContext.from_defaults(llm_predictor=self.llm_predictor, storage_context=self.storage_context)
self.index = load_index_from_storage(storage_context=self.storage_context)
self.query_engine = self.index.as_query_engine(top_k=3)
def query(self, query):
res = self.query_engine.query(query)
print(res)
return str(res)
if __name__=='__main__':
try:
engine = LLamaIndexEngine()
print(engine.query('give best dishes.'))
except(Exception) as e:
print(e)