Spaces:
Runtime error
Runtime error
import json | |
from typing import List | |
# Load context from a JSON file (make sure context.json is in the same directory) | |
try: | |
with open("context.json", "r") as f: | |
document_store = json.load(f) | |
except FileNotFoundError: | |
document_store = {} | |
def retrieve_context(task_id: str, question: str) -> List[str]: | |
""" | |
Retrieves relevant context using a local JSON context store. | |
Args: | |
task_id (str): The task ID from the GAIA question. | |
question (str): The actual question string (for fallback retrieval). | |
Returns: | |
List[str]: List of context strings. | |
""" | |
if task_id in document_store: | |
return [document_store[task_id]] | |
elif "Titanic" in question: | |
return ["Titanic was featured in The Last Voyage."] | |
else: | |
return ["Context not found. Please refer to web or document tools."] | |