Spaces:
Runtime error
Runtime error
Update retriever.py
Browse files- retriever.py +7 -15
retriever.py
CHANGED
|
@@ -1,19 +1,11 @@
|
|
| 1 |
-
|
| 2 |
|
| 3 |
-
#
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
"task_id_2": "The fruits in the 2008 painting were apples, grapes, and pears.",
|
| 7 |
-
# Add more if needed
|
| 8 |
-
}
|
| 9 |
|
| 10 |
-
def
|
| 11 |
"""
|
| 12 |
-
|
| 13 |
"""
|
| 14 |
-
|
| 15 |
-
return [document_store[task_id]]
|
| 16 |
-
elif "Titanic" in question:
|
| 17 |
-
return ["Titanic was featured in The Last Voyage."]
|
| 18 |
-
else:
|
| 19 |
-
return ["Context not found. Please refer to web or document tools."]
|
|
|
|
| 1 |
+
import json
|
| 2 |
|
| 3 |
+
# Load the context from context.json once at startup
|
| 4 |
+
with open("context.json", "r") as f:
|
| 5 |
+
context_data = json.load(f)
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
def retrieve_relevant_context(task_id: str) -> str:
|
| 8 |
"""
|
| 9 |
+
Retrieves the relevant context for a given task_id using preloaded context.json.
|
| 10 |
"""
|
| 11 |
+
return context_data.get(task_id, "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|