Smart-Notes-backend / app /graph /nodes /rag_agent.py
pluto90's picture
Update app/graph/nodes/rag_agent.py
f4dda8a verified
raw
history blame contribute delete
847 Bytes
# 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
}