@@ -14,24 +14,31 @@ async def excecute_luis_query(configuration: dict, turn_context: TurnContext) ->
14
14
15
15
try :
16
16
luis_application = LuisApplication (
17
- configuration ['LuisApplication ' ],
17
+ configuration ['LuisAppId ' ],
18
18
configuration ['LuisAPIKey' ],
19
19
'https://' + configuration ['LuisAPIHostName' ]
20
20
)
21
21
22
22
recognizer = LuisRecognizer (luis_application )
23
23
recognizer_result = await recognizer .recognize (turn_context )
24
24
25
- intent = sorted (recognizer_result .intents , key = recognizer_result .intents .get , reverse = True )[:1 ] if recognizer_result .intents else None
25
+ intent = sorted (recognizer_result .intents , key = recognizer_result .intents .get , reverse = True )[:1 ][ 0 ] if recognizer_result .intents else None
26
26
27
27
if intent == 'Book_flight' :
28
28
# We need to get the result from the LUIS JSON which at every level returns an array.
29
- booking_details .destination = recognizer_result .entities .get ("To" , {}).get ("Airport" , [])[:1 ][:1 ]
30
- booking_details .origin = recognizer_result .entities .get ("From" , {}).get ("Airport" , [])[:1 ][:1 ]
29
+ to_entities = recognizer_result .entities .get ("$instance" , {}).get ("To" , [])
30
+ if len (to_entities ) > 0 :
31
+ booking_details .destination = to_entities [0 ]['text' ]
31
32
32
- # This value will be a TIMEX. And we are only interested in a Date so grab the first result and drop the Time part.
33
+ from_entities = recognizer_result .entities .get ("$instance" , {}).get ("From" , [])
34
+ if len (from_entities ) > 0 :
35
+ booking_details .origin = from_entities [0 ]['text' ]
36
+
37
+ # TODO: This value will be a TIMEX. And we are only interested in a Date so grab the first result and drop the Time part.
33
38
# TIMEX is a format that represents DateTime expressions that include some ambiguity. e.g. missing a Year.
34
- booking_details .travel_date = recognizer_result .entities .get ("datetime" , {}).get ("timex" , [])[:1 ].split ('T' )[0 ]
39
+ date_entities = recognizer_result .entities .get ("$instance" , {}).get ("datetime" , [])
40
+ if len (date_entities ) > 0 :
41
+ booking_details .travel_date = None # TODO: Set when we get a timex format
35
42
except Exception as e :
36
43
print (e )
37
44
0 commit comments