- Unify API: lib/api.ts uses /api/v1, inbox uses /api/inbox (rewrites) - Remove localhost refs: openapi, inbox page - Add rewrites: /api/inbox|tmc -> inbox-server, /api/v1 -> FastAPI - Add stub routes: knowledge/insights, recommendations, search, log-error - Transfer from PAPA: prompts (inspection, tmc), scripts, supabase, data/tmc-requests - Fix inbox-server: ORDER BY created_at, package.json - Remove redundant app/api/inbox/files route (rewrites handle it) - knowledge/ in gitignore (large PDFs) Co-authored-by: Cursor <cursoragent@cursor.com>
52 lines
2.2 KiB
Python
52 lines
2.2 KiB
Python
"""
|
|
Агент проверки соответствия документа нормам законодательства выбранной юрисдикции.
|
|
"""
|
|
|
|
import json
|
|
from .base import BaseLegalAgent, AgentResult
|
|
|
|
|
|
class NormComplianceAgent(BaseLegalAgent):
|
|
def __init__(self, llm_client=None):
|
|
super().__init__("NormComplianceAgent", llm_client)
|
|
|
|
def run(self, context: dict) -> AgentResult:
|
|
title = context.get("title", "")
|
|
content = (context.get("content") or "")[:8000]
|
|
jurisdiction = context.get("jurisdiction_code", "RU")
|
|
doc_type = context.get("document_type", "other")
|
|
|
|
system = (
|
|
"Ты — юрист, проверяющий соответствие документа нормам законодательства указанной юрисдикции. "
|
|
"Верни JSON: {\"compliant\": true|false, \"issues\": [\"...\"], \"recommendations\": [\"...\"], \"summary\": \"...\"}"
|
|
)
|
|
user = f"Юрисдикция: {jurisdiction}, тип документа: {doc_type}\nЗаголовок: {title}\n\nТекст:\n{content[:4000]}"
|
|
|
|
out = self._call_llm(system, user, json_mode=True)
|
|
if out:
|
|
try:
|
|
data = json.loads(out)
|
|
return AgentResult(
|
|
True,
|
|
{
|
|
"compliant": bool(data.get("compliant", True)),
|
|
"issues": data.get("issues") or [],
|
|
"recommendations": data.get("recommendations") or [],
|
|
"summary": data.get("summary") or "",
|
|
},
|
|
agent_name=self.name,
|
|
)
|
|
except (json.JSONDecodeError, TypeError):
|
|
pass
|
|
|
|
return AgentResult(
|
|
True,
|
|
{
|
|
"compliant": True,
|
|
"issues": [],
|
|
"recommendations": ["Рекомендуется провести ручную проверку на соответствие нормам (LLM недоступен)."],
|
|
"summary": "Автоматическая проверка недоступна.",
|
|
},
|
|
agent_name=self.name,
|
|
)
|