Intelligent Query Repair with Learning and Retries Strategies: 1. Check memory for known fix 2. Apply Python-level validation 3. Get LLM to fix with detailed context 4. Retry with increasingly specific instructions 5. Record successful fix in memory
"""
Intelligent Query Repair with Learning and Retries
Strategies:
1. Check memory for known fix
2. Apply Python-level validation
3. Get LLM to fix with detailed context
4. Retry with increasingly specific instructions
5. Record successful fix in memory
"""
import json
import logging
import time
import re
from typing import Optional, Tuple, Callable
from core.query_repair_memory import get_memory, QueryRepairMemory, _normalize_error
logger = logging.getLogger(__name__)
def _is_time_field(field_name: str) -> bool:
lowered = str(field_name or "").lower()
return lowered == "@timestamp" or any(token in lowered for token in ("timestamp", "date", "time"))
def _is_date_like_string(value: str) -> bool:
if not isinstance(value, str):
return False
text = value.strip().
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key