mirror of
https://github.com/katanemo/plano.git
synced 2026-05-27 14:17:15 +02:00
fix: make upstream timeout configurable, default to 300s
This commit is contained in:
parent
198c912202
commit
0c7b999770
6 changed files with 34 additions and 12 deletions
|
|
@ -84,6 +84,7 @@ pub struct Overrides {
|
|||
pub prompt_target_intent_matching_threshold: Option<f64>,
|
||||
pub optimize_context_window: Option<bool>,
|
||||
pub use_agent_orchestrator: Option<bool>,
|
||||
pub upstream_timeout_ms: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ pub const SYSTEM_ROLE: &str = "system";
|
|||
pub const USER_ROLE: &str = "user";
|
||||
pub const TOOL_ROLE: &str = "tool";
|
||||
pub const ASSISTANT_ROLE: &str = "assistant";
|
||||
pub const ARCH_FC_REQUEST_TIMEOUT_MS: u64 = 30000; // 30 seconds
|
||||
pub const DEFAULT_TARGET_REQUEST_TIMEOUT_MS: u64 = 30000; // 30 seconds
|
||||
pub const API_REQUEST_TIMEOUT_MS: u64 = 30000; // 30 seconds
|
||||
pub const MODEL_SERVER_REQUEST_TIMEOUT_MS: u64 = 30000; // 30 seconds
|
||||
pub const ARCH_FC_REQUEST_TIMEOUT_MS: u64 = 300_000; // 300 seconds
|
||||
pub const DEFAULT_TARGET_REQUEST_TIMEOUT_MS: u64 = 300_000; // 300 seconds
|
||||
pub const API_REQUEST_TIMEOUT_MS: u64 = 300_000; // 300 seconds
|
||||
pub const MODEL_SERVER_REQUEST_TIMEOUT_MS: u64 = 300_000; // 300 seconds
|
||||
pub const MODEL_SERVER_NAME: &str = "bright_staff";
|
||||
pub const ARCH_ROUTING_HEADER: &str = "x-arch-llm-provider";
|
||||
pub const MESSAGES_KEY: &str = "messages";
|
||||
|
|
|
|||
|
|
@ -205,7 +205,12 @@ impl HttpContext for StreamContext {
|
|||
info!("on_http_request_body: sending request to model server");
|
||||
debug!("request body: {}", json_data);
|
||||
|
||||
let timeout_str = MODEL_SERVER_REQUEST_TIMEOUT_MS.to_string();
|
||||
let timeout_ms = if let Some(overrides) = self.overrides.as_ref() {
|
||||
overrides.upstream_timeout_ms.unwrap_or(MODEL_SERVER_REQUEST_TIMEOUT_MS)
|
||||
} else {
|
||||
MODEL_SERVER_REQUEST_TIMEOUT_MS
|
||||
};
|
||||
let timeout_str = timeout_ms.to_string();
|
||||
|
||||
let mut headers = vec![
|
||||
(ARCH_UPSTREAM_HOST_HEADER, MODEL_SERVER_NAME),
|
||||
|
|
@ -230,7 +235,7 @@ impl HttpContext for StreamContext {
|
|||
headers,
|
||||
Some(json_data.as_bytes()),
|
||||
vec![],
|
||||
Duration::from_secs(5),
|
||||
Duration::from_millis(timeout_ms),
|
||||
);
|
||||
|
||||
if let Some(content) = self.user_prompt.as_ref().unwrap().content.as_ref() {
|
||||
|
|
|
|||
|
|
@ -171,7 +171,14 @@ impl StreamContext {
|
|||
callout_context.request_body.messages.clone(),
|
||||
);
|
||||
let arch_messages_json = serde_json::to_string(¶ms).unwrap();
|
||||
let timeout_str = DEFAULT_TARGET_REQUEST_TIMEOUT_MS.to_string();
|
||||
let timeout_ms = if let Some(overrides) = self.overrides.as_ref() {
|
||||
overrides
|
||||
.upstream_timeout_ms
|
||||
.unwrap_or(DEFAULT_TARGET_REQUEST_TIMEOUT_MS)
|
||||
} else {
|
||||
DEFAULT_TARGET_REQUEST_TIMEOUT_MS
|
||||
};
|
||||
let timeout_str = timeout_ms.to_string();
|
||||
|
||||
let mut headers = vec![
|
||||
(":method", "POST"),
|
||||
|
|
@ -193,7 +200,7 @@ impl StreamContext {
|
|||
headers,
|
||||
Some(arch_messages_json.as_bytes()),
|
||||
vec![],
|
||||
Duration::from_secs(5),
|
||||
Duration::from_millis(timeout_ms),
|
||||
);
|
||||
callout_context.response_handler_type = ResponseHandlerType::DefaultTarget;
|
||||
callout_context.prompt_target_name = Some(default_prompt_target.name.clone());
|
||||
|
|
@ -422,7 +429,12 @@ impl StreamContext {
|
|||
|
||||
debug!("on_http_call_response: api call body {:?}", api_call_body);
|
||||
|
||||
let timeout_str = API_REQUEST_TIMEOUT_MS.to_string();
|
||||
let timeout_ms = if let Some(overrides) = self.overrides.as_ref() {
|
||||
overrides.upstream_timeout_ms.unwrap_or(API_REQUEST_TIMEOUT_MS)
|
||||
} else {
|
||||
API_REQUEST_TIMEOUT_MS
|
||||
};
|
||||
let timeout_str = timeout_ms.to_string();
|
||||
|
||||
let http_method_str = http_method.to_string();
|
||||
let mut headers: HashMap<_, _> = [
|
||||
|
|
@ -457,7 +469,7 @@ impl StreamContext {
|
|||
headers.into_iter().collect(),
|
||||
api_call_body.as_deref().map(|s| s.as_bytes()),
|
||||
vec![],
|
||||
Duration::from_secs(5),
|
||||
Duration::from_millis(timeout_ms),
|
||||
);
|
||||
|
||||
info!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue