From db19395eb7d51e21e3ef34c965c784099d3b332e Mon Sep 17 00:00:00 2001 From: Adil Hafeez Date: Thu, 5 Jun 2025 16:58:45 -0700 Subject: [PATCH] more changes --- crates/Cargo.lock | 1 - crates/hermesllm/Cargo.toml | 1 - crates/llm_gateway/src/stream_context.rs | 3 ++- tests/rest/api_llm_gateway.rest | 31 +++++++++++++++++++++--- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/crates/Cargo.lock b/crates/Cargo.lock index 7edb0a62..ad046f36 100644 --- a/crates/Cargo.lock +++ b/crates/Cargo.lock @@ -1076,7 +1076,6 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" name = "hermesllm" version = "0.1.0" dependencies = [ - "log", "serde", "serde_json", "serde_with", diff --git a/crates/hermesllm/Cargo.toml b/crates/hermesllm/Cargo.toml index 991c64a5..c7917f9a 100644 --- a/crates/hermesllm/Cargo.toml +++ b/crates/hermesllm/Cargo.toml @@ -4,7 +4,6 @@ version = "0.1.0" edition = "2021" [dependencies] -log = "0.4.27" serde = "1.0.219" serde_json = "1.0.140" serde_with = "3.12.0" diff --git a/crates/llm_gateway/src/stream_context.rs b/crates/llm_gateway/src/stream_context.rs index d02e6987..7ba0c9b3 100644 --- a/crates/llm_gateway/src/stream_context.rs +++ b/crates/llm_gateway/src/stream_context.rs @@ -599,7 +599,8 @@ impl HttpContext for StreamContext { Err(e) => { warn!("could not parse response: {}", e); debug!( - "on_http_response_body: response body: {}", + "on_http_response_body: S[{}], response body: {}", + self.context_id, String::from_utf8_lossy(&body) ); self.send_server_error( diff --git a/tests/rest/api_llm_gateway.rest b/tests/rest/api_llm_gateway.rest index 752d600b..5549ccac 100644 --- a/tests/rest/api_llm_gateway.rest +++ b/tests/rest/api_llm_gateway.rest @@ -2,8 +2,33 @@ @openai_endpoint = https://api.openai.com @access_key = {{$dotenv OPENAI_API_KEY}} -### openai request -POST {{openai_endpoint}}/v1/chat/completions HTTP/1.1 +POST {{llm_endpoint}}/v1/chat/completions HTTP/1.1 +content-type: application/json +authorization: Bearer +accept: */* +accept-encoding: deflate +user-agent: Python/3.11 aiohttp/3.11.11 +content-length: 876 +x-forwarded-proto: https +x-request-id: 99d7817d-a646-9497-a38d-710b1ce1325f +traceparent: 00-e4c9fc8cf9fc7714c6a15ef34852fb30-573a351a98e0cd01-01 +tracestate: +x-arch-llm-provider-hint: gpt-4o-mini + + +{ + "model": "gpt-4o-mini", + "messages": [ + { + "role": "user", + "content": "### Task:\nGenerate 1-3 broad tags categorizing the main themes of the chat history, along with 1-3 more specific subtopic tags.\n\n### Guidelines:\n- Start with high-level domains (e.g. Science, Technology, Philosophy, Arts, Politics, Business, Health, Sports, Entertainment, Education)\n- Consider including relevant subfields/subdomains if they are strongly represented throughout the conversation\n- If content is too short (less than 3 messages) or too diverse, use only [\"General\"]\n- Use the chat's primary language; default to English if multilingual\n- Prioritize accuracy over specificity\n\n### Output:\nJSON format: { \"tags\": [\"tag1\", \"tag2\", \"tag3\"] }\n\n### Chat History:\n\nUSER: hello\nASSISTANT: Hello! How can I assist you today?\n" + } + ], + "stream": false +} + +### test +POST {{llm_endpoint}}/v1/chat/completions HTTP/1.1 Content-Type: application/json Authorization: Bearer {{access_key}} @@ -15,7 +40,7 @@ Authorization: Bearer {{access_key}} } ], "model": "gpt-4o-mini", - "stream": true + "stream": false } ### openai request (streaming)