feat: batch V2 — показываем паттерны вместо скрипта + ссылка с главной
- Claude генерирует batch_summary.json с найденными паттернами - UI показывает сметчику: лист, шифр, паттерны итогов, маппинг столбцов - Скрипт скрыт в <details> для разработчиков - Кнопка «Пакетная V2» на главной странице чата Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+44
-3
@@ -196,7 +196,41 @@ NOTE: In the script, use the `target_file` variable (not a hardcoded path).
|
||||
1. Read the sample CSV files in /data/sample_csv/ — understand their structure
|
||||
2. Read the target CSV files in /data/target_csv/ — understand where data goes
|
||||
3. Figure out: what to extract from each source, how to match to target rows
|
||||
4. Write a COMPLETE Python script to /data/batch_script.py
|
||||
4. Write TWO files:
|
||||
|
||||
### File 1: /data/batch_summary.json — human-readable summary for the user
|
||||
JSON with these fields (in Russian):
|
||||
```json
|
||||
{{
|
||||
"description": "Краткое описание что будет сделано",
|
||||
"source_patterns": {{
|
||||
"sheet": "на каком листе искать данные",
|
||||
"id_field": "где шифр/название сметы (например: имя файла, ячейка B5)",
|
||||
"totals": {{
|
||||
"строительные работы": "паттерн поиска (например: ВСЕГО строительные работы)",
|
||||
"монтажные работы": "паттерн поиска",
|
||||
"оборудование": "паттерн поиска",
|
||||
"прочие затраты": "паттерн поиска"
|
||||
}},
|
||||
"value_column": "в каком столбце значения (например: A или H)",
|
||||
"units": "рубли или тыс.руб"
|
||||
}},
|
||||
"target_mapping": {{
|
||||
"sheet": "на какой лист сводного файла записывать",
|
||||
"match_column": "столбец с шифрами для сопоставления (например: B)",
|
||||
"value_columns": {{
|
||||
"строительные работы": "столбец (например: D)",
|
||||
"монтажные работы": "столбец (например: E)",
|
||||
"оборудование": "столбец (например: F)",
|
||||
"прочие затраты": "столбец (например: G)"
|
||||
}},
|
||||
"units": "тыс.руб"
|
||||
}},
|
||||
"conversion": "делить на 1000 (руб → тыс.руб)" или "без конвертации"
|
||||
}}
|
||||
```
|
||||
|
||||
### File 2: /data/batch_script.py — Python script
|
||||
|
||||
## CRITICAL: The script will run on ALL {total_xlsx_count} files, not just samples!
|
||||
The script must handle any file with the same general structure as the samples.
|
||||
@@ -303,12 +337,19 @@ async def run_claude_analysis(
|
||||
elif etype == "result":
|
||||
got_result = True
|
||||
script_path = job_dir / "batch_script.py"
|
||||
summary_path = job_dir / "batch_summary.json"
|
||||
summary = {}
|
||||
if summary_path.exists():
|
||||
try:
|
||||
summary = json.loads(summary_path.read_text(encoding="utf-8"))
|
||||
except (json.JSONDecodeError, OSError):
|
||||
pass
|
||||
if script_path.exists():
|
||||
script = script_path.read_text(encoding="utf-8")
|
||||
yield {"type": "done", "script": script}
|
||||
yield {"type": "done", "script": script, "summary": summary}
|
||||
else:
|
||||
result_text = event.get("result", "")
|
||||
yield {"type": "done", "script": "", "result": result_text}
|
||||
yield {"type": "done", "script": "", "result": result_text, "summary": summary}
|
||||
|
||||
finally:
|
||||
if proc.returncode is None:
|
||||
|
||||
Reference in New Issue
Block a user