mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-05-23 22:21:00 +08:00
* fix(codex): use TOML parser instead of regex for model extraction Regex only matched model=... on first line, TOML parser handles multiline TOML correctly. Fixes #2222 * fix(stream_check): drop unused regex::Regex import The previous commit replaced the only Regex usage in stream_check.rs with toml::Table parsing, leaving `use regex::Regex;` orphaned. Without this removal, `cargo clippy -- -D warnings` (run in CI) fails with `unused import: regex::Regex`. --------- Co-authored-by: Jason <farion1231@gmail.com>
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
//! 使用流式 API 进行快速健康检查,只需接收首个 chunk 即判定成功。
|
||||
|
||||
use futures::StreamExt;
|
||||
use regex::Regex;
|
||||
use reqwest::Client;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
@@ -1412,10 +1411,11 @@ impl StreamCheckService {
|
||||
return None;
|
||||
}
|
||||
|
||||
let re = Regex::new(r#"^model\s*=\s*["']([^"']+)["']"#).ok()?;
|
||||
re.captures(config_text)
|
||||
.and_then(|caps| caps.get(1))
|
||||
.map(|m| m.as_str().trim().to_string())
|
||||
let table = toml::from_str::<toml::Table>(config_text).ok()?;
|
||||
table
|
||||
.get("model")
|
||||
.and_then(|v| v.as_str())
|
||||
.map(|s| s.trim().to_string())
|
||||
.filter(|value| !value.is_empty())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user