File size: 858 Bytes
7fb1978
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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."]