diff --git a/Cargo.lock b/Cargo.lock index f0eea85..152e6a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -234,11 +234,9 @@ version = "0.1.0" dependencies = [ "async-stream", "axum", - "bytes", "config", "dotenvy", "futures-util", - "hyper", "reqwest", "serde", "serde_json", diff --git a/Cargo.toml b/Cargo.toml index 98f58b1..d28822d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,8 +12,6 @@ serde_json = "1.0.140" tokio = { version = "1.46.1", features = ["full"] } futures-util = "0.3" async-stream = "0.3" -bytes = "1.4" -hyper = { version = "1", features = ["full"] } tracing = "0.1.41" tracing-subscriber = { version = "0.3.19", features = ["fmt", "env-filter"] } config = { version = "0.14.0", features = ["yaml"] } diff --git a/src/main.rs b/src/main.rs index faabcbb..a54588f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,7 +35,7 @@ async fn main() { if let Some(path) = args.get(index + 1) { logging_path = Some(path.clone()); std::fs::create_dir_all(path).expect("Failed to create logging directory"); - println!("Logging requests and responses to: {}", path); + println!("Logging requests and responses to: {path}"); } else { eprintln!("--logging flag requires a path argument."); std::process::exit(1); @@ -73,7 +73,7 @@ async fn messages_handler( .duration_since(std::time::UNIX_EPOCH) .unwrap() .as_millis(); - let request_path = format!("{}/{}-request.json", path, timestamp); + let request_path = format!("{path}/{timestamp}-request.json"); let request_json = serde_json::to_string_pretty(&openai_request).unwrap(); std::fs::write(request_path, request_json).expect("Failed to write request log"); } @@ -132,9 +132,9 @@ async fn messages_handler( } }); let sse_event = format!("event: content_block_delta -data: {} +data: {anthropic_stream_event} -", anthropic_stream_event); +"); yield Ok::<_, axum::Error>(sse_event.into_bytes()); } } @@ -146,9 +146,9 @@ data: {} "type": "message_stop" }); let sse_event = format!("event: message_stop -data: {} +data: {message_stop} -", message_stop); +"); yield Ok::<_, axum::Error>(sse_event.into_bytes()); if let Some(path) = logging_path.as_ref() { @@ -156,7 +156,7 @@ data: {} .duration_since(std::time::UNIX_EPOCH) .unwrap() .as_millis(); - let response_path = format!("{}/{}-response.json", path, timestamp); + let response_path = format!("{path}/{timestamp}-response.json"); std::fs::write(response_path, full_response).expect("Failed to write response log"); } }; @@ -189,7 +189,7 @@ data: {} .duration_since(std::time::UNIX_EPOCH) .unwrap() .as_millis(); - let response_path = format!("{}/{}-response.json", path, timestamp); + let response_path = format!("{path}/{timestamp}-response.json"); let response_json = serde_json::to_string_pretty(&anthropic_response).unwrap(); std::fs::write(response_path, response_json).expect("Failed to write response log"); } diff --git a/src/models.rs b/src/models.rs index 3e411ec..d4bb84b 100644 --- a/src/models.rs +++ b/src/models.rs @@ -1,7 +1,5 @@ - use serde::{Deserialize, Serialize}; - // Anthropic API Structs #[derive(Debug, Serialize, Deserialize)] diff --git a/src/openai_to_anthropic.rs b/src/openai_to_anthropic.rs index a51726d..1fb9666 100644 --- a/src/openai_to_anthropic.rs +++ b/src/openai_to_anthropic.rs @@ -1,4 +1,3 @@ - use crate::models::*; use serde_json::json;