feat(llm): improve logging and content processing

- Add 'keyword' to LLM processing log message for better context
- Replace simple string replace with regex for removing <think> tags in DeepseekR3 model
- The changes provide more precise logging and more robust content processing
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2025-11-05 10:35:54 -03:00
parent e3bd06ff54
commit ac9c1509d5
2 changed files with 4 additions and 2 deletions

View file

@ -13,7 +13,7 @@ pub fn llm_keyword(state: Arc<AppState>, _user: UserSession, engine: &mut Engine
.register_custom_syntax(&["LLM", "$expr$"], false, move |context, inputs| {
let text = context.eval_expression_tree(&inputs[0])?.to_string();
info!("LLM processing text: {}", text);
info!("LLM keyword processing text: {}", text);
let state_for_thread = Arc::clone(&state_clone);
let prompt = build_llm_prompt(&text);

View file

@ -1,4 +1,5 @@
use super::ModelHandler;
use regex;
pub struct DeepseekR3Handler;
@ -8,7 +9,8 @@ impl ModelHandler for DeepseekR3Handler {
}
fn process_content(&self, content: &str) -> String {
content.replace("<think>", "").replace("</think>", "")
let re = regex::Regex::new(r"<think>.*?</think>").unwrap();
re.replace_all(content, "").to_string()
}
fn has_analysis_markers(&self, buffer: &str) -> bool {