У меня возникла проблема с моим ботом Weather. Разговор работает нормально, за исключением действия по прогнозированию погоды после указания местоположения, которое на самом деле является основным действием. Я использую Apixu для прогноза погоды
Когда я запускаю онлайн-тренинг, я получаю эту ошибку:
ERROR:rasa_core.processor:Encountered an exception while running action 'action_weather'. Bot will continue, but the actions events are lost. Make sure to fix the exception in your custom code.
Это мой скрипт на python для прогноза погоды:
from __future__ import absolute_import from __future__ import division
__future__ import unicode_literals
from rasa_core.actions.action import Action from rasa_core.events
import SlotSet from apixu.client import ApixuClient
class ActionWeather(Action):
def name(self):
return 'action_weather'
def run(self, dispatcher, tracker, domain):
api_key = '6******************'
client = ApixuClient(api_key)
loc = tracker.get_slot('location')
current = client.getCurrentWeather(q=loc)
country = current['location']['country']
city = current['location']['name']
condition = current['current']['condition']['text']
temperature_c = current['current']['temp_c']
humidity = current['current']['humidity']
wind_mph = current['current']['wind_mph']
response = """It is currently {} in {} at the moment. The temperature is {} degrees, the humidity is {}%
and the wind speed is {} mph.""".format(condition, city, temperature_c, humidity, wind_mph)
dispatcher.utter_message(response)
return [SlotSet('location', loc)]
и это мой файл домена погоды, который является файлом yaml
slots: location:
type: text
intents:
- greet
- goodbye
- inform
entities:
- location
templates: utter_greet:
- 'Hello! How can I help?' utter_goodbye:
- 'Talk to you later.'
- 'Bye bye :(' utter_ask_location:
- 'In what location?'
actions:
- utter_greet
- utter_goodbye
- utter_ask_location
- actions.ActionWeather
Есть идеи, пожалуйста?