Fix practice_area/appeal_subtype regression in search and case creation
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m55s
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m55s
The merge of ui-rewrite removed these parameters from db.search_similar() and db.create_case() but left the callers passing them, causing TypeError on any corpus search. Restores the parameters and adds schema migration. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -220,9 +220,14 @@ async def search_decisions(
|
||||
query: str,
|
||||
limit: int = 10,
|
||||
section_type: str = "",
|
||||
practice_area: str = "",
|
||||
appeal_subtype: str = "",
|
||||
case_number: str = "",
|
||||
) -> str:
|
||||
"""חיפוש סמנטי בהחלטות קודמות ובמסמכים."""
|
||||
return await search.search_decisions(query, limit, section_type)
|
||||
"""חיפוש סמנטי בהחלטות קודמות ובמסמכים — מסונן לפי תחום משפטי."""
|
||||
return await search.search_decisions(
|
||||
query, limit, section_type, practice_area, appeal_subtype, case_number,
|
||||
)
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
@@ -239,9 +244,14 @@ async def search_case_documents(
|
||||
async def find_similar_cases(
|
||||
description: str,
|
||||
limit: int = 5,
|
||||
practice_area: str = "",
|
||||
appeal_subtype: str = "",
|
||||
case_number: str = "",
|
||||
) -> str:
|
||||
"""מציאת תיקים דומים על בסיס תיאור."""
|
||||
return await search.find_similar_cases(description, limit)
|
||||
"""מציאת תיקים דומים על בסיס תיאור — מסונן לפי תחום משפטי."""
|
||||
return await search.find_similar_cases(
|
||||
description, limit, practice_area, appeal_subtype, case_number,
|
||||
)
|
||||
|
||||
|
||||
# Drafting
|
||||
|
||||
@@ -156,6 +156,8 @@ ALTER TABLE decisions ADD COLUMN IF NOT EXISTS outcome_reasoning TEXT DEFAULT ''
|
||||
|
||||
-- הרחבת cases עם appeal_type (אם לא קיים)
|
||||
ALTER TABLE cases ADD COLUMN IF NOT EXISTS appeal_type TEXT DEFAULT '';
|
||||
ALTER TABLE cases ADD COLUMN IF NOT EXISTS practice_area TEXT DEFAULT 'appeals_committee';
|
||||
ALTER TABLE cases ADD COLUMN IF NOT EXISTS appeal_subtype TEXT DEFAULT '';
|
||||
|
||||
-- טבלת qa_results
|
||||
CREATE TABLE IF NOT EXISTS qa_results (
|
||||
@@ -467,6 +469,8 @@ async def create_case(
|
||||
hearing_date: date | None = None,
|
||||
notes: str = "",
|
||||
expected_outcome: str = "",
|
||||
practice_area: str = "appeals_committee",
|
||||
appeal_subtype: str = "",
|
||||
) -> dict:
|
||||
pool = await get_pool()
|
||||
case_id = uuid4()
|
||||
@@ -474,13 +478,15 @@ async def create_case(
|
||||
await conn.execute(
|
||||
"""INSERT INTO cases (id, case_number, title, appellants, respondents,
|
||||
subject, property_address, permit_number, committee_type,
|
||||
hearing_date, notes, expected_outcome)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)""",
|
||||
hearing_date, notes, expected_outcome,
|
||||
practice_area, appeal_subtype)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)""",
|
||||
case_id, case_number, title,
|
||||
json.dumps(appellants or []),
|
||||
json.dumps(respondents or []),
|
||||
subject, property_address, permit_number, committee_type,
|
||||
hearing_date, notes, expected_outcome,
|
||||
practice_area, appeal_subtype,
|
||||
)
|
||||
return await get_case(case_id)
|
||||
|
||||
@@ -809,6 +815,8 @@ async def search_similar(
|
||||
limit: int = 10,
|
||||
case_id: UUID | None = None,
|
||||
section_type: str | None = None,
|
||||
practice_area: str | None = None,
|
||||
appeal_subtype: str | None = None,
|
||||
) -> list[dict]:
|
||||
"""Cosine similarity search on document chunks."""
|
||||
pool = await get_pool()
|
||||
@@ -824,6 +832,14 @@ async def search_similar(
|
||||
conditions.append(f"dc.section_type = ${param_idx}")
|
||||
params.append(section_type)
|
||||
param_idx += 1
|
||||
if practice_area:
|
||||
conditions.append(f"c.practice_area = ${param_idx}")
|
||||
params.append(practice_area)
|
||||
param_idx += 1
|
||||
if appeal_subtype:
|
||||
conditions.append(f"c.appeal_subtype = ${param_idx}")
|
||||
params.append(appeal_subtype)
|
||||
param_idx += 1
|
||||
|
||||
where = f"WHERE {' AND '.join(conditions)}" if conditions else ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user