From 2895a070882b1cbd8a7612ff2a5047247dd04350 Mon Sep 17 00:00:00 2001 From: Salman Paracha Date: Fri, 5 Sep 2025 09:09:17 -0700 Subject: [PATCH] cleaned up logs and fixed issue with connectivity for llm gateway in weather forecast demo --- crates/hermesllm/src/clients/endpoints.rs | 10 +++++++ crates/llm_gateway/src/stream_context.rs | 29 +++++++------------ .../weather_forecast/arch_config.yaml | 6 ++++ 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/crates/hermesllm/src/clients/endpoints.rs b/crates/hermesllm/src/clients/endpoints.rs index 7f04bd76..5af51fe0 100644 --- a/crates/hermesllm/src/clients/endpoints.rs +++ b/crates/hermesllm/src/clients/endpoints.rs @@ -22,6 +22,7 @@ //! ``` use crate::{apis::{AnthropicApi, ApiDefinition, OpenAIApi}, ProviderId}; +use std::fmt; /// Unified enum representing all supported API endpoints across providers #[derive(Debug, Clone, PartialEq)] @@ -30,6 +31,15 @@ pub enum SupportedAPIs { AnthropicMessagesAPI(AnthropicApi), } +impl fmt::Display for SupportedAPIs { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + SupportedAPIs::OpenAIChatCompletions(api) => write!(f, "OpenAI API ({})", api.endpoint()), + SupportedAPIs::AnthropicMessagesAPI(api) => write!(f, "Anthropic API ({})", api.endpoint()), + } + } +} + impl SupportedAPIs { /// Create a SupportedApi from an endpoint path pub fn from_endpoint(endpoint: &str) -> Option { diff --git a/crates/llm_gateway/src/stream_context.rs b/crates/llm_gateway/src/stream_context.rs index 1465cf97..b84d615c 100644 --- a/crates/llm_gateway/src/stream_context.rs +++ b/crates/llm_gateway/src/stream_context.rs @@ -858,14 +858,8 @@ impl HttpContext for StreamContext { Action::Continue } - fn on_http_response_headers(&mut self, _num_headers: usize, end_of_stream: bool) -> Action { - debug!( - "on_http_response_headers [S={}] end_stream={}", - self.context_id, end_of_stream - ); - + fn on_http_response_headers(&mut self, _num_headers: usize, _end_of_stream: bool) -> Action { self.remove_http_response_header("content-length"); - // If upstream may compress, drop encoding so our new bytes are sent as-is. self.remove_http_response_header("content-encoding"); self.set_property( @@ -877,11 +871,6 @@ impl HttpContext for StreamContext { } fn on_http_response_body(&mut self, body_size: usize, end_of_stream: bool) -> Action { - debug!( - "on_http_response_body [S={}] bytes={} end_stream={}", - self.context_id, body_size, end_of_stream - ); - if self.request_body_sent_time.is_none() { debug!("on_http_response_body: request body not sent, not doing any processing in llm filter"); return Action::Continue; @@ -891,7 +880,15 @@ impl HttpContext for StreamContext { Some(SupportedAPIs::OpenAIChatCompletions(_)) => {} Some(SupportedAPIs::AnthropicMessagesAPI(_)) => {} _ => { - info!("on_http_response_body: non-chatcompletion request"); + let api_info = match &self.client_api { + Some(api) => format!("{}", api), + None => "None".to_string(), + }; + info!( + "[ARCHGW_REQ_ID:{}], UNSUPPORTED API: {}", + self.request_identifier(), + api_info + ); return Action::Continue; } } @@ -925,12 +922,6 @@ impl HttpContext for StreamContext { Err(action) => return action, } } - - debug!( - "recv [S={}] total_tokens={} end_stream={}", - self.context_id, self.response_tokens, end_of_stream - ); - Action::Continue } } diff --git a/demos/samples_python/weather_forecast/arch_config.yaml b/demos/samples_python/weather_forecast/arch_config.yaml index bd4478bc..6d33a5c5 100644 --- a/demos/samples_python/weather_forecast/arch_config.yaml +++ b/demos/samples_python/weather_forecast/arch_config.yaml @@ -7,6 +7,12 @@ listeners: message_format: openai timeout: 30s + egress_traffic: + address: 0.0.0.0 + port: 12000 + message_format: openai + timeout: 30s + endpoints: weather_forecast_service: endpoint: host.docker.internal:18083