Request_timeout

How to setup on API request_timeout, in case of no answer from the API for XXX seconds.

You can add this as a custom method on the SDK. Automatically though there should be a timeout on the API endpoints since Pinecone is a hosted service so they probably have a pretty standard timeout already set if the connection remains open too long.

Given that the service is hosted though your reads and upserts should be fairly quick. I have never had latency issues prior. However, if you want to run a timeout you can do this with a timeout for both python and JS.

Python:

r = requests.get("MYURL.com", timeout=10) # 10 seconds

Javascript:

 const res = await fetch(url, { signal: AbortSignal.timeout(5000) }); // 5 second timeout

These are examples that would hit the URL endpoint directly, but you can do the same by forking the SDK and building your own or just wrapping the SDK method in a timeout and aborting if it goes over.

Hi Tim

I’m facing timeouts in about 5% of my Pinecone queries and need help.
I didn’t understand your previous instructions on setting timeouts in Python. How do I add a timeout to my existing query structure which uses parameters like query_vector, top_k, and namespace? An example with mu url would be really helpful.

check this log. - 17 min timeout

Nov 28 06:23:20 BotiyServer gunicorn[154945]: 2023-11-28 06:23:20,703 - src.core_bot - INFO - chat_with_bot:98 - Querying Pinecone for relevant chunks Nov 28 06:23:20 BotiyServer gunicorn[154945]: INFO:src.core_bot:Querying Pinecone for relevant chunks Nov 28 06:23:20 BotiyServer gunicorn[154945]: 2023-11-28 06:23:20,703 - src.api - INFO - log_it:40 - Starting call to ‘src.decorators.log_runtime..wrapper’, this is the 1st time calling it. Nov 28 06:23:20 BotiyServer gunicorn[154945]: INFO:src.api:Starting call to ‘src.decorators.log_runtime..wrapper’, this is the 1st time calling it. Nov 28 06:23:20 BotiyServer gunicorn[154945]: 2023-11-28 06:23:20,704 - src.api - INFO - get_embedding:24 - Starting get_embedding API call. Nov 28 06:23:20 BotiyServer gunicorn[154945]: INFO:src.api:Starting get_embedding API call. Nov 28 06:23:20 BotiyServer gunicorn[154945]: 2023-11-28 06:23:20,820 - src.api - INFO - get_embedding:34 - Completed get_embedding API call. Nov 28 06:23:20 BotiyServer gunicorn[154945]: INFO:src.api:Completed get_embedding API call. Nov 28 06:23:20 BotiyServer gunicorn[154945]: 2023-11-28 06:23:20,821 - src.decorators - DEBUG - wrapper:16 - Function ‘get_embedding’ executed in 0.116852 seconds. Nov 28 06:23:20 BotiyServer gunicorn[154945]: DEBUG:src.decorators:Function ‘get_embedding’ executed in 0.116852 seconds. Nov 28 06:23:20 BotiyServer gunicorn[154945]: 2023-11-28 06:23:20,821 - src.LLMutils - INFO - query_pinecone:112 - Starting pinecone - index.query: <pinecone.index.Index object at 0x7fb812fd4d30> Nov 28 06:23:20 BotiyServer gunicorn[154945]: INFO:src.LLMutils:Starting pinecone - index.query: <pinecone.index.Index object at 0x7fb812fd4d30> Nov 28 06:23:20 BotiyServer gunicorn[154945]: 2023-11-28 06:23:20,821 - src.api - INFO - log_it:40 - Starting call to ‘src.api.pinecone_api_call’, this is the 1st time calling it. Nov 28 06:23:20 BotiyServer gunicorn[154945]: INFO:src.api:Starting call to ‘src.api.pinecone_api_call’, this is the 1st time calling it. Nov 28 06:39:59 BotiyServer gunicorn[154945]: 2023-11-28 06:39:59,847 - src.api - WARNING - log_retry_attempt:17 - Retry attempt 1 due to: Failed to connect; did you specify the correct index name? Nov 28 06:39:59 BotiyServer gunicorn[154945]: WARNING:src.api:Retry attempt 1 due to: Failed to connect; did you specify the correct index name? Nov 28 06:40:01 BotiyServer gunicorn[154945]: 2023-11-28 06:40:01,850 - src.api - INFO - log_it:40 - Starting call to ‘src.api.pinecone_api_call’, this is the 2nd time calling it. Nov 28 06:40:01 BotiyServer gunicorn[154945]: INFO:src.api:Starting call to ‘src.api.pinecone_api_call’, this is the 2nd time calling it. Nov 28 06:40:02 BotiyServer gunicorn[154945]: 2023-11-28 06:40:02,393 - src.LLMutils - INFO - query_pinecone:121 - Pinecone Query Response: {‘matches’: [{‘id’: ‘64f04582c0a431981dba0336_3’, Nov 28 06:40:02 BotiyServer gunicorn[154945]: ‘score’: 0.748406529, Nov 28 06:40:02 BotiyServer gunicorn[154945]: ‘values’: }, Nov 28 06:40:02 BotiyServer gunicorn[154945]: {‘id’: ‘64f04582c0a431981dba0336_4’, Nov 28 06:40:02 BotiyServer gunicorn[154945]: ‘score’: 0.743082583, Nov 28 06:40:02 BotiyServer gunicorn[154945]: ‘values’: }], Nov 28 06:40:02 BotiyServer gunicorn[154945]: ‘namespace’: ‘64f04582c0a431981dba0336’}

Ori Shohat

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.