Skip to content

Commit 7cc6148

Browse files
committed
mito-ai: only set timeout on non testing:
1 parent a35da90 commit 7cc6148

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

mito-ai/mito_ai/utils/open_ai_utils.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,20 @@ async def get_ai_completion_from_mito_server(
110110
"Content-Type": "application/json",
111111
}
112112

113-
# The HTTP client timesout after 20 seconds by default. We update this to match the timeout
114-
# we give to OpenAI. The OpenAI timeouts are denoted in seconds, wherease the HTTP client
115-
# expects milliseconds. We also give the HTTP client a 10 second buffer to account for
116-
# the time it takes to send the request, etc.
117-
http_client_timeout = timeout * 1000 * max_retries + 10000
118113

119-
# If we are running in a test environment, we want a short timeout to prevent tests from hanging
120-
# for too long, but still give enough time for simple responses.
114+
121115
if is_running_test():
122-
# Increase timeout specifically for CI environments to prevent kernel shutdown issues
123-
# CI environments tend to be slower and need more time to process requests
124-
http_client_timeout = 60000 # 60 seconds for CI tests
125-
126-
http_client = AsyncHTTPClient(defaults=dict(user_agent="Mito-AI client"), request_timeout=http_client_timeout)
116+
# If we are running in a test environment, setting the request_timeout fails for some reason.
117+
http_client = AsyncHTTPClient(defaults=dict(user_agent="Mito-AI client"))
118+
else:
119+
120+
# The HTTP client timesout after 20 seconds by default. We update this to match the timeout
121+
# we give to OpenAI. The OpenAI timeouts are denoted in seconds, wherease the HTTP client
122+
# expects milliseconds. We also give the HTTP client a 10 second buffer to account for
123+
# the time it takes to send the request, etc.
124+
http_client_timeout = timeout * 1000 * max_retries + 10000
125+
http_client = AsyncHTTPClient(defaults=dict(user_agent="Mito-AI client"), request_timeout=http_client_timeout)
126+
127127
try:
128128
res = await http_client.fetch(
129129
# Important: DO NOT CHANGE MITO_AI_URL. If you want to use the dev endpoint,

0 commit comments

Comments
 (0)