mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-27 08:01:04 +00:00
refactor: align backend names
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
pub mod cf_path_block;
|
||||
pub mod cloudflare_challenge;
|
||||
pub mod cookies;
|
||||
pub mod jwt;
|
||||
pub mod lifecycle;
|
||||
pub mod model;
|
||||
pub mod models;
|
||||
pub mod pool;
|
||||
pub mod repository;
|
||||
pub mod service;
|
||||
|
||||
@@ -9,13 +9,6 @@ use crate::{
|
||||
utils::pagination::{decode_cursor, encode_cursor, Page},
|
||||
};
|
||||
|
||||
mod lease;
|
||||
mod quota;
|
||||
mod token;
|
||||
mod usage;
|
||||
|
||||
pub use usage::AccountUsageRepository;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AccountRepositoryError {
|
||||
#[error("database error: {0}")]
|
||||
@@ -155,8 +148,8 @@ pub struct AccountUsageSummary {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AccountRepository {
|
||||
pool: SqlitePool,
|
||||
secret_box: SecretBox,
|
||||
pub(super) pool: SqlitePool,
|
||||
pub(super) secret_box: SecretBox,
|
||||
}
|
||||
|
||||
const INSERT_ACCOUNT_SQL: &str = r"
|
||||
@@ -644,7 +637,7 @@ impl AccountRepository {
|
||||
}
|
||||
}
|
||||
|
||||
fn status_to_db(status: AccountStatus) -> &'static str {
|
||||
pub(crate) fn status_to_db(status: AccountStatus) -> &'static str {
|
||||
match status {
|
||||
AccountStatus::Active => "active",
|
||||
AccountStatus::Expired => "expired",
|
||||
@@ -667,11 +660,13 @@ fn status_from_db(value: &str) -> AccountRepositoryResult<AccountStatus> {
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_optional_rfc3339(value: Option<String>) -> AccountRepositoryResult<Option<DateTime<Utc>>> {
|
||||
pub(crate) fn parse_optional_rfc3339(
|
||||
value: Option<String>,
|
||||
) -> AccountRepositoryResult<Option<DateTime<Utc>>> {
|
||||
value.as_deref().map(parse_rfc3339).transpose()
|
||||
}
|
||||
|
||||
fn parse_rfc3339(value: &str) -> AccountRepositoryResult<DateTime<Utc>> {
|
||||
pub(crate) fn parse_rfc3339(value: &str) -> AccountRepositoryResult<DateTime<Utc>> {
|
||||
Ok(DateTime::parse_from_rfc3339(value)?.with_timezone(&Utc))
|
||||
}
|
||||
|
||||
@@ -679,7 +674,7 @@ fn nonnegative_i64_to_u64(value: i64) -> u64 {
|
||||
value.max(0) as u64
|
||||
}
|
||||
|
||||
fn optional_positive_i64_to_u64(value: Option<i64>) -> Option<u64> {
|
||||
pub(crate) fn optional_positive_i64_to_u64(value: Option<i64>) -> Option<u64> {
|
||||
value
|
||||
.and_then(|value| u64::try_from(value).ok())
|
||||
.filter(|value| *value > 0)
|
||||
@@ -0,0 +1,9 @@
|
||||
mod accounts;
|
||||
mod leases;
|
||||
mod quotas;
|
||||
mod tokens;
|
||||
mod usage;
|
||||
|
||||
pub use accounts::*;
|
||||
pub(crate) use accounts::{optional_positive_i64_to_u64, parse_optional_rfc3339, status_to_db};
|
||||
pub use usage::AccountUsageRepository;
|
||||
@@ -185,7 +185,7 @@ mod tests {
|
||||
);
|
||||
let access_token = SecretString::new("access-secret".to_string().into());
|
||||
let refresh_token = SecretString::new("refresh-secret".to_string().into());
|
||||
let expires_at = super::super::parse_rfc3339("2026-06-14T00:00:00Z").unwrap();
|
||||
let expires_at = super::super::accounts::parse_rfc3339("2026-06-14T00:00:00Z").unwrap();
|
||||
|
||||
let write = repository
|
||||
.prepare_token_write(&access_token, Some(&refresh_token), Some(expires_at))
|
||||
@@ -198,6 +198,6 @@ mod tests {
|
||||
write.access_token_expires_at.as_deref(),
|
||||
Some("2026-06-14T00:00:00+00:00")
|
||||
);
|
||||
assert!(super::super::parse_rfc3339(&write.updated_at).is_ok());
|
||||
assert!(super::super::accounts::parse_rfc3339(&write.updated_at).is_ok());
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ use crate::{
|
||||
repository::{AccountRepository, StoredAccount},
|
||||
},
|
||||
codex::gateway::fingerprint::model::Fingerprint,
|
||||
codex::gateway::transport::client::{
|
||||
codex::gateway::transport::http_client::{
|
||||
build_reqwest_client, CodexBackendClient, CodexClientError, CodexRequestContext,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -13,8 +13,8 @@ use crate::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
runtime_pool::pool_account_from_stored, AccountImportCounts, AccountImportEntry,
|
||||
AccountService, StoreImportAccountError, ValidatedAccountImportError,
|
||||
pool_sync::pool_account_from_stored, AccountImportCounts, AccountImportEntry, AccountService,
|
||||
StoreImportAccountError, ValidatedAccountImportError,
|
||||
};
|
||||
|
||||
enum StoredImportAccount {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::codex::accounts::{model::AccountStatus, repository::AccountRepository};
|
||||
|
||||
use super::{
|
||||
runtime_pool::pool_account_from_stored, AccountService, AccountServiceError,
|
||||
BatchDeleteAccounts, BatchUpdateAccountStatus, UpdateAccountStatus,
|
||||
pool_sync::pool_account_from_stored, AccountService, AccountServiceError, BatchDeleteAccounts,
|
||||
BatchUpdateAccountStatus, UpdateAccountStatus,
|
||||
};
|
||||
|
||||
impl AccountService {
|
||||
@@ -1,10 +1,10 @@
|
||||
pub mod cookies;
|
||||
pub mod health;
|
||||
pub mod import;
|
||||
pub mod mutation;
|
||||
pub mod lifecycle;
|
||||
pub mod pool_sync;
|
||||
pub mod quota;
|
||||
pub mod refresh;
|
||||
pub mod runtime_pool;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::{
|
||||
};
|
||||
|
||||
use super::{
|
||||
health::skipped_probe_result, runtime_pool::pool_account_from_stored, AccountProbeOutcome,
|
||||
health::skipped_probe_result, pool_sync::pool_account_from_stored, AccountProbeOutcome,
|
||||
AccountProbeResult, AccountService, RefreshAccountError,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
pub mod event;
|
||||
pub mod repository;
|
||||
pub mod rotation;
|
||||
pub mod service;
|
||||
@@ -1,7 +1,7 @@
|
||||
use sqlx::{QueryBuilder, Row, Sqlite, SqlitePool};
|
||||
|
||||
use crate::{
|
||||
codex::logs::event::{EventLevel, EventLog},
|
||||
codex::events::event::{EventLevel, EventLog},
|
||||
utils::pagination::{clamp_limit, decode_cursor, encode_cursor, Page},
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||
use tokio::sync::RwLock;
|
||||
|
||||
use crate::{
|
||||
codex::logs::{
|
||||
codex::events::{
|
||||
event::EventLog,
|
||||
repository::{EventLogFilters, EventLogRepository},
|
||||
},
|
||||
@@ -1,6 +1,6 @@
|
||||
pub mod conversation_identity;
|
||||
pub mod fingerprint;
|
||||
pub mod identity;
|
||||
pub mod installation;
|
||||
pub mod installation_id;
|
||||
pub mod oauth;
|
||||
pub mod protocol;
|
||||
pub mod transport;
|
||||
|
||||
@@ -19,7 +19,7 @@ const OPENAI_OAUTH_AUTHORIZE_ENDPOINT: &str = "https://auth.openai.com/oauth/aut
|
||||
const OPENAI_OAUTH_DEVICE_CODE_ENDPOINT: &str = "https://auth.openai.com/oauth/device/code";
|
||||
const OPENAI_OAUTH_TOKEN_ENDPOINT: &str = "https://auth.openai.com/oauth/token";
|
||||
const OAUTH_CALLBACK_PORT: u16 = 1455;
|
||||
const OAUTH_CALLBACK_PATH: &str = "/auth/callback";
|
||||
const OAUTH_CALLBACK_PATH: &str = "/auth/openai/callback";
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct OAuthConfig {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
pub mod cli_import;
|
||||
pub mod client;
|
||||
pub mod codex_cli;
|
||||
pub mod refresh;
|
||||
pub mod token;
|
||||
|
||||
pub use cli_import::*;
|
||||
pub use client::*;
|
||||
pub use codex_cli::*;
|
||||
pub use refresh::*;
|
||||
pub use token::*;
|
||||
|
||||
@@ -11,13 +11,12 @@ use serde_json::{Map, Value};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::{
|
||||
codex::accounts::models::catalog::BackendModelEntry,
|
||||
codex::gateway::fingerprint::model::Fingerprint,
|
||||
codex::gateway::transport::{
|
||||
headers::build_ordered_codex_headers,
|
||||
sse::SseError,
|
||||
types::CodexResponsesRequest,
|
||||
usage::{extract_sse_usage, TokenUsage},
|
||||
usage_events::{extract_sse_usage, TokenUsage},
|
||||
websocket::{
|
||||
append_rate_limit_updates, create_response_via_websocket,
|
||||
create_response_via_websocket_stream, create_response_via_websocket_stream_with_pool,
|
||||
@@ -26,6 +25,7 @@ use crate::{
|
||||
SharedRateLimitUpdates, WebSocketSupportError,
|
||||
},
|
||||
},
|
||||
codex::models::catalog::BackendModelEntry,
|
||||
};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
@@ -1,7 +1,7 @@
|
||||
pub mod client;
|
||||
pub mod headers;
|
||||
pub mod http_client;
|
||||
pub mod rate_limits;
|
||||
pub mod sse;
|
||||
pub mod types;
|
||||
pub mod usage;
|
||||
pub mod usage_events;
|
||||
pub mod websocket;
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
use std::{
|
||||
fs, io,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use thiserror::Error;
|
||||
use tracing_appender::{
|
||||
non_blocking::WorkerGuard,
|
||||
rolling::{RollingFileAppender, Rotation},
|
||||
};
|
||||
use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
|
||||
|
||||
const LOG_PREFIX: &str = "codex-proxy-rs";
|
||||
const LOG_SUFFIX: &str = "log";
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RotationConfig {
|
||||
pub directory: PathBuf,
|
||||
pub retention_days: usize,
|
||||
}
|
||||
|
||||
impl RotationConfig {
|
||||
pub fn new(directory: impl AsRef<Path>, retention_days: usize) -> Self {
|
||||
Self {
|
||||
directory: directory.as_ref().to_path_buf(),
|
||||
retention_days,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum LogError {
|
||||
#[error("log io error: {0}")]
|
||||
Io(#[from] io::Error),
|
||||
#[error("log appender initialization failed: {0}")]
|
||||
Appender(#[from] tracing_appender::rolling::InitError),
|
||||
#[error("global tracing subscriber is already initialized")]
|
||||
SubscriberAlreadyInitialized,
|
||||
}
|
||||
|
||||
pub struct LogGuard {
|
||||
_guard: WorkerGuard,
|
||||
}
|
||||
|
||||
pub fn build_file_appender(config: &RotationConfig) -> Result<RollingFileAppender, LogError> {
|
||||
fs::create_dir_all(&config.directory)?;
|
||||
|
||||
let builder = RollingFileAppender::builder()
|
||||
.rotation(Rotation::DAILY)
|
||||
.filename_prefix(LOG_PREFIX)
|
||||
.filename_suffix(LOG_SUFFIX);
|
||||
let builder = if config.retention_days == 0 {
|
||||
builder
|
||||
} else {
|
||||
builder.max_log_files(config.retention_days)
|
||||
};
|
||||
|
||||
builder.build(&config.directory).map_err(LogError::Appender)
|
||||
}
|
||||
|
||||
pub fn init_tracing(config: RotationConfig) -> Result<LogGuard, LogError> {
|
||||
let appender = build_file_appender(&config)?;
|
||||
let (writer, guard) = tracing_appender::non_blocking(appender);
|
||||
let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
|
||||
|
||||
tracing_subscriber::registry()
|
||||
.with(filter)
|
||||
.with(
|
||||
fmt::layer()
|
||||
.json()
|
||||
.with_writer(writer)
|
||||
.with_target(true)
|
||||
.with_level(true)
|
||||
.with_file(true)
|
||||
.with_line_number(true)
|
||||
.with_thread_ids(true)
|
||||
.with_thread_names(true)
|
||||
.with_current_span(true)
|
||||
.with_span_list(true),
|
||||
)
|
||||
.try_init()
|
||||
.map_err(|_| LogError::SubscriberAlreadyInitialized)?;
|
||||
|
||||
Ok(LogGuard { _guard: guard })
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
pub mod accounts;
|
||||
pub mod events;
|
||||
pub mod gateway;
|
||||
pub mod logs;
|
||||
pub mod models;
|
||||
pub mod serving;
|
||||
pub mod tasks;
|
||||
pub mod usage;
|
||||
|
||||
@@ -2,7 +2,7 @@ use chrono::Utc;
|
||||
use sqlx::{Row, SqlitePool};
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::codex::accounts::models::catalog::{CodexModelInfo, ModelPlanSnapshot};
|
||||
use crate::codex::models::catalog::{CodexModelInfo, ModelPlanSnapshot};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ModelSnapshotRepositoryError {
|
||||
@@ -3,19 +3,19 @@ use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use crate::{
|
||||
codex::accounts::models::{
|
||||
catalog::{ModelCatalog, ModelPlanSnapshot},
|
||||
repository::ModelSnapshotRepository,
|
||||
},
|
||||
codex::accounts::{
|
||||
model::{Account, AccountStatus},
|
||||
pool::AccountPool,
|
||||
repository::AccountRepository,
|
||||
},
|
||||
codex::gateway::fingerprint::model::Fingerprint,
|
||||
codex::gateway::transport::client::{
|
||||
codex::gateway::transport::http_client::{
|
||||
build_reqwest_client, CodexBackendClient, CodexRequestContext,
|
||||
},
|
||||
codex::models::{
|
||||
catalog::{ModelCatalog, ModelPlanSnapshot},
|
||||
repository::ModelSnapshotRepository,
|
||||
},
|
||||
config::AppConfig,
|
||||
};
|
||||
|
||||
@@ -12,15 +12,15 @@ use axum::{
|
||||
use serde_json::json;
|
||||
|
||||
use crate::{
|
||||
codex::accounts::models::catalog::ModelCatalog,
|
||||
codex::accounts::models::service::ModelService,
|
||||
codex::events::event::EventLevel,
|
||||
codex::gateway::protocol::{
|
||||
codex_to_openai::{
|
||||
chat_completion_from_codex_sse, chat_completion_stream_from_codex_sse, openai_error,
|
||||
},
|
||||
openai_to_codex::{translate_chat_to_codex, ChatCompletionRequest},
|
||||
},
|
||||
codex::logs::event::EventLevel,
|
||||
codex::models::catalog::ModelCatalog,
|
||||
codex::models::service::ModelService,
|
||||
codex::serving::dispatch::{
|
||||
classify_upstream_account_retry, no_available_accounts_response,
|
||||
normalize_service_tier_for_upstream, CodexRequestLogContext, CodexUpstreamService,
|
||||
|
||||
@@ -6,7 +6,7 @@ use serde::Serialize;
|
||||
use crate::{
|
||||
codex::gateway::{
|
||||
fingerprint::model::Fingerprint,
|
||||
transport::client::{
|
||||
transport::http_client::{
|
||||
build_reqwest_client, CodexBackendClient, CodexClientError, CodexRequestContext,
|
||||
},
|
||||
},
|
||||
|
||||
+1
-1
@@ -7,9 +7,9 @@ use crate::{
|
||||
model::{Account, AccountStatus},
|
||||
repository::TokenUpdate,
|
||||
},
|
||||
codex::events::event::{EventLevel, EventLog},
|
||||
codex::gateway::oauth::{RefreshFailure, TokenPair},
|
||||
codex::gateway::transport::types::CodexResponsesRequest,
|
||||
codex::logs::event::{EventLevel, EventLog},
|
||||
};
|
||||
|
||||
use super::CodexUpstreamDependencies;
|
||||
@@ -7,7 +7,7 @@ use crate::codex::{
|
||||
model::{Account, AccountStatus},
|
||||
pool::AccountAcquireRequest,
|
||||
},
|
||||
gateway::transport::{client::CodexClientError, rate_limits::cooldown_with_jitter},
|
||||
gateway::transport::{http_client::CodexClientError, rate_limits::cooldown_with_jitter},
|
||||
};
|
||||
|
||||
use super::{usage::record_request_attempt, CodexUpstreamDependencies};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
mod account_refresh;
|
||||
pub mod affinity;
|
||||
mod audit;
|
||||
pub mod fallback;
|
||||
mod limits;
|
||||
pub mod refresh;
|
||||
// 上游调度辅助命名为 routing,避免出现 dispatch::dispatch 的模块套娃。
|
||||
pub mod routing;
|
||||
pub mod stream;
|
||||
mod stream_audit;
|
||||
pub mod usage;
|
||||
|
||||
use std::{sync::Arc, time::Instant};
|
||||
@@ -31,26 +31,26 @@ use crate::{
|
||||
pool::{AccountAcquireRequest, AccountPool},
|
||||
repository::AccountRepository,
|
||||
},
|
||||
codex::events::{
|
||||
event::{EventLevel, EventLog},
|
||||
service::LogService,
|
||||
},
|
||||
codex::gateway::conversation_identity::{build_conversation_identity, ensure_prompt_cache_key},
|
||||
codex::gateway::fingerprint::model::Fingerprint,
|
||||
codex::gateway::identity::{build_conversation_identity, ensure_prompt_cache_key},
|
||||
codex::gateway::installation::get_installation_id,
|
||||
codex::gateway::installation_id::get_installation_id,
|
||||
codex::gateway::oauth::TokenRefresher,
|
||||
codex::gateway::protocol::codex_to_openai::openai_error,
|
||||
codex::gateway::transport::{
|
||||
client::{
|
||||
http_client::{
|
||||
build_reqwest_client, CodexBackendClient, CodexBackendStream,
|
||||
CodexBackendWebSocketStream, CodexClientError, CodexRequestContext,
|
||||
},
|
||||
types::CodexResponsesRequest,
|
||||
usage::TokenUsage,
|
||||
usage_events::TokenUsage,
|
||||
websocket::{
|
||||
transport_for_request, CodexTransport, CodexWebSocketError, CodexWebSocketPool,
|
||||
},
|
||||
},
|
||||
codex::logs::{
|
||||
event::{EventLevel, EventLog},
|
||||
service::LogService,
|
||||
},
|
||||
config::AppConfig,
|
||||
};
|
||||
|
||||
@@ -65,13 +65,13 @@ pub(crate) use self::{
|
||||
};
|
||||
|
||||
use self::affinity::{compute_variant_hash, SessionAffinityMap, SessionAffinityRepository};
|
||||
use self::audit::{StreamAudit, WebSocketStreamAudit};
|
||||
use self::fallback::{
|
||||
apply_upstream_account_retry_with_deps, apply_upstream_retry_and_acquire_fallback_with_deps,
|
||||
};
|
||||
use self::stream_audit::{StreamAudit, WebSocketStreamAudit};
|
||||
use self::{
|
||||
account_refresh::refresh_account_after_unauthorized,
|
||||
limits::apply_rate_limit_headers_with_deps,
|
||||
refresh::refresh_account_after_unauthorized,
|
||||
routing::request_domain,
|
||||
stream::{completed_response_metadata, ensure_stream_metadata},
|
||||
usage::{record_empty_response_with_deps, record_usage_with_deps},
|
||||
@@ -200,7 +200,7 @@ impl CodexUpstreamService {
|
||||
request: &CodexResponsesRequest,
|
||||
account: &Account,
|
||||
request_id: &str,
|
||||
) -> Result<crate::codex::gateway::transport::client::CodexBackendResponse, CodexClientError>
|
||||
) -> Result<crate::codex::gateway::transport::http_client::CodexBackendResponse, CodexClientError>
|
||||
{
|
||||
send_codex_request_with_refresh_retry_deps(&self.deps, request, account, request_id).await
|
||||
}
|
||||
@@ -466,7 +466,7 @@ async fn send_codex_request_with_refresh_retry_deps(
|
||||
request: &CodexResponsesRequest,
|
||||
account: &Account,
|
||||
request_id: &str,
|
||||
) -> Result<crate::codex::gateway::transport::client::CodexBackendResponse, CodexClientError> {
|
||||
) -> Result<crate::codex::gateway::transport::http_client::CodexBackendResponse, CodexClientError> {
|
||||
let result = match send_codex_request(deps, request, account, request_id).await {
|
||||
Err(CodexClientError::Upstream {
|
||||
status,
|
||||
@@ -503,7 +503,7 @@ async fn send_codex_request(
|
||||
request: &CodexResponsesRequest,
|
||||
account: &Account,
|
||||
request_id: &str,
|
||||
) -> Result<crate::codex::gateway::transport::client::CodexBackendResponse, CodexClientError> {
|
||||
) -> Result<crate::codex::gateway::transport::http_client::CodexBackendResponse, CodexClientError> {
|
||||
let request_domain = request_domain(&deps.config.api.base_url);
|
||||
let cookie_header = match (deps.cookie_repository.as_ref(), request_domain.as_deref()) {
|
||||
(Some(repo), Some(domain)) => repo.cookie_header(&account.id, domain).await.ok().flatten(),
|
||||
|
||||
@@ -8,11 +8,11 @@ use crate::{
|
||||
codex::gateway::transport::types::CodexResponsesRequest,
|
||||
codex::{
|
||||
accounts::pool::AccountPool,
|
||||
events::event::EventLevel,
|
||||
gateway::transport::{
|
||||
usage::extract_sse_usage,
|
||||
usage_events::extract_sse_usage,
|
||||
websocket::{append_rate_limit_updates, CodexWebSocketError, SharedRateLimitUpdates},
|
||||
},
|
||||
logs::event::EventLevel,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
codex::accounts::repository::UsageDelta, codex::gateway::transport::usage::TokenUsage,
|
||||
codex::accounts::repository::UsageDelta, codex::gateway::transport::usage_events::TokenUsage,
|
||||
};
|
||||
|
||||
use super::CodexUpstreamDependencies;
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::{
|
||||
codex::gateway::protocol::{
|
||||
codex_to_openai::openai_error, openai_to_codex::ChatCompletionRequest,
|
||||
},
|
||||
platform::http::middleware::RequestId,
|
||||
platform::http::request_id::RequestId,
|
||||
runtime::state::AppState,
|
||||
};
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@ use serde::Serialize;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::{
|
||||
admin::auth::service::AdminAuthPoolSummary,
|
||||
admin::session::service::AdminAuthPoolSummary,
|
||||
codex::{accounts::pool::AccountCapacitySummary, gateway::fingerprint::model::Fingerprint},
|
||||
config::AppConfig,
|
||||
platform::http::middleware::RequestId,
|
||||
platform::http::request_id::RequestId,
|
||||
runtime::state::AppState,
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use serde_json::Value;
|
||||
|
||||
use crate::{
|
||||
codex::gateway::protocol::codex_to_openai::openai_error,
|
||||
codex::gateway::transport::client::CodexClientError,
|
||||
codex::gateway::transport::http_client::CodexClientError,
|
||||
};
|
||||
|
||||
pub(crate) fn codex_client_error_response(error: CodexClientError) -> (StatusCode, Json<Value>) {
|
||||
|
||||
@@ -6,7 +6,7 @@ use axum::{
|
||||
};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use crate::{codex::accounts::models::catalog::ModelCatalog, runtime::state::AppState};
|
||||
use crate::{codex::models::catalog::ModelCatalog, runtime::state::AppState};
|
||||
|
||||
use super::{
|
||||
auth::authorize_client_api_key,
|
||||
|
||||
@@ -8,7 +8,7 @@ use axum::{
|
||||
Extension,
|
||||
};
|
||||
|
||||
use crate::{platform::http::middleware::RequestId, runtime::state::AppState};
|
||||
use crate::{platform::http::request_id::RequestId, runtime::state::AppState};
|
||||
|
||||
use super::{auth::authorize_client_api_key, errors::missing_client_api_key_response};
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ use serde::Deserialize;
|
||||
use serde_json::{json, Map, Value};
|
||||
|
||||
use crate::{
|
||||
codex::accounts::models::service::ModelService,
|
||||
codex::events::event::EventLevel,
|
||||
codex::gateway::fingerprint::model::Fingerprint,
|
||||
codex::gateway::protocol::codex_to_openai::openai_error,
|
||||
codex::gateway::transport::types::CodexResponsesRequest,
|
||||
codex::logs::event::EventLevel,
|
||||
codex::models::service::ModelService,
|
||||
codex::serving::dispatch::{
|
||||
affinity::SessionAffinityRepositoryResult, classify_upstream_account_retry,
|
||||
completed_response_json, no_available_accounts_response,
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
pub mod model;
|
||||
pub mod quota;
|
||||
pub mod refresh;
|
||||
pub mod model_refresh;
|
||||
pub mod quota_refresh;
|
||||
pub mod token_refresh;
|
||||
|
||||
@@ -3,9 +3,7 @@ use std::time::Duration;
|
||||
use tokio::time::{interval, sleep};
|
||||
use tracing::{info, warn};
|
||||
|
||||
use crate::{
|
||||
codex::accounts::models::service::ModelService, runtime::tasks::types::SchedulerHandle,
|
||||
};
|
||||
use crate::{codex::models::service::ModelService, runtime::tasks::types::SchedulerHandle};
|
||||
|
||||
/// 模型刷新调度器 - 定期从 Codex 后端刷新模型列表
|
||||
///
|
||||
@@ -78,7 +76,7 @@ impl ModelRefresher {
|
||||
// 如果是 NoAccounts 错误,跳过重试直接进入定期刷新
|
||||
let is_no_accounts = matches!(
|
||||
e,
|
||||
crate::codex::accounts::models::service::ModelServiceError::NoAccounts
|
||||
crate::codex::models::service::ModelServiceError::NoAccounts
|
||||
);
|
||||
|
||||
if is_no_accounts {
|
||||
Reference in New Issue
Block a user