QueryEnhancedResponseGenerator.generate_context:v0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import weave
from typing import List
from typing import Dict
@weave.op()
def generate_context(self, context: List[Dict[str, any]]) -> List[Dict[str, any]]:
"""
Generate a list of contexts from the provided context list.
Args:
context (List[Dict[str, any]]): A list of dictionaries containing context data.
Returns:
List[Dict[str, any]]: A list of dictionaries with 'source' and 'text' keys.
"""
contexts = [
{"data": {"source": item["source"], "text": item["text"]}}
for item in context
]
return contexts