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(
6262 """
6363 if isinstance (template , str ):
6464 return interpolate_text (template , values )
65+ elif isinstance (template , list ):
66+ [interpolate (i , values ) for i in template ]
6567 elif isinstance (template , dict ):
6668 for k , v in template .items ():
6769 if isinstance (v , dict ):
Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ def _fill_template(
134134 "text" ,
135135 "image" ,
136136 "custom" ,
137- "button " ,
137+ "buttons " ,
138138 "attachment" ,
139139 "quick_replies" ,
140140 ]
Original file line number Diff line number Diff line change 77from rasa .utils .endpoints import EndpointConfig
88import os
99import urllib .error
10+ from rasa .core .nlg .interpolator import interpolate
1011
1112logger = logging .getLogger (__name__ )
1213
@@ -172,6 +173,18 @@ async def generate(
172173 metadata = response .pop ("metadata" , {}) or {}
173174 for key in metadata :
174175 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 ())
175188 else :
176189 response = await self .nlg_endpoint .request (
177190 method = "post" , json = body , timeout = DEFAULT_REQUEST_TIMEOUT
You can’t perform that action at this time.
0 commit comments