Skip to content

The agent engineering platform.

chat_models.openai: Set tenacity timeout to openai's recommendation (#2768)

rafael1cc7ea333c0a
diff --git a/langchain/chat_models/openai.py b/langchain/chat_models/openai.py
index 69e3f9fd2a..644ed261dc 100644
--- a/langchain/chat_models/openai.py
+++ b/langchain/chat_models/openai.py
@@ -32,8 +32,8 @@ logger = logging.getLogger(__file__)
def _create_retry_decorator(llm: ChatOpenAI) -> Callable[[Any], Any]:
import openai
- min_seconds = 4
- max_seconds = 10
+ min_seconds = 1
+ max_seconds = 60
# Wait 2^x * 1 second between each retry starting with
# 4 seconds, then up to 10 seconds, then 10 seconds afterwards
return retry(
@@ -199,8 +199,8 @@ class ChatOpenAI(BaseChatModel):
def _create_retry_decorator(self) -> Callable[[Any], Any]:
import openai
- min_seconds = 4
- max_seconds = 10
+ min_seconds = 1
+ max_seconds = 60
# Wait 2^x * 1 second between each retry starting with
# 4 seconds, then up to 10 seconds, then 10 seconds afterwards
return retry(