Files
ai-tax-agent/libs/rag/utils.py
harkon b324ff09ef
Some checks failed
CI/CD Pipeline / Code Quality & Linting (push) Has been cancelled
CI/CD Pipeline / Policy Validation (push) Has been cancelled
CI/CD Pipeline / Test Suite (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-firm-connectors) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-forms) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-hmrc) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ingestion) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-normalize-map) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-ocr) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-indexer) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-reason) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (svc-rpa) (push) Has been cancelled
CI/CD Pipeline / Build Docker Images (ui-review) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-coverage) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-extract) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-kg) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (svc-rag-retriever) (push) Has been cancelled
CI/CD Pipeline / Security Scanning (ui-review) (push) Has been cancelled
CI/CD Pipeline / Generate SBOM (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / Notifications (push) Has been cancelled
Initial commit
2025-10-11 08:41:36 +01:00

45 lines
1.3 KiB
Python

"""Coverage-specific RAG utility functions."""
from typing import Any
import structlog
from libs.schemas.coverage.evaluation import Citation
logger = structlog.get_logger()
async def rag_search_for_citations(
rag_client: Any, query: str, filters: dict[str, Any] | None = None
) -> list["Citation"]:
"""Search for citations using RAG with PII-free filtering"""
try:
# Ensure PII-free filter is always applied
search_filters = filters or {}
search_filters["pii_free"] = True
# This would integrate with the actual RAG retrieval system
# For now, return a placeholder implementation
logger.debug(
"RAG citation search called",
query=query,
filters=search_filters,
rag_client_available=rag_client is not None,
)
# Placeholder citations - in production this would call the RAG system
citations = [
Citation(
doc_id=f"RAG-{query.replace(' ', '-')[:20]}",
locator="Retrieved via RAG search",
url=f"https://guidance.example.com/search?q={query}",
)
]
return citations
except (ConnectionError, TimeoutError) as e:
logger.error("RAG citation search failed", query=query, error=str(e))
return []