From 96e857a68249c934c9317e174f4e730d082734b0 Mon Sep 17 00:00:00 2001 From: Adil Hafeez Date: Fri, 21 Mar 2025 15:07:41 -0700 Subject: [PATCH] throw error if model name couldn't be determined --- crates/llm_gateway/src/stream_context.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/llm_gateway/src/stream_context.rs b/crates/llm_gateway/src/stream_context.rs index d51aba23..9f4b9d99 100644 --- a/crates/llm_gateway/src/stream_context.rs +++ b/crates/llm_gateway/src/stream_context.rs @@ -309,7 +309,18 @@ impl HttpContext for StreamContext { let model_requested = deserialized_body.model.clone(); if deserialized_body.model.is_empty() || deserialized_body.model.to_lowercase() == "none" { - deserialized_body.model = model_name.unwrap().to_string(); + deserialized_body.model = match model_name { + Some(model_name) => model_name.clone(), + None => { + self.send_server_error( + ServerError::BadRequest { + why: "No model specified in request and couldn't determine model name from arch_config".to_string(), + }, + Some(StatusCode::BAD_REQUEST), + ); + return Action::Continue; + } + } } debug!(