chore: 修复 release 构建的编译器警告
- 为 regex::Captures 补全显式生命周期标注 - 将仅用于 debug 日志的局部变量 (media_count/len/total) 用 cfg(debug_assertions) 条件化 - 为仅 debug 读取的 AnthropicProvider::llm_timeout_secs 字段添加 cfg_attr allow(dead_code)
This commit is contained in:
parent
da62905505
commit
f26ec49182
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1635,7 +1635,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "picobot"
|
name = "picobot"
|
||||||
version = "0.3.2"
|
version = "0.3.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
|||||||
@ -1311,6 +1311,7 @@ impl FeishuChannel {
|
|||||||
let channel = self.clone();
|
let channel = self.clone();
|
||||||
let bus = bus.clone();
|
let bus = bus.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
let media_count = if parsed.media.is_some() { 1 } else { 0 };
|
let media_count = if parsed.media.is_some() { 1 } else { 0 };
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
tracing::debug!(open_id = %parsed.open_id, chat_id = %parsed.chat_id, content_len = %parsed.content.len(), media_count = %media_count, "Publishing message to bus");
|
tracing::debug!(open_id = %parsed.open_id, chat_id = %parsed.chat_id, content_len = %parsed.content.len(), media_count = %media_count, "Publishing message to bus");
|
||||||
|
|||||||
@ -1222,13 +1222,13 @@ fn resolve_env_placeholders(content: &str) -> String {
|
|||||||
let re_braces = Regex::new(r"\$\{([A-Z_][A-Z0-9_]*)\}").expect("invalid regex");
|
let re_braces = Regex::new(r"\$\{([A-Z_][A-Z0-9_]*)\}").expect("invalid regex");
|
||||||
let re_angle = Regex::new(r"<([A-Z_]+)>").expect("invalid regex");
|
let re_angle = Regex::new(r"<([A-Z_]+)>").expect("invalid regex");
|
||||||
|
|
||||||
let content = re_braces.replace_all(content, |caps: ®ex::Captures| {
|
let content = re_braces.replace_all(content, |caps: ®ex::Captures<'_>| {
|
||||||
let var_name = &caps[1];
|
let var_name = &caps[1];
|
||||||
env::var(var_name).unwrap_or_else(|_| caps[0].to_string())
|
env::var(var_name).unwrap_or_else(|_| caps[0].to_string())
|
||||||
});
|
});
|
||||||
|
|
||||||
re_angle
|
re_angle
|
||||||
.replace_all(&content, |caps: ®ex::Captures| {
|
.replace_all(&content, |caps: ®ex::Captures<'_>| {
|
||||||
let var_name = &caps[1];
|
let var_name = &caps[1];
|
||||||
env::var(var_name).unwrap_or_else(|_| caps[0].to_string())
|
env::var(var_name).unwrap_or_else(|_| caps[0].to_string())
|
||||||
})
|
})
|
||||||
|
|||||||
@ -223,6 +223,7 @@ impl SessionHistory {
|
|||||||
) -> Result<(), AgentError> {
|
) -> Result<(), AgentError> {
|
||||||
if let Some(tid) = topic_id {
|
if let Some(tid) = topic_id {
|
||||||
if let Some(history) = self.topic_histories.get_mut(tid) {
|
if let Some(history) = self.topic_histories.get_mut(tid) {
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
let len = history.len();
|
let len = history.len();
|
||||||
history.clear();
|
history.clear();
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
@ -320,6 +321,7 @@ impl SessionHistory {
|
|||||||
/// 清空所有内存历史(主要用于测试全局重置)。
|
/// 清空所有内存历史(主要用于测试全局重置)。
|
||||||
/// 不遍历清 DB,生产环境如需清 DB 应由调用方显式调用。
|
/// 不遍历清 DB,生产环境如需清 DB 应由调用方显式调用。
|
||||||
pub(crate) fn clear_all_history(&mut self) -> Result<(), AgentError> {
|
pub(crate) fn clear_all_history(&mut self) -> Result<(), AgentError> {
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
let total: usize = self.topic_histories.values().map(|h| h.len()).sum();
|
let total: usize = self.topic_histories.values().map(|h| h.len()).sum();
|
||||||
self.topic_histories.clear();
|
self.topic_histories.clear();
|
||||||
self.compression_in_flight.clear();
|
self.compression_in_flight.clear();
|
||||||
|
|||||||
@ -32,7 +32,7 @@ use std::process::Stdio;
|
|||||||
/// Resolve ${ENV_VAR} placeholders in a value string
|
/// Resolve ${ENV_VAR} placeholders in a value string
|
||||||
fn resolve_env_placeholders_in_value(value: &str) -> String {
|
fn resolve_env_placeholders_in_value(value: &str) -> String {
|
||||||
let re = regex::Regex::new(r"\$\{([A-Z_][A-Z0-9_]*)\}").expect("invalid regex");
|
let re = regex::Regex::new(r"\$\{([A-Z_][A-Z0-9_]*)\}").expect("invalid regex");
|
||||||
re.replace_all(value, |caps: ®ex::Captures| {
|
re.replace_all(value, |caps: ®ex::Captures<'_>| {
|
||||||
let var_name = &caps[1];
|
let var_name = &caps[1];
|
||||||
env::var(var_name).unwrap_or_else(|_| caps[0].to_string())
|
env::var(var_name).unwrap_or_else(|_| caps[0].to_string())
|
||||||
})
|
})
|
||||||
|
|||||||
@ -125,6 +125,7 @@ pub struct AnthropicProvider {
|
|||||||
api_key: String,
|
api_key: String,
|
||||||
base_url: String,
|
base_url: String,
|
||||||
extra_headers: HashMap<String, String>,
|
extra_headers: HashMap<String, String>,
|
||||||
|
#[cfg_attr(not(debug_assertions), allow(dead_code))]
|
||||||
llm_timeout_secs: u64,
|
llm_timeout_secs: u64,
|
||||||
model_id: String,
|
model_id: String,
|
||||||
temperature: Option<f32>,
|
temperature: Option<f32>,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user