/
yakobsonsa
/
bi_agent
Обзор
Документация
Войти
/
yakobsonsa
/
bi_agent
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/interfaces/sql_validator.py
60 строк
1 KB
Yakobsonsa
first_commit
01 фев 2026, 22:53
01 фев 2026, 22:53
20245d9
Код
Авторство
О чём код?
"""Interface for SQL validation.""" from abc import ABC, abstractmethod from typing import Dict, Tuple, Any class ISQLValidator(ABC): """ Interface for SQL query validation. Provides validation and auto-correction of SQL queries against database schema. """ @abstractmethod def validate(self, sql: str) -> Dict[str, Any]: """ Validate SQL query against schema. Args: sql: SQL query string Returns: Dict with keys: - valid: bool - whether SQL is valid - errors: List[str] - validation error messages - warnings: List[str] - non-critical warnings """ pass @abstractmethod def fix_hallucinations(self, sql: str) -> Tuple[str, bool]: """ Auto-fix common LLM hallucinations in SQL. Fixes: - Non-existent column names - Wrong table names - Syntax errors Args: sql: Original SQL query Returns: Tuple of (fixed_sql, was_modified) """ pass @abstractmethod def normalize_sql(self, sql: str) -> str: """ Normalize SQL query formatting. Args: sql: Raw SQL string Returns: Normalized SQL string """ pass