fix(MAT-174): Stricter LLM filter prompt — exclude when in doubt

Require ALL criteria to clearly match. Exclude general articles,
category pages, unconfirmed locations. When in doubt, exclude.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Christian Gick
2026-03-16 14:17:49 +02:00
parent 6937b91fe3
commit bd65b12e5d

View File

@@ -15,10 +15,15 @@ LITELLM_URL = os.environ.get("LITELLM_BASE_URL", "")
LITELLM_KEY = os.environ.get("LITELLM_API_KEY", "")
FILTER_MODEL = os.environ.get("BASE_MODEL", "claude-haiku")
FILTER_SYSTEM_PROMPT = """You are a search result filter. Given a list of search results and filtering criteria, evaluate each result and return ONLY the ones that match the criteria.
FILTER_SYSTEM_PROMPT = """You are a strict search result filter. Given search results and filtering criteria, evaluate each result's title and description against ALL criteria. A result must clearly match EVERY criterion to be included. When in doubt, EXCLUDE.
Return a JSON array of indices (0-based) of results that match. If none match, return an empty array [].
Only return the JSON array, nothing else."""
Rules:
- If a result is a general article, category page, or ad rather than a specific listing, EXCLUDE it.
- If the location/region cannot be confirmed from the title or description, EXCLUDE it.
- If any single criterion is not met or unclear, EXCLUDE the result.
Return ONLY a JSON array of matching indices (0-based). If none match, return [].
No explanation, just the array."""
async def _llm_filter(results: list[dict], criteria: str) -> list[dict]: