Fix precedents search + auto-update case parties

block_writer: _build_precedents_context now searches both
paragraph_embeddings (other decisions by Dafna) and case_law_embeddings
(precedent case law). Previously only searched document_chunks which
had no cross-case data. Now returns ~2400 chars from 3 other decisions.

processor: Step 1.6 auto-updates case appellants/respondents from
classifier results when they're empty. Prevents blank party fields.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-03 11:59:33 +00:00
parent 52beb6ebdc
commit 7781987c3a
2 changed files with 49 additions and 9 deletions

View File

@@ -57,6 +57,18 @@ async def process_document(document_id: UUID, case_id: UUID) -> dict:
len(classification_result["parties"].get("respondents", [])),
)
# Step 1.6: Update case parties if empty
if case_id and case:
parties = classification_result.get("parties", {})
updates = {}
if not case.get("appellants") and parties.get("appellants"):
updates["appellants"] = parties["appellants"]
if not case.get("respondents") and parties.get("respondents"):
updates["respondents"] = parties["respondents"]
if updates:
await db.update_case(case_id, **updates)
logger.info("Updated case parties: %s", updates)
# Step 2: Chunk
logger.info("Chunking document (%d chars)", len(text))
chunks = chunker.chunk_document(text)