From 94cc8dc49f2c3e54dd343601a199d1fe228b88ec Mon Sep 17 00:00:00 2001 From: LuoShui Date: Wed, 27 Mar 2024 10:32:23 +0800 Subject: [PATCH] :bug: Fix Arkose Static --- crates/openai/src/serve/mod.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/openai/src/serve/mod.rs b/crates/openai/src/serve/mod.rs index f54706dd2..61cf86c5a 100644 --- a/crates/openai/src/serve/mod.rs +++ b/crates/openai/src/serve/mod.rs @@ -51,7 +51,7 @@ use std::str::FromStr; use std::sync::Arc; use std::time::{Duration, SystemTime, UNIX_EPOCH}; use tower_http::trace; -use tracing::Level; +use tracing::{Instrument, Level}; use tracing_subscriber::prelude::__tracing_subscriber_SubscriberExt; use tracing_subscriber::util::SubscriberInitExt; @@ -185,7 +185,8 @@ impl Serve { .route("/auth/revoke_token", post(post_revoke_token)) .route("/auth/refresh_session", post(post_refresh_session)) .route("/auth/sess_token", post(post_sess_token)) - .route("/auth/billing", post(post_billing)); + .route("/auth/billing", post(post_billing)) + .route("/v2/*path", any(arkos_static)); let router = router::config( // Enable arkose token endpoint proxy @@ -509,3 +510,19 @@ async fn check_wan_address() { } } } + + +async fn arkos_static(path: Path) -> Result, ResponseError> { + let client = with_context!(api_client); + let data = client + .get(format!("{}/v2/{}", arkose::Type::GPT4.origin_url(), path.0.as_str())) + .send() + .await?; + let mut builder = Response::builder() + .status(data.status()); + for (key, value) in data.headers().iter() { + builder = builder.header(key, value); + } + let content = data.bytes().await?; + builder.body(content.into()).map_err(ResponseError::InternalServerError) +}