Skip to content

Commit da350dc

Browse files
committed
feat(timeout): extend timeout duration for specific API endpoints
1 parent b3a702e commit da350dc

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

server/src/middleware/timeout_middleware.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ pub async fn timeout_15secs(
4848
timeout_secs = 300;
4949
}
5050

51+
if path == "/api/message"
52+
|| path == "/api/message/get_tool_function_params"
53+
|| path == "/api/chunk/generate"
54+
{
55+
timeout_secs = 120;
56+
}
57+
5158
match tokio::time::timeout(
5259
std::time::Duration::from_secs(timeout_secs),
5360
next.call(service_req),

server/src/operators/message_operator.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,9 +1353,9 @@ pub async fn stream_response(
13531353
});
13541354

13551355
let chat_completion_timeout = std::env::var("CHAT_COMPLETION_TIMEOUT_SECS")
1356-
.unwrap_or("60".to_string())
1356+
.unwrap_or("120".to_string())
13571357
.parse::<u64>()
1358-
.unwrap_or(60);
1358+
.unwrap_or(120);
13591359

13601360
let state = Arc::new(AtomicU16::new(0));
13611361
let documents = if create_message_req_payload
@@ -2699,9 +2699,9 @@ pub async fn stream_response_with_agentic_search(
26992699
});
27002700

27012701
let chat_completion_timeout = std::env::var("CHAT_COMPLETION_TIMEOUT_SECS")
2702-
.unwrap_or("60".to_string())
2702+
.unwrap_or("120".to_string())
27032703
.parse::<u64>()
2704-
.unwrap_or(60);
2704+
.unwrap_or(120);
27052705

27062706
let completion_stream = tokio_stream::wrappers::ReceiverStream::new(rx)
27072707
.take_until(tokio::time::sleep(std::time::Duration::from_secs(

0 commit comments

Comments
 (0)