Add Attorney AI agent (substantive strategy memo)
- fl.attorney.agent (AbstractModel): manual-only substantive analysis fired from the case AI tab. Builds a full case context (parties, children, financials, issue tags, prior analyses) plus candidate statute/caselaw lists, and asks Claude to author a strategy memo, draft arguments/counterarguments, write a risk narrative, and assess substantial change (FL 61.30(1)(b)) - Grounds output in the real library: the model may only pick statutes/case law from the supplied candidates, which are then resolved back to records and linked (fl.analysis.cited_statute_ids / matched_caselaw_ids, case.caselaw_ids) - Rule-based fallback produces a usable memo (complexity, statutes by category, caselaw by tag, risk flags) when the API is unavailable — never a raw error - fl.analysis: add analysis_type, strategy_memo (Html), risk_narrative, cited_statute_ids; surface them in the analysis views - fl.case: add attorney_memo_id + related memo/risk display; action_run_attorney_agent opens the memo; "Generate Attorney Strategy Memo" button on the AI tab (admin) - Refactor fl_ai_engine: extract shared call_claude_json(system, user) + _extract_json so both agents and the engine share one Claude/JSON path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,10 @@ class FlAnalysis(models.Model):
|
||||
case_id = fields.Many2one(
|
||||
'fl.case', ondelete='cascade', index=True
|
||||
)
|
||||
analysis_type = fields.Selection([
|
||||
('engine', 'AI Engine Analysis'),
|
||||
('attorney', 'Attorney Strategy Memo'),
|
||||
], string='Analysis Type', default='engine')
|
||||
analysis_date = fields.Datetime(
|
||||
string='Analysis Date',
|
||||
default=fields.Datetime.now
|
||||
@@ -36,6 +40,23 @@ class FlAnalysis(models.Model):
|
||||
help='Resumen en español — sin jerga legal'
|
||||
)
|
||||
|
||||
# ── Attorney Strategy Memo ─────────────────────────────────────────────
|
||||
strategy_memo = fields.Html(
|
||||
string='Strategy Memo',
|
||||
help='Substantive strategy memo authored by the Attorney agent.'
|
||||
)
|
||||
risk_narrative = fields.Text(
|
||||
string='Risk Narrative',
|
||||
help='Narrative of substantive risks: DV, hidden assets, income '
|
||||
'imputation, unrepresented respondent, etc.'
|
||||
)
|
||||
cited_statute_ids = fields.Many2many(
|
||||
'fl.statute',
|
||||
'fl_analysis_statute_rel',
|
||||
'analysis_id', 'statute_id',
|
||||
string='Cited Statutes'
|
||||
)
|
||||
|
||||
# ── Analysis Detail (Phase 5) ──────────────────────────────────────────
|
||||
petitioner_arguments = fields.Text(
|
||||
string='Petitioner Arguments (JSON)'
|
||||
|
||||
Reference in New Issue
Block a user