feat: конвейер ingest→SQLite, API на БД, фронт сравнения цен
- etl/pipeline.py — extract→normalize→validate→SQLite, дедуп партнёров, версии цен, отчёт качества
- api/main.py — 7 эндпоинтов на SQLite; ядро /services/{id}/partners (сравнение)
- web/index.html — одностраничный фронт (палитра Nomad): поиск, сравнение, дашборд, unmatched
- загрузчик справочника: уникальный service_id
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,8 +18,12 @@ from etl.extractors import readers # noqa: E402
|
||||
from etl.extractors.grid import extract_rows_from_grid # noqa: E402
|
||||
|
||||
|
||||
def extract(path: str) -> ParsedDocument:
|
||||
"""Разобрать один файл прайса в структурированный ParsedDocument."""
|
||||
def extract(path: str, use_vision: bool = True) -> ParsedDocument:
|
||||
"""Разобрать один файл прайса в структурированный ParsedDocument.
|
||||
|
||||
use_vision=False отключает добор через Gemini Vision (быстрый прогон без
|
||||
обращений к API), даже если ключ задан.
|
||||
"""
|
||||
name = Path(path).name
|
||||
fmt = readers.detect_format(path)
|
||||
doc = ParsedDocument(file_name=name, file_format=fmt, partner_name=readers.partner_from_name(name))
|
||||
@@ -55,7 +59,7 @@ def extract(path: str) -> ParsedDocument:
|
||||
doc.parse_log.append(f"ошибка разбора таблицы: {type(exc).__name__}: {exc}")
|
||||
|
||||
# Трудные PDF (скан, битый слой, нулевой разбор) добираем через Gemini Vision.
|
||||
needs_vision = fmt == "pdf" and (doc.file_format == "scan_pdf" or not doc.rows)
|
||||
needs_vision = use_vision and fmt == "pdf" and (doc.file_format == "scan_pdf" or not doc.rows)
|
||||
if needs_vision and os.environ.get("GEMINI_API_KEY"):
|
||||
try:
|
||||
from etl.extractors.vision import extract_with_vision
|
||||
|
||||
Reference in New Issue
Block a user