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:
parent
e3bd06ff54
commit
ac9c1509d5
2 changed files with 4 additions and 2 deletions
|
|
@ -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| {
|
.register_custom_syntax(&["LLM", "$expr$"], false, move |context, inputs| {
|
||||||
let text = context.eval_expression_tree(&inputs[0])?.to_string();
|
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 state_for_thread = Arc::clone(&state_clone);
|
||||||
let prompt = build_llm_prompt(&text);
|
let prompt = build_llm_prompt(&text);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use super::ModelHandler;
|
use super::ModelHandler;
|
||||||
|
use regex;
|
||||||
|
|
||||||
pub struct DeepseekR3Handler;
|
pub struct DeepseekR3Handler;
|
||||||
|
|
||||||
|
|
@ -8,7 +9,8 @@ impl ModelHandler for DeepseekR3Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_content(&self, content: &str) -> String {
|
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 {
|
fn has_analysis_markers(&self, buffer: &str) -> bool {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue