0

I was using an old version of llama_index for a while, I just updated the package and a lot of syntax changed... I am currently trying to use Pinecode for vector indexes and OpenAI for embeddings and completion. This is my code:

with open(file_path, 'r', encoding='utf-8') as file:
    content = file.read()

chunk_size = 1000
texts = [content[i:i+chunk_size] for i in range(0, len(content), chunk_size)]

embeddings = LangchainEmbedding(OpenAIEmbeddings(model="text-embedding-ada-002", chunk_size=1))

pinecone_index = pinecone.Index(index_name)

vector_store = PineconeVectorStore(pinecone_index=pinecone_index)
docs = [Document(t) for t in texts]

storage_context = StorageContext.from_defaults(vector_store=vector_store)
service_context = ServiceContext.from_defaults(embed_model=embeddings)

index = GPTVectorStoreIndex.from_documents(docs, storage_context=storage_context, service_context=service_context)
query_engine = index.as_query_engine()

response = query_engine.query(query)

Last line generate this error: "openai.error.InvalidRequestError: Must provide an 'engine' or 'deployment_id' parameter to create a <class 'openai.api_resources.completion.Completion'>" I don't exactly know how to solve this, I did not find any solution in the documentation that solve this issue with my current code. Any ideas around ? Thank you in advance !

(PS: I tried to add and modify a lot of parameters at different steps of the process, but none of them seems to solve my problem there. My environment is correcly setup also.)

1 Answers1

0

It seems you have some problems on the configuration of OpenAI API version and deployment model. I guess you need to specify a LLM model too. Not just an embedding model.

I suggest you to fill in the parameter llm_predictor within ServiceContext. Where you can specify the above two values with the llm parameter of the ChatGPTLLMPredictor object.

reference: https://clemenssiebler.com/posts/using-llamaindex-with-turbo-and-azure-openai-service/

simcheuk
  • 11
  • 1