File size: 847 Bytes
f4dda8a
195e631
 
bb25312
 
 
 
 
195e631
bb25312
195e631
 
bb25312
 
 
195e631
bb25312
 
 
 
 
 
 
 
195e631
 
 
bb25312
 
195e631
 
 
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
# app/graph/rag_agent.py

def rag_agent_node(state):
    """

    Context is already fetched by router_node.

    This node exists to rerank or validate — keeps the graph extensible.

    Right now it passes state through; add reranking here later.

    """

    # print("DEBUG → state received:", state)

    # ✅ context already comes from router now
    context = state.get("context", "")
    sources = state.get("sources", [])
    score= state.get("score", 0.0)

    print(f"RAG AGENT → context length: {len(context)} | score: {score:.3f}")

    if not context:
        # Fallback: if somehow context is empty, reroute to general
        return {
            **state,
            "route": "general",
        }

    return {
        **state,
        # "context": context,
        # "sources": sources
    }