diff --git a/crates/brightstaff/src/main.rs b/crates/brightstaff/src/main.rs index ca3d1771..e5933676 100644 --- a/crates/brightstaff/src/main.rs +++ b/crates/brightstaff/src/main.rs @@ -97,13 +97,13 @@ async fn main() -> Result<(), Box> { let router_service: Arc = Arc::new(RouterService::new( arch_config.model_providers.clone(), - llm_provider_url.clone() + CHAT_COMPLETIONS_PATH, - routing_model_name.clone(), - routing_llm_provider.clone(), + format!("{llm_provider_url}{CHAT_COMPLETIONS_PATH}"), + routing_model_name, + routing_llm_provider, )); let orchestrator_service: Arc = Arc::new(OrchestratorService::new( - llm_provider_url.clone() + CHAT_COMPLETIONS_PATH, + format!("{llm_provider_url}{CHAT_COMPLETIONS_PATH}"), PLANO_ORCHESTRATOR_MODEL_NAME.to_string(), )); diff --git a/crates/brightstaff/src/router/llm_router.rs b/crates/brightstaff/src/router/llm_router.rs index e99652d3..743630e6 100644 --- a/crates/brightstaff/src/router/llm_router.rs +++ b/crates/brightstaff/src/router/llm_router.rs @@ -61,7 +61,7 @@ impl RouterService { let router_model = Arc::new(router_model_v1::RouterModelV1::new( llm_routes, - routing_model_name.clone(), + routing_model_name, router_model_v1::MAX_TOKEN_LEN, )); diff --git a/crates/brightstaff/src/router/orchestrator_model_v1.rs b/crates/brightstaff/src/router/orchestrator_model_v1.rs index 5e308ecf..ef32db83 100644 --- a/crates/brightstaff/src/router/orchestrator_model_v1.rs +++ b/crates/brightstaff/src/router/orchestrator_model_v1.rs @@ -666,8 +666,7 @@ If no routes are needed, return an empty list for `route`. >(orchestrations_str) .unwrap(); let orchestration_model = "test-model".to_string(); - let orchestrator = - OrchestratorModelV1::new(agent_orchestrations, orchestration_model.clone(), 235); + let orchestrator = OrchestratorModelV1::new(agent_orchestrations, orchestration_model, 235); let conversation_str = r#" [ @@ -739,8 +738,7 @@ If no routes are needed, return an empty list for `route`. .unwrap(); let orchestration_model = "test-model".to_string(); - let orchestrator = - OrchestratorModelV1::new(agent_orchestrations, orchestration_model.clone(), 200); + let orchestrator = OrchestratorModelV1::new(agent_orchestrations, orchestration_model, 200); let conversation_str = r#" [ @@ -819,8 +817,7 @@ If no routes are needed, return an empty list for `route`. >(orchestrations_str) .unwrap(); let orchestration_model = "test-model".to_string(); - let orchestrator = - OrchestratorModelV1::new(agent_orchestrations, orchestration_model.clone(), 230); + let orchestrator = OrchestratorModelV1::new(agent_orchestrations, orchestration_model, 230); let conversation_str = r#" [ diff --git a/crates/brightstaff/src/router/router_model_v1.rs b/crates/brightstaff/src/router/router_model_v1.rs index 758cf83a..84680928 100644 --- a/crates/brightstaff/src/router/router_model_v1.rs +++ b/crates/brightstaff/src/router/router_model_v1.rs @@ -322,7 +322,7 @@ Based on your analysis, provide your response in the following JSON formats if y let llm_routes = serde_json::from_str::>>(routes_str).unwrap(); let routing_model = "test-model".to_string(); - let router = RouterModelV1::new(llm_routes, routing_model.clone(), usize::MAX); + let router = RouterModelV1::new(llm_routes, routing_model, usize::MAX); let conversation_str = r#" [ @@ -380,7 +380,7 @@ Based on your analysis, provide your response in the following JSON formats if y let llm_routes = serde_json::from_str::>>(routes_str).unwrap(); let routing_model = "test-model".to_string(); - let router = RouterModelV1::new(llm_routes, routing_model.clone(), usize::MAX); + let router = RouterModelV1::new(llm_routes, routing_model, usize::MAX); let conversation_str = r#" [ @@ -446,7 +446,7 @@ Based on your analysis, provide your response in the following JSON formats if y let llm_routes = serde_json::from_str::>>(routes_str).unwrap(); let routing_model = "test-model".to_string(); - let router = RouterModelV1::new(llm_routes, routing_model.clone(), 235); + let router = RouterModelV1::new(llm_routes, routing_model, 235); let conversation_str = r#" [ @@ -507,7 +507,7 @@ Based on your analysis, provide your response in the following JSON formats if y serde_json::from_str::>>(routes_str).unwrap(); let routing_model = "test-model".to_string(); - let router = RouterModelV1::new(llm_routes, routing_model.clone(), 200); + let router = RouterModelV1::new(llm_routes, routing_model, 200); let conversation_str = r#" [ @@ -567,7 +567,7 @@ Based on your analysis, provide your response in the following JSON formats if y let llm_routes = serde_json::from_str::>>(routes_str).unwrap(); let routing_model = "test-model".to_string(); - let router = RouterModelV1::new(llm_routes, routing_model.clone(), 230); + let router = RouterModelV1::new(llm_routes, routing_model, 230); let conversation_str = r#" [ @@ -634,7 +634,7 @@ Based on your analysis, provide your response in the following JSON formats if y let llm_routes = serde_json::from_str::>>(routes_str).unwrap(); let routing_model = "test-model".to_string(); - let router = RouterModelV1::new(llm_routes, routing_model.clone(), usize::MAX); + let router = RouterModelV1::new(llm_routes, routing_model, usize::MAX); let conversation_str = r#" [ @@ -703,7 +703,7 @@ Based on your analysis, provide your response in the following JSON formats if y let llm_routes = serde_json::from_str::>>(routes_str).unwrap(); let routing_model = "test-model".to_string(); - let router = RouterModelV1::new(llm_routes, routing_model.clone(), usize::MAX); + let router = RouterModelV1::new(llm_routes, routing_model, usize::MAX); let conversation_str = r#" [ diff --git a/crates/common/src/llm_providers.rs b/crates/common/src/llm_providers.rs index 120be691..a3ae93a0 100644 --- a/crates/common/src/llm_providers.rs +++ b/crates/common/src/llm_providers.rs @@ -14,7 +14,7 @@ impl LlmProviders { } pub fn default(&self) -> Option> { - self.default.as_ref().map(|rc| rc.clone()) + self.default.clone() } pub fn get(&self, name: &str) -> Option> { @@ -58,19 +58,21 @@ impl TryFrom> for LlmProviders { let name = llm_provider.name.clone(); if llm_providers .providers - .insert(name.clone(), llm_provider.clone()) + .insert(name.clone(), Rc::clone(&llm_provider)) .is_some() { return Err(LlmProvidersNewError::DuplicateName(name)); } // also add model_id as key for provider lookup - if llm_providers - .providers - .insert(llm_provider.model.clone().unwrap(), llm_provider) - .is_some() - { - return Err(LlmProvidersNewError::DuplicateName(name)); + if let Some(model) = llm_provider.model.clone() { + if llm_providers + .providers + .insert(model, llm_provider) + .is_some() + { + return Err(LlmProvidersNewError::DuplicateName(name)); + } } } Ok(llm_providers) diff --git a/crates/common/src/path.rs b/crates/common/src/path.rs index f11cb7b9..89a7b9be 100644 --- a/crates/common/src/path.rs +++ b/crates/common/src/path.rs @@ -20,13 +20,12 @@ pub fn replace_params_in_path( in_param = true; } else if c == '}' { in_param = false; - let param_name = current_param.clone(); - if let Some(value) = tool_params.get(¶m_name) { + if let Some(value) = tool_params.get(¤t_param) { let value = urlencoding::encode(value); query_string_replaced.push_str(value.into_owned().as_str()); - vars_replaced.insert(param_name.clone()); + vars_replaced.insert(current_param.clone()); } else { - return Err(format!("Missing value for parameter `{}`", param_name)); + return Err(format!("Missing value for parameter `{}`", current_param)); } current_param.clear(); } else if in_param { @@ -41,25 +40,22 @@ pub fn replace_params_in_path( let value = urlencoding::encode(value).into_owned(); if !vars_replaced.contains(param_name) { vars_replaced.insert(param_name.clone()); - params.insert(param_name.clone(), value.clone()); if query_string_replaced.contains("?") { query_string_replaced.push_str(&format!("&{}={}", param_name, value)); } else { query_string_replaced.push_str(&format!("?{}={}", param_name, value)); } + params.insert(param_name.clone(), value); } } // add default values for param in prompt_target_params.iter() { if !vars_replaced.contains(¶m.name) && param.default.is_some() { - params.insert(param.name.clone(), param.default.clone().unwrap()); + let default_val = param.default.as_ref().unwrap(); + params.insert(param.name.clone(), default_val.clone()); if query_string_replaced.contains("?") { - query_string_replaced.push_str(&format!( - "&{}={}", - param.name, - param.default.as_ref().unwrap() - )); + query_string_replaced.push_str(&format!("&{}={}", param.name, default_val)); } else { query_string_replaced.push_str(&format!( "?{}={}", @@ -117,7 +113,7 @@ mod test { Ok(( "/cluster.open-cluster-management.io/v1/managedclusters/test1".to_string(), "hello=hello%20world&country=US".to_string(), - out_params.clone() + out_params )) ); diff --git a/crates/llm_gateway/src/stream_context.rs b/crates/llm_gateway/src/stream_context.rs index 066fef7f..420a1035 100644 --- a/crates/llm_gateway/src/stream_context.rs +++ b/crates/llm_gateway/src/stream_context.rs @@ -894,7 +894,7 @@ impl HttpContext for StreamContext { }; let model_name = match self.llm_provider.as_ref() { - Some(llm_provider) => llm_provider.model.as_ref(), + Some(llm_provider) => llm_provider.model.clone(), None => None, }; @@ -903,7 +903,7 @@ impl HttpContext for StreamContext { // Apply model name resolution logic using the trait method let resolved_model = match model_name { - Some(model_name) => model_name.clone(), + Some(model_name) => model_name, None => { warn!( "[PLANO_REQ_ID:{}] MODEL_RESOLUTION_ERROR: no model specified | req_model='{}' provider='{}' config_model={:?}",