refactor(core): 扫清 v0.1 Phase A 技术债

- 修复测试编译回归:补全 session.rs/cycle.rs 测试模块导入;
convert.rs 2 处 irrefutable if let 改为 let
- composer.rs 迁移至 IR:OpenaiChatMessage → Message,
ContentField/OpenaiContentPart → ContentBlock;删除 set_message_name
和 build_request;developer 消息映射为 Message::System
- knowledge.rs 锁修复:std::sync::Mutex → tokio::sync::Mutex;
search() 优化锁粒度(锁内仅 clone IDs,避免锁内异步 IO)
- 标记 ChatResponse / ToolDefinition 为废弃(#[deprecated(since = "0.1.0")]),
内部使用点加 #[allow(deprecated)] 抑制警告
- clippy 清零:合并冗余 if、手动 strip_prefix 改 strip_prefix、
多处 dead_code 抑制、测试代码清理
This commit is contained in:
徐涛
2026-07-03 15:19:37 +08:00
parent c2c0d498ee
commit c084c57e2c
16 changed files with 138 additions and 181 deletions
+3
View File
@@ -36,6 +36,7 @@ const DEFAULT_MAX_TOKENS: u32 = 4096;
pub struct AnthropicProvider {
http_client: Client,
base_url: String,
#[allow(dead_code)]
api_key: String,
model: String,
}
@@ -586,6 +587,7 @@ enum AnthropicDelta {
struct AnthropicMessageDeltaInner {
stop_reason: Option<String>,
#[serde(default)]
#[allow(dead_code)]
stop_sequence: Option<String>,
}
@@ -599,6 +601,7 @@ pub struct AnthropicSseStream {
chunks: Pin<Box<dyn Stream<Item = Result<Bytes, LlmError>> + Send>>,
buffer: String,
partial: PartialMessageResponse,
#[allow(dead_code)]
next_block_index: u32,
saw_terminal: bool,
}
+2 -2
View File
@@ -720,8 +720,8 @@ impl Stream for ChunkToEventStream {
}
let data = if let Some(p) = trimmed.strip_prefix("data: ") {
p
} else if trimmed.starts_with("data:") {
&trimmed[5..]
} else if let Some(p) = trimmed.strip_prefix("data:") {
p
} else {
continue;
};