Spaces:
Sleeping
Sleeping
Nagendravarma commited on
Commit Β·
4f262ec
1
Parent(s): 7a1d46d
Fix comparison intent and dev console node activation
Browse files- frontend/dev_console.html +37 -9
- orchestration/orchestrator.py +18 -0
frontend/dev_console.html
CHANGED
|
@@ -784,11 +784,23 @@ const EDGES = [
|
|
| 784 |
];
|
| 785 |
|
| 786 |
const STEP_MAP = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 787 |
{pat:/Graph entity lookup/i, nodes:['graphdb','vectordb','bm25','ensemble']},
|
| 788 |
{pat:/Hybrid document retrieval/i, nodes:['vectordb','bm25','ensemble']},
|
| 789 |
{pat:/Hybrid policy retrieval/i, nodes:['vectordb','bm25','ensemble']},
|
|
|
|
| 790 |
{pat:/Multi-Query/i, nodes:['multiquery']},
|
| 791 |
-
{pat:/Prior
|
| 792 |
{pat:/Bronze/i, nodes:['bronze']},
|
| 793 |
{pat:/Silver/i, nodes:['silver']},
|
| 794 |
{pat:/Gold/i, nodes:['gold']},
|
|
@@ -797,7 +809,7 @@ const STEP_MAP = [
|
|
| 797 |
{pat:/Answer synthesized/i, nodes:['synthesis','langsmith']},
|
| 798 |
{pat:/LangSmith|langsmith|trace/i, nodes:['langsmith']},
|
| 799 |
{pat:/Mem0 stored|Mem0: no new/i, nodes:['mem_add']},
|
| 800 |
-
{pat:/Searching Mem0|Mem0 recalled/i,nodes:['mem_search']},
|
| 801 |
];
|
| 802 |
|
| 803 |
const LG_START = {
|
|
@@ -937,13 +949,30 @@ function setStatus(txt,state=''){
|
|
| 937 |
}
|
| 938 |
|
| 939 |
function activateFromStep(step, lgNode){
|
|
|
|
| 940 |
for(const m of STEP_MAP){
|
| 941 |
if(m.pat.test(step)){
|
| 942 |
m.nodes.forEach(id=>{
|
| 943 |
setNode(id,'active');
|
| 944 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 945 |
});
|
| 946 |
-
|
|
|
|
| 947 |
}
|
| 948 |
}
|
| 949 |
}
|
|
@@ -1033,17 +1062,16 @@ async function run(){
|
|
| 1033 |
|
| 1034 |
if(type==='node_done'){
|
| 1035 |
if(node==='retrieve'){
|
| 1036 |
-
const allRetrieval=['graphdb','vectordb','bm25','priorauth','bronze','silver','gold'];
|
| 1037 |
allRetrieval.forEach(id=>{
|
| 1038 |
const el=document.getElementById(`nd-${id}`);
|
| 1039 |
if(el && el.getAttribute('class')==='n idle') setNode(id,'skip');
|
| 1040 |
else if(el) setNode(id,'done');
|
| 1041 |
});
|
| 1042 |
-
const ensembleEl = document.getElementById(`nd-ensemble`);
|
| 1043 |
-
if(ensembleEl && ensembleEl.getAttribute('class')==='n idle') setNode('ensemble','skip');
|
| 1044 |
-
else { setNode('ensemble','done'); activateEdge('ensemble','reranker'); }
|
| 1045 |
|
| 1046 |
-
|
|
|
|
|
|
|
| 1047 |
}
|
| 1048 |
if(node==='synthesize'){
|
| 1049 |
setNode('reranker','done');setNode('merger','done');doneEdge('merger','synthesis');
|
|
|
|
| 784 |
];
|
| 785 |
|
| 786 |
const STEP_MAP = [
|
| 787 |
+
// ββ Intent patterns from orchestrator steps_log ββ
|
| 788 |
+
{pat:/SIMPLE_LOOKUP/i, nodes:['graphdb','vectordb','bm25','ensemble','multiquery']},
|
| 789 |
+
{pat:/POLICY_QUESTION/i, nodes:['vectordb','bm25','ensemble','multiquery']},
|
| 790 |
+
{pat:/MULTI_HOP.*Graph.*Policy.*Prior/i, nodes:['graphdb','vectordb','bm25','ensemble','multiquery','priorauth']},
|
| 791 |
+
{pat:/MULTI_HOP/i, nodes:['graphdb','vectordb','bm25','ensemble','multiquery','priorauth']},
|
| 792 |
+
{pat:/COMPARISON/i, nodes:['bronze','silver','gold','vectordb','bm25','ensemble','multiquery']},
|
| 793 |
+
// ββ Per-tier retrieval patterns (from COMPARISON) ββ
|
| 794 |
+
{pat:/Bronze Tier/i, nodes:['bronze']},
|
| 795 |
+
{pat:/Silver Tier/i, nodes:['silver']},
|
| 796 |
+
{pat:/Gold Tier/i, nodes:['gold']},
|
| 797 |
+
// ββ Individual retrieval component patterns ββ
|
| 798 |
{pat:/Graph entity lookup/i, nodes:['graphdb','vectordb','bm25','ensemble']},
|
| 799 |
{pat:/Hybrid document retrieval/i, nodes:['vectordb','bm25','ensemble']},
|
| 800 |
{pat:/Hybrid policy retrieval/i, nodes:['vectordb','bm25','ensemble']},
|
| 801 |
+
{pat:/Multi-Query Variant/i, nodes:['multiquery','vectordb','bm25','ensemble','graphdb']},
|
| 802 |
{pat:/Multi-Query/i, nodes:['multiquery']},
|
| 803 |
+
{pat:/Prior.?auth/i, nodes:['priorauth']},
|
| 804 |
{pat:/Bronze/i, nodes:['bronze']},
|
| 805 |
{pat:/Silver/i, nodes:['silver']},
|
| 806 |
{pat:/Gold/i, nodes:['gold']},
|
|
|
|
| 809 |
{pat:/Answer synthesized/i, nodes:['synthesis','langsmith']},
|
| 810 |
{pat:/LangSmith|langsmith|trace/i, nodes:['langsmith']},
|
| 811 |
{pat:/Mem0 stored|Mem0: no new/i, nodes:['mem_add']},
|
| 812 |
+
{pat:/Searching Mem0|Mem0 recalled|Mem0: no relevant/i, nodes:['mem_search']},
|
| 813 |
];
|
| 814 |
|
| 815 |
const LG_START = {
|
|
|
|
| 949 |
}
|
| 950 |
|
| 951 |
function activateFromStep(step, lgNode){
|
| 952 |
+
let matched = false;
|
| 953 |
for(const m of STEP_MAP){
|
| 954 |
if(m.pat.test(step)){
|
| 955 |
m.nodes.forEach(id=>{
|
| 956 |
setNode(id,'active');
|
| 957 |
+
// Activate edge from retrieve_agent for retrieval nodes, or from the current lgNode
|
| 958 |
+
const fromNode = lgNode==='retrieve' ? 'retrieve_agent' : lgNode;
|
| 959 |
+
activateEdge(fromNode, id);
|
| 960 |
+
// Activate internal edges between retrieval pipeline components
|
| 961 |
+
if(id==='ensemble') { activateEdge('vectordb','ensemble'); activateEdge('bm25','ensemble'); }
|
| 962 |
+
if(id==='multiquery') { activateEdge('retrieve_agent','multiquery'); }
|
| 963 |
+
if(id==='graphdb') { activateEdge('multiquery','graphdb'); }
|
| 964 |
+
if(id==='vectordb') { activateEdge('multiquery','vectordb'); }
|
| 965 |
+
if(id==='bm25') { activateEdge('multiquery','bm25'); }
|
| 966 |
+
// Activate tier/priorauth β merger edges
|
| 967 |
+
if(id==='bronze') { activateEdge('retrieve_agent','bronze'); activateEdge('bronze','merger'); }
|
| 968 |
+
if(id==='silver') { activateEdge('retrieve_agent','silver'); activateEdge('silver','merger'); }
|
| 969 |
+
if(id==='gold') { activateEdge('retrieve_agent','gold'); activateEdge('gold','merger'); }
|
| 970 |
+
if(id==='priorauth') { activateEdge('retrieve_agent','priorauth'); activateEdge('priorauth','merger'); }
|
| 971 |
+
if(id==='reranker') { activateEdge('ensemble','reranker'); activateEdge('graphdb','reranker'); }
|
| 972 |
+
if(id==='merger') { activateEdge('reranker','merger'); }
|
| 973 |
});
|
| 974 |
+
matched = true;
|
| 975 |
+
break; // break on first match to use the most specific pattern
|
| 976 |
}
|
| 977 |
}
|
| 978 |
}
|
|
|
|
| 1062 |
|
| 1063 |
if(type==='node_done'){
|
| 1064 |
if(node==='retrieve'){
|
| 1065 |
+
const allRetrieval=['graphdb','vectordb','bm25','ensemble','multiquery','priorauth','bronze','silver','gold'];
|
| 1066 |
allRetrieval.forEach(id=>{
|
| 1067 |
const el=document.getElementById(`nd-${id}`);
|
| 1068 |
if(el && el.getAttribute('class')==='n idle') setNode(id,'skip');
|
| 1069 |
else if(el) setNode(id,'done');
|
| 1070 |
});
|
|
|
|
|
|
|
|
|
|
| 1071 |
|
| 1072 |
+
// Activate reranker to show scoring phase, then transition edges
|
| 1073 |
+
activateEdge('ensemble','reranker'); activateEdge('graphdb','reranker');
|
| 1074 |
+
setNode('reranker','active');
|
| 1075 |
}
|
| 1076 |
if(node==='synthesize'){
|
| 1077 |
setNode('reranker','done');setNode('merger','done');doneEdge('merger','synthesis');
|
orchestration/orchestrator.py
CHANGED
|
@@ -217,10 +217,16 @@ def retrieve(state: AgentState) -> AgentState:
|
|
| 217 |
graph_ctx = fut_g.result()
|
| 218 |
if graph_ctx and "No structured" not in graph_ctx:
|
| 219 |
parts.append(f"[STRUCTURED GRAPH FACTS]\n{graph_ctx}")
|
|
|
|
|
|
|
|
|
|
| 220 |
|
| 221 |
policy_ctx = fut_p.result()
|
| 222 |
if policy_ctx and "No relevant" not in policy_ctx:
|
| 223 |
parts.append(f"[POLICY DOCUMENTS]\n{policy_ctx}")
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
# ββ POLICY_QUESTION ββββββββββββββββββββββββββββββββββββββββββ
|
| 226 |
elif intent == "POLICY_QUESTION":
|
|
@@ -240,14 +246,23 @@ def retrieve(state: AgentState) -> AgentState:
|
|
| 240 |
graph_ctx = fut_g.result()
|
| 241 |
if graph_ctx and "No structured" not in graph_ctx:
|
| 242 |
parts.append(f"[STRUCTURED GRAPH FACTS]\n{graph_ctx}")
|
|
|
|
|
|
|
|
|
|
| 243 |
|
| 244 |
policy_ctx = fut_p.result()
|
| 245 |
if policy_ctx and "No relevant" not in policy_ctx:
|
| 246 |
parts.append(f"[POLICY DOCUMENTS]\n{policy_ctx}")
|
|
|
|
|
|
|
|
|
|
| 247 |
|
| 248 |
auth_ctx = fut_a.result()
|
| 249 |
if auth_ctx and "No prior authorization" not in auth_ctx:
|
| 250 |
parts.append(f"[PRIOR AUTHORIZATION RULES]\n{auth_ctx}")
|
|
|
|
|
|
|
|
|
|
| 251 |
|
| 252 |
# ββ COMPARISON βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 253 |
elif intent == "COMPARISON":
|
|
@@ -261,6 +276,9 @@ def retrieve(state: AgentState) -> AgentState:
|
|
| 261 |
tier_ctx = futures[tier].result()
|
| 262 |
if tier_ctx and f"No {tier}" not in tier_ctx:
|
| 263 |
parts.append(f"[{tier.upper()} PLAN]\n{tier_ctx}")
|
|
|
|
|
|
|
|
|
|
| 264 |
|
| 265 |
separator = "\n\n" + "β" * 60 + "\n\n"
|
| 266 |
full_context = separator.join(parts) if parts else "No relevant context found."
|
|
|
|
| 217 |
graph_ctx = fut_g.result()
|
| 218 |
if graph_ctx and "No structured" not in graph_ctx:
|
| 219 |
parts.append(f"[STRUCTURED GRAPH FACTS]\n{graph_ctx}")
|
| 220 |
+
log.append("πΈοΈ Graph entity lookup completed")
|
| 221 |
+
else:
|
| 222 |
+
log.append("πΈοΈ Graph entity lookup β no structured results")
|
| 223 |
|
| 224 |
policy_ctx = fut_p.result()
|
| 225 |
if policy_ctx and "No relevant" not in policy_ctx:
|
| 226 |
parts.append(f"[POLICY DOCUMENTS]\n{policy_ctx}")
|
| 227 |
+
log.append("π Hybrid policy retrieval completed")
|
| 228 |
+
else:
|
| 229 |
+
log.append("π Hybrid policy retrieval β no relevant results")
|
| 230 |
|
| 231 |
# ββ POLICY_QUESTION ββββββββββββββββββββββββββββββββββββββββββ
|
| 232 |
elif intent == "POLICY_QUESTION":
|
|
|
|
| 246 |
graph_ctx = fut_g.result()
|
| 247 |
if graph_ctx and "No structured" not in graph_ctx:
|
| 248 |
parts.append(f"[STRUCTURED GRAPH FACTS]\n{graph_ctx}")
|
| 249 |
+
log.append("πΈοΈ Graph entity lookup completed")
|
| 250 |
+
else:
|
| 251 |
+
log.append("πΈοΈ Graph entity lookup β no structured results")
|
| 252 |
|
| 253 |
policy_ctx = fut_p.result()
|
| 254 |
if policy_ctx and "No relevant" not in policy_ctx:
|
| 255 |
parts.append(f"[POLICY DOCUMENTS]\n{policy_ctx}")
|
| 256 |
+
log.append("π Hybrid policy retrieval completed")
|
| 257 |
+
else:
|
| 258 |
+
log.append("π Hybrid policy retrieval β no relevant results")
|
| 259 |
|
| 260 |
auth_ctx = fut_a.result()
|
| 261 |
if auth_ctx and "No prior authorization" not in auth_ctx:
|
| 262 |
parts.append(f"[PRIOR AUTHORIZATION RULES]\n{auth_ctx}")
|
| 263 |
+
log.append("π Prior authorization rules retrieved")
|
| 264 |
+
else:
|
| 265 |
+
log.append("π Prior authorization β no relevant rules found")
|
| 266 |
|
| 267 |
# ββ COMPARISON βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 268 |
elif intent == "COMPARISON":
|
|
|
|
| 276 |
tier_ctx = futures[tier].result()
|
| 277 |
if tier_ctx and f"No {tier}" not in tier_ctx:
|
| 278 |
parts.append(f"[{tier.upper()} PLAN]\n{tier_ctx}")
|
| 279 |
+
log.append(f"π₯ [{tier} Tier] Retrieved plan context successfully")
|
| 280 |
+
else:
|
| 281 |
+
log.append(f"β οΈ [{tier} Tier] No relevant context found")
|
| 282 |
|
| 283 |
separator = "\n\n" + "β" * 60 + "\n\n"
|
| 284 |
full_context = separator.join(parts) if parts else "No relevant context found."
|