Spaces:
Sleeping
Sleeping
File size: 2,423 Bytes
1e732dd 696f787 1e732dd 9659593 1e732dd 696f787 1e732dd 9659593 1e732dd 696f787 1e732dd 696f787 1e732dd 696f787 1e732dd 9659593 696f787 1e732dd 696f787 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | """
MediGuard AI β Agentic RAG State
Enhanced LangGraph state for the guardrail β retrieve β grade β generate
pipeline that wraps the existing 6-agent clinical workflow.
"""
from __future__ import annotations
import operator
from typing import Annotated, Any
from typing_extensions import TypedDict
class AgenticRAGState(TypedDict, total=False):
"""State flowing through the agentic RAG graph."""
# ββ Input ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
query: str
biomarkers: dict[str, float] | None
patient_context: dict[str, Any] | None
# ββ Guardrail ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
guardrail_score: float # 0-100 medical-relevance score
is_in_scope: bool # passed guardrail?
# ββ Retrieval ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
retrieved_documents: list[dict[str, Any]]
retrieval_attempts: int
max_retrieval_attempts: int
# ββ Grading ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
grading_results: list[dict[str, Any]]
relevant_documents: list[dict[str, Any]]
needs_rewrite: bool
# ββ Rewriting ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
rewritten_query: str | None
# ββ Generation / routing βββββββββββββββββββββββββββββββββββββββββββββ
routing_decision: str # "analyze" | "rag_answer" | "out_of_scope"
final_answer: str | None
analysis_result: dict[str, Any] | None
# ββ Metadata βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
trace_id: str | None
errors: Annotated[list[str], operator.add]
|