feat: агентный путь (Docker sandbox) — паритет по форматам .xls/.doc/OCR
Паритет agent-пути с GLM: read_xlsx_sheet читает .xls через xlrd; в образ песочницы добавлены catdoc (.doc), tesseract-ocr+rus (OCR PDF), xlrd/pytesseract/pillow (pip). parse_gsfx_file/parse_arp_file уже доступны агенту (gge_tools/smeta_mcp монтируются). Образ smeta-claude-sandbox пересобран. Real-тест: read_xlsx_sheet(.xls) в песочнице → 1926 строк. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+5
-2
@@ -1,13 +1,16 @@
|
|||||||
FROM node:22-slim
|
FROM node:22-slim
|
||||||
|
|
||||||
# Python + libs for file processing + smeta-railway deps
|
# Python + libs for file processing + smeta-railway deps
|
||||||
|
# catdoc — старые .doc (OLE2); tesseract-ocr + rus — OCR PDF-сканов
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
python3 python3-pip python3-venv && \
|
python3 python3-pip python3-venv \
|
||||||
|
catdoc tesseract-ocr tesseract-ocr-rus && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN pip3 install --break-system-packages --no-cache-dir \
|
RUN pip3 install --break-system-packages --no-cache-dir \
|
||||||
openpyxl python-docx pymupdf pandas \
|
openpyxl python-docx pymupdf pandas \
|
||||||
faiss-cpu pyyaml pydantic typer openai rank-bm25
|
faiss-cpu pyyaml pydantic typer openai rank-bm25 \
|
||||||
|
xlrd pytesseract pillow
|
||||||
|
|
||||||
# Claude Code CLI
|
# Claude Code CLI
|
||||||
RUN npm install -g @anthropic-ai/claude-code
|
RUN npm install -g @anthropic-ai/claude-code
|
||||||
|
|||||||
+28
-1
@@ -56,8 +56,35 @@ def tool_read_xlsx_sheet(*, filename: str, sheet: str | None = None, max_rows: i
|
|||||||
fpath = _work_dir(user, tab) / Path(filename).name
|
fpath = _work_dir(user, tab) / Path(filename).name
|
||||||
if not fpath.exists():
|
if not fpath.exists():
|
||||||
return {"error": f"Файл «{filename}» не найден"}
|
return {"error": f"Файл «{filename}» не найден"}
|
||||||
if fpath.suffix.lower() not in {".xlsx", ".xlsm", ".xls"}:
|
ext = fpath.suffix.lower()
|
||||||
|
if ext not in {".xlsx", ".xlsm", ".xls"}:
|
||||||
return {"error": f"Неподдерживаемый формат: {fpath.suffix}"}
|
return {"error": f"Неподдерживаемый формат: {fpath.suffix}"}
|
||||||
|
if ext == ".xls":
|
||||||
|
# Легаси BIFF — openpyxl не умеет, читаем через xlrd.
|
||||||
|
try:
|
||||||
|
import xlrd
|
||||||
|
from openpyxl.utils import get_column_letter
|
||||||
|
except ImportError:
|
||||||
|
return {"error": "Чтение .xls требует xlrd (нет в окружении)"}
|
||||||
|
try:
|
||||||
|
book = xlrd.open_workbook(str(fpath))
|
||||||
|
except Exception as e:
|
||||||
|
return {"error": f"Не удалось открыть .xls: {e}"}
|
||||||
|
names = book.sheet_names()
|
||||||
|
sh = book.sheet_by_name(sheet) if sheet in names else book.sheet_by_index(0)
|
||||||
|
rows_x: list[dict] = []
|
||||||
|
real_x = 0
|
||||||
|
for r in range(sh.nrows):
|
||||||
|
cells = {get_column_letter(c + 1): str(sh.cell_value(r, c))[:300]
|
||||||
|
for c in range(sh.ncols)
|
||||||
|
if str(sh.cell_value(r, c)).strip()}
|
||||||
|
if not cells:
|
||||||
|
continue
|
||||||
|
real_x += 1
|
||||||
|
if len(rows_x) < max_rows:
|
||||||
|
rows_x.append({"row": r + 1, "cells": cells})
|
||||||
|
return {"filename": fpath.name, "sheet": sh.name, "all_sheets": names,
|
||||||
|
"rows_with_data_total": real_x, "rows_returned": len(rows_x), "rows": rows_x}
|
||||||
try:
|
try:
|
||||||
wb = openpyxl.load_workbook(str(fpath), data_only=True)
|
wb = openpyxl.load_workbook(str(fpath), data_only=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user