Connection error on embedding #17462
Replies: 1 comment 4 replies
-
I found some similar threads that might help you resolve the
Additionally, you can implement a retry mechanism using the from llama_index.embeddings.openai.utils import create_retry_decorator
import openai
# Define your retry decorator with desired parameters
retry_decorator = create_retry_decorator(
max_retries=5, # Number of retries
random_exponential=True, # Use random exponential backoff
stop_after_delay_seconds=30 # Maximum delay in seconds
)
# Use the retry decorator on your function that calls the OpenAI API
@retry_decorator
def call_openai_chat_method():
# Your code to call the OpenAI chat method
response = openai.ChatCompletion.create(
model="your-model",
messages=[{"role": "user", "content": "Hello, world!"}]
)
return response
# Call the function
try:
result = call_openai_chat_method()
print(result)
except openai.APIConnectionError as e:
print(f"Failed to connect to OpenAI API: {e}") This setup will attempt to reconnect to the OpenAI API in case of connection errors, using exponential backoff to manage the timing of retries [3]. To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Beta Was this translation helpful? Give feedback.
-
Hi,
Sunddenly my aplication started generate a error when I call the method chat from ChatEngine.
Retrying llama_index.embeddings.openai.base.OpenAIEmbedding._get_query_embedding.._retryable_get_embedding in 0.8407925745186211 seconds as it raised APIConnectionError: Connection error..
I already try reinstall all packages, run commands of certifieds (pip install --upgrade certifi), but no success.
Anyone could help me? Thank you in advance
Beta Was this translation helpful? Give feedback.
All reactions