diff --git a/Dockerfile b/Dockerfile index 8a0ab81e..b3313856 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # build docker image for arch gateway -FROM rust:1.92.0 AS builder +FROM rust:1.93.0 AS builder RUN rustup -v target add wasm32-wasip1 WORKDIR /arch COPY crates . diff --git a/crates/common/src/path.rs b/crates/common/src/path.rs index 89a7b9be..fbcfa7cc 100644 --- a/crates/common/src/path.rs +++ b/crates/common/src/path.rs @@ -51,17 +51,14 @@ pub fn replace_params_in_path( // add default values for param in prompt_target_params.iter() { - if !vars_replaced.contains(¶m.name) && param.default.is_some() { - 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, default_val)); - } else { - query_string_replaced.push_str(&format!( - "?{}={}", - param.name, - param.default.as_ref().unwrap() - )); + if !vars_replaced.contains(¶m.name) { + if let Some(default_val) = ¶m.default { + params.insert(param.name.clone(), default_val.clone()); + if query_string_replaced.contains("?") { + query_string_replaced.push_str(&format!("&{}={}", param.name, default_val)); + } else { + query_string_replaced.push_str(&format!("?{}={}", param.name, default_val)); + } } } } diff --git a/crates/hermesllm/src/providers/streaming_response.rs b/crates/hermesllm/src/providers/streaming_response.rs index 9fc83065..66ccc735 100644 --- a/crates/hermesllm/src/providers/streaming_response.rs +++ b/crates/hermesllm/src/providers/streaming_response.rs @@ -327,8 +327,7 @@ impl TryFrom<(SseEvent, &SupportedAPIsFromClient, &SupportedUpstreamAPIs)> for S } // If has data, parse the data as a provider stream response (business logic layer) - if transformed_event.data.is_some() { - let data_str = transformed_event.data.as_ref().unwrap(); + if let Some(data_str) = &transformed_event.data { let data_bytes = data_str.as_bytes(); let transformed_response: ProviderStreamResponseType = ProviderStreamResponseType::try_from((data_bytes, client_api, upstream_api))?; diff --git a/crates/prompt_gateway/src/http_context.rs b/crates/prompt_gateway/src/http_context.rs index 1b6afbab..d3cde081 100644 --- a/crates/prompt_gateway/src/http_context.rs +++ b/crates/prompt_gateway/src/http_context.rs @@ -216,12 +216,12 @@ impl HttpContext for StreamContext { ("x-envoy-upstream-rq-timeout-ms", timeout_str.as_str()), ]; - if self.request_id.is_some() { - headers.push((REQUEST_ID_HEADER, self.request_id.as_ref().unwrap())); + if let Some(request_id) = &self.request_id { + headers.push((REQUEST_ID_HEADER, request_id)); } - if self.traceparent.is_some() { - headers.push((TRACE_PARENT_HEADER, self.traceparent.as_ref().unwrap())); + if let Some(traceparent) = &self.traceparent { + headers.push((TRACE_PARENT_HEADER, traceparent)); } let call_args = CallArgs::new( diff --git a/crates/prompt_gateway/src/stream_context.rs b/crates/prompt_gateway/src/stream_context.rs index 5f464930..cebd689f 100644 --- a/crates/prompt_gateway/src/stream_context.rs +++ b/crates/prompt_gateway/src/stream_context.rs @@ -183,8 +183,8 @@ impl StreamContext { ("x-envoy-upstream-rq-timeout-ms", timeout_str.as_str()), ]; - if self.request_id.is_some() { - headers.push((REQUEST_ID_HEADER, self.request_id.as_ref().unwrap())); + if let Some(request_id) = &self.request_id { + headers.push((REQUEST_ID_HEADER, request_id)); } let call_args = CallArgs::new( @@ -437,12 +437,12 @@ impl StreamContext { .into_iter() .collect(); - if self.request_id.is_some() { - headers.insert(REQUEST_ID_HEADER, self.request_id.as_ref().unwrap()); + if let Some(request_id) = &self.request_id { + headers.insert(REQUEST_ID_HEADER, request_id); } - if self.traceparent.is_some() { - headers.insert(TRACE_PARENT_HEADER, self.traceparent.as_ref().unwrap()); + if let Some(traceparent) = &self.traceparent { + headers.insert(TRACE_PARENT_HEADER, traceparent); } // override http headers that are set in the prompt target @@ -648,7 +648,15 @@ impl StreamContext { } pub fn generate_tool_call_message(&mut self) -> Message { - if self.arch_fc_response.is_none() { + if let Some(arch_fc_response) = &self.arch_fc_response { + Message { + role: ASSISTANT_ROLE.to_string(), + content: Some(ContentType::Text(arch_fc_response.clone())), + model: Some(ARCH_FC_MODEL_NAME.to_string()), + tool_calls: None, + tool_call_id: None, + } + } else { info!("arch_fc_response is none, generating tool call message"); Message { role: ASSISTANT_ROLE.to_string(), @@ -657,16 +665,6 @@ impl StreamContext { tool_calls: self.tool_calls.clone(), tool_call_id: None, } - } else { - Message { - role: ASSISTANT_ROLE.to_string(), - content: Some(ContentType::Text( - self.arch_fc_response.as_ref().unwrap().clone(), - )), - model: Some(ARCH_FC_MODEL_NAME.to_string()), - tool_calls: None, - tool_call_id: None, - } } }