feat(corroboration): halacha matcher + cosine threshold (INV-COR3, X11)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3386,6 +3386,18 @@ async def update_halacha(
|
||||
return dict(row) if row else None
|
||||
|
||||
|
||||
async def nearest_halacha_for_vector(case_law_id: UUID, vec: list[float]) -> tuple[str, float] | None:
|
||||
"""Best-matching halacha of `case_law_id` for a context embedding (cosine)."""
|
||||
pool = await get_pool()
|
||||
row = await pool.fetchrow(
|
||||
"SELECT id::text AS id, 1 - (embedding <=> $2) AS sim "
|
||||
"FROM halachot WHERE case_law_id = $1 AND embedding IS NOT NULL "
|
||||
"ORDER BY embedding <=> $2 LIMIT 1",
|
||||
case_law_id, vec,
|
||||
)
|
||||
return (row["id"], float(row["sim"])) if row else None
|
||||
|
||||
|
||||
async def search_precedent_library_semantic(
|
||||
query_embedding: list[float],
|
||||
practice_area: str = "",
|
||||
|
||||
Reference in New Issue
Block a user