Nelly-43 commited on
Commit
e3a278f
·
verified ·
1 Parent(s): 9646cb8

Update src/query_engine.py

Browse files
Files changed (1) hide show
  1. src/query_engine.py +4 -32
src/query_engine.py CHANGED
@@ -163,9 +163,7 @@ def init_query(user_query:str,
163
  }
164
 
165
  def understand_query(
166
- user_query: str,
167
- cfg: Dict,
168
- conversation_history: list[Dict] | None = None,
169
  ) -> dict:
170
  """Analyze and reformulate a user query for better retrieval.
171
 
@@ -186,27 +184,8 @@ def understand_query(
186
  - ``original_query``: The raw user input
187
  - ``clarification_question``: Question to ask (only if action is "clarify")
188
  """
189
- qu_cfg = cfg.get("query_understanding", {})
190
-
191
- # Disabled: pass through raw query
192
- if not qu_cfg.get("enabled", True):
193
- return {
194
- "action": "search",
195
- "search_query": user_query,
196
- "display_query": user_query,
197
- "original_query": user_query,
198
- "route": "vector",
199
- "sql_query": None,
200
- }
201
-
202
  domain = cfg.get("chatbot", {}).get("domain", "research")
203
- max_history = qu_cfg.get("max_history", 6)
204
-
205
- # Trim conversation history
206
- history = conversation_history or []
207
- if len(history) > max_history:
208
- history = history[-max_history:]
209
-
210
  # Load SQL schema summary for prompt injection
211
  sql_enabled = cfg.get("sql", {}).get("enabled", True)
212
  schema_summary = ""
@@ -223,7 +202,7 @@ def understand_query(
223
  kb_overview = load_kb_meta(cfg)
224
 
225
  prompt = build_query_understanding_prompt(
226
- user_query, domain, history,
227
  sql_schema_summary=schema_summary,
228
  kb_overview=kb_overview,
229
  )
@@ -238,14 +217,7 @@ def understand_query(
238
  result = _parse_qu_result(raw, user_query)
239
  except Exception:
240
  # LLM failure: fall back to raw query
241
- result = {
242
- "action": "search",
243
- "search_query": user_query,
244
- "display_query": user_query,
245
- "original_query": user_query,
246
- "route": "vector",
247
- "sql_query": None,
248
- }
249
 
250
  return result
251
 
 
163
  }
164
 
165
  def understand_query(
166
+ cfg: Dict
 
 
167
  ) -> dict:
168
  """Analyze and reformulate a user query for better retrieval.
169
 
 
184
  - ``original_query``: The raw user input
185
  - ``clarification_question``: Question to ask (only if action is "clarify")
186
  """
187
+
 
 
 
 
 
 
 
 
 
 
 
 
188
  domain = cfg.get("chatbot", {}).get("domain", "research")
 
 
 
 
 
 
 
189
  # Load SQL schema summary for prompt injection
190
  sql_enabled = cfg.get("sql", {}).get("enabled", True)
191
  schema_summary = ""
 
202
  kb_overview = load_kb_meta(cfg)
203
 
204
  prompt = build_query_understanding_prompt(
205
+ domain,
206
  sql_schema_summary=schema_summary,
207
  kb_overview=kb_overview,
208
  )
 
217
  result = _parse_qu_result(raw, user_query)
218
  except Exception:
219
  # LLM failure: fall back to raw query
220
+ result = None
 
 
 
 
 
 
 
221
 
222
  return result
223