Commit 075c9528 authored by Vũ Hoàng Anh's avatar Vũ Hoàng Anh

fix(search): remove deprecated preference import and enforce internal SearchEngine

parent 33ca1424
...@@ -17,19 +17,8 @@ PROJECT_ROOT = Path(__file__).resolve().parents[3] ...@@ -17,19 +17,8 @@ PROJECT_ROOT = Path(__file__).resolve().parents[3]
if str(PROJECT_ROOT) not in sys.path: if str(PROJECT_ROOT) not in sys.path:
sys.path.append(str(PROJECT_ROOT)) sys.path.append(str(PROJECT_ROOT))
try: # Preference module is deprecated; use internal SearchEngine only.
from preference.lead_stage_agent.product_search_engine import ( ProductSearchEngine = None
InferredSearch as ProductInferredSearch,
LeadSearchInput,
LiteralSearch as ProductLiteralSearch,
ProductSearchEngine,
)
except Exception as exc: # pragma: no cover - exercised only when optional import is unavailable
ProductInferredSearch = None
ProductLiteralSearch = None
ProductSearchEngine = None
LeadSearchInput = None
logger.warning("ProductSearchEngine import failed; legacy SearchEngine fallback will be used: %s", exc)
class LiteralSearch(BaseModel): class LiteralSearch(BaseModel):
...@@ -336,14 +325,10 @@ async def data_retrieval_tool( ...@@ -336,14 +325,10 @@ async def data_retrieval_tool(
literal_text = _build_literal_text(item) literal_text = _build_literal_text(item)
logger.info("[Tool] Searching via ProductSearchEngine: %s", literal_text) logger.info("[Tool] Searching via ProductSearchEngine: %s", literal_text)
try: try:
result = await _run_product_search_engine(
item,
reasoning=reasoning,
user_insight=shared_user_insight,
)
except Exception as exc:
logger.exception("ProductSearchEngine failed; falling back to legacy engine: %s", exc)
result = await _run_legacy_engine(item, use_sqlite=use_sqlite) result = await _run_legacy_engine(item, use_sqlite=use_sqlite)
except Exception as exc:
logger.exception("SearchEngine failed: %s", exc)
result = {"status": "error", "message": str(exc), "products": []}
if result.get("status") == "error": if result.get("status") == "error":
errors.append(str(result.get("message", "unknown error"))) errors.append(str(result.get("message", "unknown error")))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment