axiom-of-choice / LLM-Chatbot

Build a Chatbot in Streamlit to perform Generative QA with indexed documents in a Vector DB as knowledge base
https://llm-chatbot-rbjv6s9pz7kcjrjwd4clwm.streamlit.app
MIT License
6 stars 1 forks source link

Corhere Connection Error #36

Closed sainisanjay closed 8 months ago

sainisanjay commented 8 months ago

CohereConnectionError: HTTPSConnectionPool(host='api.cohere.ai', port=443): Max retries exceeded with url: /v1/embed (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f34adf03700>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))

File "/home/saini/anaconda3/envs/ml/lib/python3.9/site-packages/cohere/client.py", line 372, in <lambda>
    for result in self._executor.map(lambda json_body: self._request(cohere.EMBED_URL, json=json_body), json_bodys):
  File "/home/saini/anaconda3/envs/ml/lib/python3.9/site-packages/cohere/client.py", line 744, in _request
    raise CohereConnectionError(str(e)) from e
cohere.error.CohereConnectionError: HTTPSConnectionPool(host='api.cohere.ai', port=443): Max retries exceeded with url: /v1/embed (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f34adf03700>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))

@axiom-of-choice Could you please help me on the issue? Is this is a API issue or something else? Error Logs: info.log

error.log

.csv file which i am loading

test.csv

axiom-of-choice commented 8 months ago

The issue was with Pinecone index, are you using it?

Maybe te host is wrong. You must configure that in your .env

PINECONE_INDEX_NAME = "indexname" PINECONE_ENV = "emv" along with the Pinecone API Key

https://app.pinecone.io/

Also Make sure you added COHERE_API_KEY

sainisanjay commented 8 months ago

@axiom-of-choice I updated the .env file:

## Index and Model Data
# EMBEDDING_MODEL_NAME = "sentence-transformers/all-MiniLM-L6-v2"
HF_EMBEDDING_MODEL_NAME = "sentence-transformers/stsb-xlm-r-multilingual"
PINECONE_INDEX_NAME = "test"
PINECONE_ENV = "gcp-starter"
COHERE_EMBEDDING_MODEL_NAME = ""

I am using Free Tier account in Pinecone.

Pinecone

Still getting error

urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/saini/workspace/TNS-LLM-Chatbot/pages/main_page.py", line 101, in upload_file
    parse(
  File "/home/saini/workspace/TNS-LLM-Chatbot/src/data/cohere_parser.py", line 216, in parse
    insert_embedded_documents(documents=documents, embeddings=embeddings, index=index, data_source=data_source)
  File "/home/saini/workspace/TNS-LLM-Chatbot/src/data/cohere_parser.py", line 192, in insert_embedded_documents
    index.upsert(vectors=zip(ids, embeds, metadatas))
  File "/home/saini/anaconda3/envs/ml/lib/python3.9/site-packages/pinecone/core/utils/error_handling.py", line 25, in inner_func
    raise PineconeProtocolError(f'Failed to connect; did you specify the correct index name?') from e
pinecone.core.exceptions.PineconeProtocolError: Failed to connect; did you specify the correct index name?

Error Logs error.log

axiom-of-choice commented 8 months ago

I think the env is wrong. For some reason, the console of pinecone does not show the correct one. Could you try with something like this PINECONE_ENV = "us-central1-gcp-starter" (Matching yours)

Screenshot 2023-10-26 at 9 04 45 a m

sainisanjay commented 8 months ago

@axiom-of-choice I am not really sure whats going on wrong. I followed your suggestion but still same error:

PINECONE_ENV = "us-central1-gcp-starter"

Pin

.env file: env

axiom-of-choice commented 8 months ago

Something weird is happening. If you take a look at your pinecone console, you can see that is actually a query activity in the exact moment you start the application and try to upload a document. Screenshot 2023-10-26 at 9 41 05 a m

axiom-of-choice commented 8 months ago

I'll try to find a fix and post it

sainisanjay commented 8 months ago

Something weird is happening. If you take a look at your pinecone console, you can see that is actually a query activity in the exact moment you start the application and try to upload a document. Screenshot 2023-10-26 at 9 41 05 a m

Right i can see it has query activity while i try to upload the file. But unfortunately i am not able to figure-out whats wrong. Still i am getting same error.

sainisanjay commented 8 months ago

I'll try to find a fix and post it

Looking forward to have some fix.

axiom-of-choice commented 8 months ago

@sainisanjay I found the error. It is in the .env file. You might need to change the following. Rename PINECONE_ENV to PINECONE_ENVIRONMENT Also, make sure this env variable has this value. COHERE_EMBEDDING_MODEL_NAME = "embed-multilingual-v2.0"

Let me know if this works so I close the issue. I also added a commit into Develop to fix this.

sainisanjay commented 8 months ago

@axiom-of-choice I incorporated your suggestions but unfortunately error still persist: However, this time not the indexing error it is MaxRetryError.

raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='chat-unknown.svc.us-central1-gcp-starter.pinecone.io', port=443): Max retries exceeded with url: /vectors/upsert (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f8900fd96a0>: Failed to establish a new connection: [Errno -2] Name or service not known'))

Error Logs: error.log

.env file env

axiom-of-choice commented 8 months ago

@sainisanjay The PINECONE_ENVIRONMENT value should be only "gcp-starter"

sainisanjay commented 8 months ago

Thanks a lot @axiom-of-choice its working now. I am closing this issue now.