|
47 | 47 | use serde::{Deserialize, Serialize}; |
48 | 48 | use tracing::{debug, info}; |
49 | 49 |
|
50 | | -use crate::llm::{LlmClient, LlmExecutor}; |
51 | 50 | use crate::llm::memo::{MemoKey, MemoOpType, MemoStore, MemoValue}; |
| 51 | +use crate::llm::{LlmClient, LlmExecutor}; |
52 | 52 | use crate::utils::fingerprint::Fingerprint; |
53 | 53 |
|
54 | 54 | /// Sub-query resulting from decomposition. |
@@ -269,30 +269,27 @@ impl QueryDecomposer { |
269 | 269 | info!("Decomposing complex query: '{}'", query); |
270 | 270 |
|
271 | 271 | // Try LLM-based decomposition if available |
272 | | - let result = if self.config.use_llm && (self.llm_client.is_some() || self.llm_executor.is_some()) { |
273 | | - match self.llm_decompose(query).await { |
274 | | - Ok(result) => result, |
275 | | - Err(e) => { |
276 | | - debug!( |
277 | | - "LLM decomposition failed, falling back to rule-based: {}", |
278 | | - e |
279 | | - ); |
280 | | - self.rule_based_decompose(query)? |
| 272 | + let result = |
| 273 | + if self.config.use_llm && (self.llm_client.is_some() || self.llm_executor.is_some()) { |
| 274 | + match self.llm_decompose(query).await { |
| 275 | + Ok(result) => result, |
| 276 | + Err(e) => { |
| 277 | + debug!( |
| 278 | + "LLM decomposition failed, falling back to rule-based: {}", |
| 279 | + e |
| 280 | + ); |
| 281 | + self.rule_based_decompose(query)? |
| 282 | + } |
281 | 283 | } |
282 | | - } |
283 | | - } else { |
284 | | - self.rule_based_decompose(query)? |
285 | | - }; |
| 284 | + } else { |
| 285 | + self.rule_based_decompose(query)? |
| 286 | + }; |
286 | 287 |
|
287 | 288 | // Cache the result |
288 | 289 | if let Some(ref store) = self.memo_store { |
289 | 290 | let cache_key = Self::build_cache_key(query); |
290 | 291 | if let Ok(json) = serde_json::to_value(&CachedDecomposition::from_result(&result)) { |
291 | | - store.put_with_tokens( |
292 | | - cache_key, |
293 | | - MemoValue::Json(json), |
294 | | - (query.len() / 4) as u64, |
295 | | - ); |
| 292 | + store.put_with_tokens(cache_key, MemoValue::Json(json), (query.len() / 4) as u64); |
296 | 293 | } |
297 | 294 | } |
298 | 295 |
|
|
0 commit comments