feat: ФОТ/ед в find_in_real_estimates + корпус-tools в агентный Claude-путь
Эксперимент подтвердил: агентный Claude (claude_bridge, Docker) сам вызывает find_in_real_estimates и берёт РЕАЛЬНЫЕ коды/цены — без фабрикации (в отличие от glm single-pass). Но НР/СП считал на сыром salary из cost_structure (неверный масштаб). Фикс: find_in_real_estimates отдаёт fot_unit (ФОТ/ед, масштабирован к цене/ед) — корректный базис для НР/СП обоим путям. В claude_bridge домонтированы real_corpus/gge_deep/data + find_in_real_estimates/find_ka_price/find_in_vor в allowedTools — агентный путь получил корпус. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+15
-1
@@ -142,10 +142,14 @@ async def stream_claude(
|
||||
smeta_mcp_path = APP_DIR / "smeta_mcp.py"
|
||||
smeta_complaints_path = APP_DIR / "complaints.py"
|
||||
smeta_gge_tools_path = APP_DIR / "gge_tools.py"
|
||||
smeta_gge_deep_path = APP_DIR / "gge_deep.py"
|
||||
smeta_corpus_path = APP_DIR / "real_corpus.py"
|
||||
smeta_corpus_data = APP_DIR / "data" / "real_corpus"
|
||||
smeta_mcp_config = APP_DIR / "sandbox" / "mcp_config.json"
|
||||
mcp_available = (smeta_mcp_path.exists() and smeta_complaints_path.exists()
|
||||
and smeta_gge_tools_path.exists()
|
||||
and smeta_mcp_config.exists())
|
||||
corpus_available = smeta_corpus_path.exists() and smeta_corpus_data.exists()
|
||||
|
||||
claude_args = [
|
||||
"-p", message,
|
||||
@@ -159,7 +163,10 @@ async def stream_claude(
|
||||
"mcp__smeta__apply_pukts_to_registry,"
|
||||
"mcp__smeta__parse_gge_archive,"
|
||||
"mcp__smeta__parse_gge_file,"
|
||||
"mcp__smeta__update_xlsx_cells"),
|
||||
"mcp__smeta__update_xlsx_cells,"
|
||||
"mcp__smeta__find_in_real_estimates,"
|
||||
"mcp__smeta__find_ka_price,"
|
||||
"mcp__smeta__find_in_vor"),
|
||||
]
|
||||
if mcp_available:
|
||||
claude_args.extend(["--mcp-config", "/app/mcp_config.json"])
|
||||
@@ -192,6 +199,13 @@ async def stream_claude(
|
||||
"-v", f"{smeta_gge_tools_path.resolve()}:/app/gge_tools.py:ro",
|
||||
"-v", f"{smeta_mcp_config.resolve()}:/app/mcp_config.json:ro",
|
||||
])
|
||||
if corpus_available:
|
||||
# Корпус реальных смет — для агентного расчёта (find_in_real_estimates)
|
||||
cmd.extend([
|
||||
"-v", f"{smeta_gge_deep_path.resolve()}:/app/gge_deep.py:ro",
|
||||
"-v", f"{smeta_corpus_path.resolve()}:/app/real_corpus.py:ro",
|
||||
"-v", f"{smeta_corpus_data.resolve()}:/app/data/real_corpus:ro",
|
||||
])
|
||||
if instructions.exists():
|
||||
cmd.extend(["-v", f"{instructions.resolve()}:/instructions.md:ro"])
|
||||
|
||||
|
||||
@@ -348,10 +348,8 @@ def _search_corpus(message: str) -> str:
|
||||
ov = r.get("overhead") or {}
|
||||
pr = r.get("profit") or {}
|
||||
regs = ", ".join(r.get("regions") or [])
|
||||
# ФОТ/ед для расчёта НР/СП (НР и СП начисляются на ФОТ)
|
||||
cs = r.get("cost_structure") or {}
|
||||
direct = sum(cs.get(k, 0) or 0 for k in ("machines", "materials", "salary", "machinist_salary"))
|
||||
fot_unit = round(r["unit_cost_cur"] * (cs.get("salary", 0) or 0) / direct, 2) if direct > 0 else None
|
||||
# ФОТ/ед для расчёта НР/СП (find_in_real_estimates считает масштаб)
|
||||
fot_unit = r.get("fot_unit")
|
||||
fot_str = f" | ФОТ/ед ≈ {fot_unit} руб (база для НР/СП)" if fot_unit else ""
|
||||
lines.append(
|
||||
f"[{code}] {r['name']} | {r['unit']} | цена/ед(тек прямые) = {r['unit_cost_cur']} руб"
|
||||
|
||||
+19
-2
@@ -128,10 +128,27 @@ def find_in_real_estimates(query: str, top_k: int = 5) -> list[dict]:
|
||||
results.append((score, it["freq"], it))
|
||||
results.sort(key=lambda x: (x[0], x[1]), reverse=True)
|
||||
keys = ("code", "name", "unit", "prefix", "kind", "freq", "norm_sets", "regions",
|
||||
"qty", "comment", "unit_cost_cur", "cost_structure", "labor_ch",
|
||||
"qty", "comment", "unit_cost_cur", "fot_unit", "cost_structure", "labor_ch",
|
||||
"machinist_ch", "price_base", "price_cur", "overhead", "profit",
|
||||
"coef_applications", "resources", "examples")
|
||||
return [{k: it.get(k) for k in keys} for _, _, it in results[:top_k]]
|
||||
out = []
|
||||
for _, _, it in results[:top_k]:
|
||||
d = {k: it.get(k) for k in keys}
|
||||
d["fot_unit"] = _fot_per_unit(it) # ФОТ/ед (база для НР/СП), масштабирован к цене/ед
|
||||
out.append(d)
|
||||
return out
|
||||
|
||||
|
||||
def _fot_per_unit(item: dict) -> float | None:
|
||||
"""ФОТ на единицу = цена/ед × (доля ОТ в прямых затратах). cost_structure —
|
||||
сырой итог вхождения; берём из него ДОЛЮ (безразмерную) и масштабируем к
|
||||
unit_cost_cur. Без этого НР/СП считаются на неверном масштабе ФОТ."""
|
||||
cs = item.get("cost_structure") or {}
|
||||
direct = sum(cs.get(k, 0) or 0 for k in ("machines", "materials", "salary", "machinist_salary"))
|
||||
uc = item.get("unit_cost_cur") or 0
|
||||
if direct <= 0 or uc <= 0:
|
||||
return None
|
||||
return round(uc * (cs.get("salary", 0) or 0) / direct, 2)
|
||||
|
||||
|
||||
def find_ka_price(query: str, top_k: int = 5) -> list[dict]:
|
||||
|
||||
Reference in New Issue
Block a user