Spaces:
Sleeping
Sleeping
Update src/query_engine.py
Browse files5 unmodified lines678910111238 unmodified lines5152535455565 unmodified linesfrom typing import Dictfrom src.llm import generatefrom src.prompts import build_query_understanding_prompt, build_categorizer_promptdef _load_sql_schema_summary(sql_db_dir: str) -> str:38 unmodified lines"action": "continue",}def understand_query(user_query: str,cfg: Dict,5 unmodified lines678910111238 unmodified lines5152535455565758596061626364656667686970717273747576777879808182838485865 unmodified linesfrom typing import Dictfrom src.llm import generatefrom src.prompts import build_query_understanding_prompt, build_categorizer_prompt, build_init_querydef _load_sql_schema_summary(sql_db_dir: str) -> str:38 unmodified lines"action": "continue",}def init_query(user_query:str,cfg:Dict,conversation_history: list[dict] | None = None,):domain = cfg.get("chatbot", {}).get("domain", "research")cat_cfg = cfg.get("query_categorization", {})max_history = cat_cfg.get("max_history", 6)# Trim conversation historyhistory = conversation_history or []if len(history) > max_history:history = history[-max_history:]prompt = build_init_prompt(user_query, domain)try:raw = generate("You are a query-routing classifier. Return only JSON.",prompt,cfg,max_tokens=512,)return _parse_qcat_result(raw)except Exception:# LLM failure: fall back to raw queryreturn {"country": None,"value_chain": None,"investment": None,}def understand_query(user_query: str,cfg: Dict,
src/query_engine.py+31-1