@@ -38,11 +38,12 @@ def __init__(
38
38
"""
39
39
self ._llm = llm
40
40
self ._prompt_template = prompt_template or copy .deepcopy (default_iql_template )
41
- self ._promptify_view = promptify_view or _promptify_filters
41
+ self ._promptify_view = promptify_view or _promptify_filters or _promptify_aggregations
42
42
43
43
async def generate_iql (
44
44
self ,
45
45
filters : List [ExposedFunction ],
46
+ aggregations : List [ExposedFunction ],
46
47
question : str ,
47
48
event_tracker : EventTracker ,
48
49
conversation : Optional [IQLPromptTemplate ] = None ,
@@ -62,12 +63,14 @@ async def generate_iql(
62
63
IQL - iql generated based on the user question
63
64
"""
64
65
filters_for_prompt = self ._promptify_view (filters )
66
+ aggregations_for_prompt = self ._promptify_view (aggregations )
65
67
66
68
template = conversation or self ._prompt_template
67
69
68
70
llm_response = await self ._llm .generate_text (
69
71
template = template ,
70
- fmt = {"filters" : filters_for_prompt , "question" : question },
72
+ fmt = {"filters" : filters_for_prompt , "question" : question ,
73
+ "aggregation" : aggregations_for_prompt },
71
74
event_tracker = event_tracker ,
72
75
options = llm_options ,
73
76
)
@@ -114,3 +117,19 @@ def _promptify_filters(
114
117
"""
115
118
filters_for_prompt = "\n " .join ([str (filter ) for filter in filters ])
116
119
return filters_for_prompt
120
+
121
+
122
+ def _promptify_aggregations (
123
+ aggregations : List [ExposedFunction ],
124
+ ) -> str :
125
+ """
126
+ Formats filters for prompt
127
+
128
+ Args:
129
+ filters: list of filters exposed by the view
130
+
131
+ Returns:
132
+ filters_for_prompt: filters formatted for prompt
133
+ """
134
+ aggregations_for_prompt = "\n " .join ([str (aggregation ) for aggregation in aggregations ])
135
+ return aggregations_for_prompt
0 commit comments