优化: 图像模型兜底防御+任务UI(状态多选+跳详情)+token popover遮挡
This commit is contained in:
@@ -14,7 +14,7 @@ use df_ai::provider::{ChatMessage, CompletionRequest, LlmProvider};
|
||||
// 摘要任务,选 Standard 智力保摘要质量;不传 tools(纯文本出,避免 LLM 调工具跑偏)。
|
||||
// 池空/无匹配兜底 default_model(与 title.rs 一致,行为可预期)。
|
||||
use df_ai::router::{
|
||||
select_model_id, Modality, TaskRequirements,
|
||||
is_likely_image_model, select_model_id, Modality, TaskRequirements,
|
||||
};
|
||||
use df_storage::models::AiProviderRecord;
|
||||
|
||||
@@ -81,6 +81,13 @@ pub(crate) async fn compress_via_llm(
|
||||
};
|
||||
let model = select_model_id(&compress_req, &provider_config.model_configs)
|
||||
.unwrap_or_else(|| provider_config.default_model.clone());
|
||||
// 防御:选中/兜底模型是图像模型时返 Err(走关键词摘要兜底,避免文本任务 404 刷屏)。
|
||||
if is_likely_image_model(&model, &provider_config.model_configs) {
|
||||
return Err(format!(
|
||||
"压缩模型 {} 是图像模型,文本任务不可用(检查 provider default_model 应为文本模型)",
|
||||
model
|
||||
));
|
||||
}
|
||||
|
||||
// 四段式 system prompt + active 消息原文,喂 complete() 非流式出摘要。
|
||||
let mut prompt = vec![ChatMessage::system(compress_prompt(lang))];
|
||||
|
||||
@@ -10,7 +10,7 @@ use df_ai::provider::{ChatMessage, CompletionRequest, LlmProvider, MessageRole};
|
||||
// - 嵌入: TaskRequirements(Capability::Embedding,无工具)— 在 embedding provider 的池中选,
|
||||
// 池空兜底 config.embedding_model(行为不变,现有 KnowledgeConfig 配置即生效)。
|
||||
use df_ai::router::{
|
||||
select_model_id, Modality, TaskRequirements,
|
||||
is_likely_image_model, select_model_id, Modality, TaskRequirements,
|
||||
};
|
||||
use df_storage::crud::{AiConversationRepo, AiMessageRepo, KnowledgeRepo};
|
||||
use df_storage::db::Database;
|
||||
@@ -682,6 +682,14 @@ async fn extract_knowledge_from_conversation(
|
||||
};
|
||||
let extract_model = select_model_id(&extract_req, &provider_config.model_configs)
|
||||
.unwrap_or_else(|| provider_config.default_model.clone());
|
||||
// 防御:选中/兜底模型是图像模型时跳过 LLM 提取(避免文本任务 404 刷屏,治 default_model 配错为图像模型)。
|
||||
if is_likely_image_model(&extract_model, &provider_config.model_configs) {
|
||||
tracing::warn!(
|
||||
"知识提取跳过:模型 {} 是图像模型,文本任务不可用(检查 provider default_model 应为文本模型)",
|
||||
extract_model
|
||||
);
|
||||
return Ok(0);
|
||||
}
|
||||
let request = CompletionRequest {
|
||||
model: extract_model,
|
||||
messages: extract_messages,
|
||||
|
||||
@@ -10,7 +10,7 @@ use df_ai::provider::{ChatMessage, CompletionRequest, LlmProvider, MessageRole};
|
||||
// 标题是短文本摘要任务;池空/无匹配兜底 default_model(行为不变)。
|
||||
// 注:路由已解耦(B-260618-03),原 Lite/Low 智力成本约束已删除,纯 weight 选模型。
|
||||
use df_ai::router::{
|
||||
select_model_id, Modality, TaskRequirements,
|
||||
is_likely_image_model, select_model_id, Modality, TaskRequirements,
|
||||
};
|
||||
use df_storage::crud::AiConversationRepo;
|
||||
use df_storage::db::Database;
|
||||
@@ -112,6 +112,15 @@ pub(crate) async fn ensure_conversation_title(
|
||||
};
|
||||
let title_model = select_model_id(&title_req, &provider_config.model_configs)
|
||||
.unwrap_or_else(|| provider_config.default_model.clone());
|
||||
// 防御:选中/兜底模型是图像模型时跳过 LLM(避免文本任务 404 刷屏,治 default_model 配错为图像模型)。
|
||||
// 跳过则保留上方 extract_title 兜底,不锁定差标题。
|
||||
if is_likely_image_model(&title_model, &provider_config.model_configs) {
|
||||
tracing::warn!(
|
||||
"标题 LLM 跳过:模型 {} 是图像模型,文本任务不可用(检查 provider default_model 应为文本模型)",
|
||||
title_model
|
||||
);
|
||||
return;
|
||||
}
|
||||
// B-260617-17: LLM 调用包 20s 超时,防信号量/网络挂起致后台 task 永久堆积;
|
||||
// 超时或返回 None 均保留上方已落的 extract 兜底,不覆盖。
|
||||
let title = match tokio::time::timeout(
|
||||
|
||||
Reference in New Issue
Block a user