Spaces:
Runtime error
Runtime error
Commit Β·
cc7609b
1
Parent(s): f112ebb
commit 000432
Browse files
app.py
CHANGED
|
@@ -52,18 +52,19 @@ parser = StrOutputParser()
|
|
| 52 |
|
| 53 |
basic_chain = prompt | llm | parser # This is a Runnable
|
| 54 |
|
| 55 |
-
#
|
|
|
|
|
|
|
| 56 |
def should_search(input_dict):
|
| 57 |
question = input_dict.get("question", "").lower()
|
| 58 |
-
|
| 59 |
-
return any(k in question for k in keywords)
|
| 60 |
|
| 61 |
search_tool = DuckDuckGoSearchRun()
|
| 62 |
|
| 63 |
-
#
|
| 64 |
search_chain = (
|
| 65 |
RunnableLambda(lambda q: {"question": search_tool.run(q["question"])}) |
|
| 66 |
-
RunnableLambda(lambda d: f"
|
| 67 |
)
|
| 68 |
|
| 69 |
# Main chain with conditional logic
|
|
|
|
| 52 |
|
| 53 |
basic_chain = prompt | llm | parser # This is a Runnable
|
| 54 |
|
| 55 |
+
# β
Enhanced keyword detection
|
| 56 |
+
REAL_TIME_KEYWORDS = {"latest", "current", "news", "today", "price", "time", "live", "trending", "update", "happening"}
|
| 57 |
+
|
| 58 |
def should_search(input_dict):
|
| 59 |
question = input_dict.get("question", "").lower()
|
| 60 |
+
return any(kw in question for kw in REAL_TIME_KEYWORDS)
|
|
|
|
| 61 |
|
| 62 |
search_tool = DuckDuckGoSearchRun()
|
| 63 |
|
| 64 |
+
# β
Refined search chain returns clean results
|
| 65 |
search_chain = (
|
| 66 |
RunnableLambda(lambda q: {"question": search_tool.run(q["question"])}) |
|
| 67 |
+
RunnableLambda(lambda d: f"(Live info) {d['question']}")
|
| 68 |
)
|
| 69 |
|
| 70 |
# Main chain with conditional logic
|