fix: 优化markdown解析器

This commit is contained in:
imeepos 2025-07-22 18:15:52 +08:00
parent 66c737e2ed
commit cd7e9b351d
1 changed files with 11 additions and 10 deletions

View File

@ -1108,17 +1108,18 @@ impl GeminiService {
conversation_context.history_included = true;
// 添加系统提示(如果有)
if let Some(system_prompt) = &request.system_prompt {
contents.push(ContentPart {
role: "system".to_string(),
parts: vec![Part::Text { text: system_prompt.clone() }],
});
let system_prompt = if let Some(system_prompt) = &request.system_prompt {
system_prompt.clone()
} else if let Some(default_prompt) = &rag_config.system_prompt {
contents.push(ContentPart {
role: "system".to_string(),
parts: vec![Part::Text { text: default_prompt.clone() }],
});
}
default_prompt.clone()
} else {
return Err(anyhow::anyhow!("系统提示词不能为空,请在请求中提供 system_prompt 或在配置中设置默认 system_prompt"));
};
contents.push(ContentPart {
role: "system".to_string(),
parts: vec![Part::Text { text: system_prompt }],
});
// 添加历史消息
for msg in &history_messages {