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:
+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