This repository was archived by the owner on Apr 28, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,8 @@ def interpolate(
62
62
"""
63
63
if isinstance (template , str ):
64
64
return interpolate_text (template , values )
65
+ elif isinstance (template , list ):
66
+ [interpolate (i , values ) for i in template ]
65
67
elif isinstance (template , dict ):
66
68
for k , v in template .items ():
67
69
if isinstance (v , dict ):
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ def _fill_template(
134
134
"text" ,
135
135
"image" ,
136
136
"custom" ,
137
- "button " ,
137
+ "buttons " ,
138
138
"attachment" ,
139
139
"quick_replies" ,
140
140
]
Original file line number Diff line number Diff line change 7
7
from rasa .utils .endpoints import EndpointConfig
8
8
import os
9
9
import urllib .error
10
+ from rasa .core .nlg .interpolator import interpolate
10
11
11
12
logger = logging .getLogger (__name__ )
12
13
@@ -172,6 +173,18 @@ async def generate(
172
173
metadata = response .pop ("metadata" , {}) or {}
173
174
for key in metadata :
174
175
response [key ] = metadata [key ]
176
+
177
+ keys_to_interpolate = [
178
+ "text" ,
179
+ "image" ,
180
+ "custom" ,
181
+ "buttons" ,
182
+ "attachment" ,
183
+ "quick_replies" ,
184
+ ]
185
+ for key in keys_to_interpolate :
186
+ if key in response :
187
+ response [key ] = interpolate (response [key ], tracker .current_slot_values ())
175
188
else :
176
189
response = await self .nlg_endpoint .request (
177
190
method = "post" , json = body , timeout = DEFAULT_REQUEST_TIMEOUT
You can’t perform that action at this time.
0 commit comments