mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-06-16 13:34:04 +08:00
00a789e7a3
prompt_cache_key was falling back to provider.id when the client did not supply a session, which collapsed every conversation onto a single key and defeated upstream prefix caching. Only emit the key when a real client-provided session/thread identity is available; otherwise let the upstream use its default matching behaviour. Additional fixes that affect cache stability: - Canonicalise (sort) JSON keys in outgoing request bodies and in tool_call arguments / tool_result content so semantically identical requests produce identical byte sequences for upstream prefix caches. - Exempt JSON Schema property maps (properties, patternProperties, definitions, \$defs) from the underscore-prefix filter so user-defined schema keys like _id and _meta survive. - Add a [CacheTrace] debug log with stable hashes for instructions, tools, input and include to help diagnose cache misses. - Thread session_id into the usage logger for request correlation.
59 lines
1.6 KiB
Rust
59 lines
1.6 KiB
Rust
//! 代理服务器模块
|
|
//!
|
|
//! 提供本地HTTP代理服务,支持多Provider故障转移和请求透传
|
|
|
|
pub mod body_filter;
|
|
pub mod cache_injector;
|
|
pub mod circuit_breaker;
|
|
pub mod copilot_optimizer;
|
|
pub mod error;
|
|
pub mod error_mapper;
|
|
pub(crate) mod failover_switch;
|
|
mod forwarder;
|
|
pub mod gemini_url;
|
|
pub mod handler_config;
|
|
pub mod handler_context;
|
|
mod handlers;
|
|
mod health;
|
|
pub mod http_client;
|
|
pub mod hyper_client;
|
|
pub(crate) mod json_canonical;
|
|
pub mod log_codes;
|
|
pub mod model_mapper;
|
|
pub mod provider_router;
|
|
pub mod providers;
|
|
pub mod response_handler;
|
|
pub mod response_processor;
|
|
pub(crate) mod server;
|
|
pub mod session;
|
|
pub(crate) mod sse;
|
|
pub(crate) mod switch_lock;
|
|
pub mod thinking_budget_rectifier;
|
|
pub mod thinking_optimizer;
|
|
pub mod thinking_rectifier;
|
|
pub(crate) mod types;
|
|
pub mod usage;
|
|
|
|
// 公开导出给外部使用(commands, services等模块需要)
|
|
#[allow(unused_imports)]
|
|
pub use circuit_breaker::{
|
|
CircuitBreaker, CircuitBreakerConfig, CircuitBreakerStats, CircuitState,
|
|
};
|
|
#[allow(unused_imports)]
|
|
pub use error::ProxyError;
|
|
#[allow(unused_imports)]
|
|
pub use provider_router::ProviderRouter;
|
|
#[allow(unused_imports)]
|
|
pub use response_handler::{NonStreamHandler, ResponseType, StreamHandler};
|
|
#[allow(unused_imports)]
|
|
pub use session::{
|
|
extract_session_id, ClientFormat, ProxySession, SessionIdResult, SessionIdSource,
|
|
};
|
|
#[allow(unused_imports)]
|
|
pub use types::{ProxyConfig, ProxyServerInfo, ProxyStatus};
|
|
|
|
// 内部模块间共享(供子模块使用)
|
|
// 注意:这个导出用于模块内部,编译器可能警告未使用但实际被子模块使用
|
|
#[allow(unused_imports)]
|
|
pub(crate) use types::*;
|