File size: 2,083 Bytes
712c393
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dda0d18
 
 
712c393
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from __future__ import annotations

from typing import Any, Dict, List, Literal, Optional
from pydantic import BaseModel, Field

QueryType = Literal[
    "fact",
    "detailed",
    "general",
    "technical_exact",
    "comparison",
    "metadata_constrained",
    "unanswerable",
]

QueryComplexity = Literal["low", "medium", "high"]
ExecutionMode = Literal["fast", "balanced", "deep"]
Answerability = Literal["supported", "unsupported", "unanswerable"]


class QueryPlan(BaseModel):
    """

    Structured execution plan produced by the query planner.

    Acts as the central brain dictating execution mode, candidate scoping,

    retriever routing, candidate budgets, and reranking requirements.

    """
    query: str
    normalized_query: str
    query_type: QueryType = "general"
    complexity: QueryComplexity = "low"
    execution_mode: ExecutionMode = "balanced"
    answerability: Answerability = "supported"

    sub_queries: List[str] = Field(default_factory=list)
    candidate_document_ids: List[str] = Field(default_factory=list)
    explicit_document_ids: List[str] = Field(default_factory=list)
    inferred_document_ids: List[str] = Field(default_factory=list)
    is_explicit_filter: bool = False
    metadata_filters: Dict[str, Any] = Field(default_factory=dict)
    retrieval_filter: Optional[Any] = None
    retrieval_signals: Dict[str, Any] = Field(default_factory=dict)

    requires_dense: bool = True
    requires_keyword: bool = True
    requires_dense_search: bool = True
    requires_keyword_search: bool = True
    requires_hybrid: bool = True
    requires_parent_child: bool = False
    requires_multi_query: bool = False
    requires_decomposition: bool = False
    requires_metadata_filter: bool = False
    requires_reranking: bool = True

    top_k: int = 10
    top_k_dense: int = 10
    top_k_keyword: int = 10
    rerank_top_k: int = 5
    max_parents: int = 3
    max_parent_tokens: int = 1200
    context_budget: int = 2048

    confidence: float = 0.85
    reasoning: str = ""