Spaces:
Running
Running
Commit ·
0678516
1
Parent(s): 0d15228
updated context builder
Browse files- core/context_builder.py +12 -4
core/context_builder.py
CHANGED
|
@@ -17,24 +17,32 @@ def build_context(agent, query):
|
|
| 17 |
rag_context = retrieve(query, k=3)
|
| 18 |
#rag_context = retrieve(user_input, k=3)
|
| 19 |
|
|
|
|
|
|
|
| 20 |
# -----------------------------
|
| 21 |
# WEB CONTEXT (only if needed)
|
| 22 |
# -----------------------------
|
| 23 |
web_context = ""
|
| 24 |
|
| 25 |
if should_use_web(query) or len(rag_context.strip()) < 50:
|
| 26 |
-
print("🌐 Using web fallback...")
|
| 27 |
-
web_context = web_search(query) or ""
|
|
|
|
|
|
|
| 28 |
|
| 29 |
# -----------------------------
|
| 30 |
# COMBINED CONTEXT
|
| 31 |
# -----------------------------
|
| 32 |
combined = f"""
|
| 33 |
-
{agent.upper()}
|
| 34 |
{rag_context}
|
| 35 |
|
| 36 |
-
|
| 37 |
{web_context}
|
| 38 |
"""
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
return combined.strip()
|
|
|
|
| 17 |
rag_context = retrieve(query, k=3)
|
| 18 |
#rag_context = retrieve(user_input, k=3)
|
| 19 |
|
| 20 |
+
#print(f"{agent.upper()} RAG: \n{rag_context}")
|
| 21 |
+
|
| 22 |
# -----------------------------
|
| 23 |
# WEB CONTEXT (only if needed)
|
| 24 |
# -----------------------------
|
| 25 |
web_context = ""
|
| 26 |
|
| 27 |
if should_use_web(query) or len(rag_context.strip()) < 50:
|
| 28 |
+
print(f"🌐 Using web fallback...")
|
| 29 |
+
#web_context = web_search(query) or ""
|
| 30 |
+
web_context = web_search(query)
|
| 31 |
+
#print(f"{agent.upper()} WEB: \n{web_context}")
|
| 32 |
|
| 33 |
# -----------------------------
|
| 34 |
# COMBINED CONTEXT
|
| 35 |
# -----------------------------
|
| 36 |
combined = f"""
|
| 37 |
+
{agent.upper()} RAG:
|
| 38 |
{rag_context}
|
| 39 |
|
| 40 |
+
{agent.upper()} WEB:
|
| 41 |
{web_context}
|
| 42 |
"""
|
| 43 |
|
| 44 |
+
print(f"{agent.upper()} RAG: \n{rag_context}")
|
| 45 |
+
print(f"{agent.upper()} WEB: \n{web_context}")
|
| 46 |
+
print(f"COMBINED - RAG+WEB - CONTEXT: \n{combined.strip()}")
|
| 47 |
+
|
| 48 |
return combined.strip()
|