Skip to main content

To use Pinecone, OpenAI and a language model chain to answer questions in documents

Overview of the elements

Set Up API Keys

  • Obtain API keys for Pinecone and OpenAI.
  • Store the keys securely. Consider using a credentials.py file (as mentioned in a previous response).

 

Install Required Libraries

Install the necessary Python libraries, such as Pinecone's Python client (pinecone-client) and OpenAI's Python client (openai).

Solved: RuntimeError: Directory 'static/' does not exist

The error message "RuntimeError: Directory 'static/' does not exist" typically indicates that your Python code is trying to access a directory named "static," but this directory doesn't exist in the current working directory or the specified path.

To resolve this issue, you can follow these steps:

 

Python - Openai using CharacterTextSplitter

It seems like you're using the CharacterTextSplitter class from the tiktoken library to split text into chunks. The CharacterTextSplitter.from_tiktoken_encoder() method is used to create an instance of the CharacterTextSplitter class with specific configuration settings.

 

Retrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry

OpenAI request timeout?

Retrying langchain.chat_models.openai.ChatOpenAI.completion_with_retry.<locals>._completion_with_retry in 4.0 seconds as it raised ServiceUnavailableError: The server is overloaded or not ready yet..

Try increasing the timeout parameter.  For example, 

llm = ChatOpenAI(temperature=0, model_name=model)

Change to

Solving the errors in running Open AI on Ubuntu

While the default version on Ubuntu 20.04 for Python is 3.8, I've added Python 3.11.5 (latest version).

Errors

GPTSimpleVectorIndex is deprecated

Attempting to run python3.11 model-ai.py and I'm seeing the following response

Subscribe to Open AI