Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
16 changes: 8 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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());
}
}
Expand All @@ -146,17 +146,17 @@ 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() {
let timestamp = std::time::SystemTime::now()
.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");
}
};
Expand Down Expand Up @@ -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");
}
Expand Down
2 changes: 0 additions & 2 deletions src/models.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

use serde::{Deserialize, Serialize};


// Anthropic API Structs

#[derive(Debug, Serialize, Deserialize)]
Expand Down
1 change: 0 additions & 1 deletion src/openai_to_anthropic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

use crate::models::*;
use serde_json::json;

Expand Down
Loading