mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-04 19:45:34 +08:00
feat: add Copilot optimizer to reduce premium interaction consumption
Implement request classification, tool result merging, compact detection, deterministic request IDs, and warmup downgrade for Copilot proxy. The root cause was x-initiator being hardcoded to "user", making Copilot count every API request (including tool callbacks and agent continuations) as a separate premium interaction. The optimizer dynamically classifies requests as "user" or "agent" based on message content analysis. Closes #1813
This commit is contained in:
@@ -247,6 +247,30 @@ pub async fn set_optimizer_config(
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
/// 获取 Copilot 优化器配置
|
||||
#[tauri::command]
|
||||
pub async fn get_copilot_optimizer_config(
|
||||
state: tauri::State<'_, crate::AppState>,
|
||||
) -> Result<crate::proxy::types::CopilotOptimizerConfig, String> {
|
||||
state
|
||||
.db
|
||||
.get_copilot_optimizer_config()
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// 设置 Copilot 优化器配置
|
||||
#[tauri::command]
|
||||
pub async fn set_copilot_optimizer_config(
|
||||
state: tauri::State<'_, crate::AppState>,
|
||||
config: crate::proxy::types::CopilotOptimizerConfig,
|
||||
) -> Result<bool, String> {
|
||||
state
|
||||
.db
|
||||
.set_copilot_optimizer_config(&config)
|
||||
.map_err(|e| e.to_string())?;
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
/// 获取日志配置
|
||||
#[tauri::command]
|
||||
pub async fn get_log_config(
|
||||
|
||||
Reference in New Issue
Block a user