project set up
Closed this issue · 2 comments
I'm facing a few issues setting up and getting the following error when running the app.py script
-Chatbot-using-Llama-2 % python app.py
Traceback (most recent call last):
File "/Users/eugvuong/Desktop/Medical-Chatbot/Medical-Chatbot-using-Llama-2/app.py", line 47, in
docsearch=pinecone.Pinecone.Index((index_name), embeddings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/eugvuong/Desktop/Medical-Chatbot/virt_env/lib/python3.11/site-packages/pinecone/control/pinecone.py", line 622, in Index
pt = kwargs.pop('pool_threads', None) or self.pool_threads
^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'pool_threads'
I also noticed every time you run the script, it will create a index in pinecone but this causes issues if the index is already created
File "/Users/eugvuong/Desktop/Medical-Chatbot/virt_env/lib/python3.11/site-packages/pinecone/core/client/rest.py", line 261, in request
raise PineconeApiException(http_resp=r)
pinecone.core.client.exceptions.PineconeApiException: (409)
Reason: Conflict
HTTP response headers: HTTPHeaderDict({'content-type': 'text/plain; charset=utf-8', 'access-control-allow-origin': '', 'vary': 'origin,access-control-request-method,access-control-request-headers', 'access-control-expose-headers': '', 'X-Cloud-Trace-Context': '34f1bc846da265c72a6b8b96b070b47e', 'Date': 'Wed, 17 Apr 2024 09:35:43 GMT', 'Server': 'Google Frontend', 'Content-Length': '85', 'Via': '1.1 google', 'Alt-Svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000'})
HTTP response body: {"error":{"code":"ALREADY_EXISTS","message":"Resource already exists"},"status":409}
wouldn't this cause issues if you want to re-run the project?
No, as the main script is app.py, it contains a method from 'from_existing_index' that takes the embeddings from existing index.
Do initialize your Pinecone credentials properly
Thanks Kaylan, I've set up an API key from pinecone console and added the key into an .env file. But when running app.py I get the following error.
AttributeError: init is no longer a top-level attribute of the pinecone package.
Please create an instance of the Pinecone class instead.
so I've changed the code to the following
index_name="medichat"
if PINECONE_API_KEY is None:
print("PINECONE_API_KEY is None")
else:
pc = pinecone.Pinecone(api_key='******************')
# Creates an index using the API key stored in the client 'pc'.
pc.create_index(
name=index_name,
dimension=3, # Replace with your model dimensions
metric="euclidean", # Replace with your model metric
spec=ServerlessSpec(
cloud="aws",
region="us-west-2"
)
)
This then led me to getting the AttributeError