rasa.core.processor
-运行操作“ action_weather”时遇到异常。机器人将继续,但动作事件丢失。确保在您的自定义代码中解决该异常。
actions.py
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from __future__ import print_function
from rasa_core_sdk import Action
from rasa_core_sdk.events import SlotSet
class ActionWeather(Action):
def name(self):
return 'action_weather'
def run(self, dispatcher, tracker, domain):
from apixu.client import ApixuClient
api_key = '5c84ed6c89dd48909d862228192607' #your apixu key
client = ApixuClient(api_key)
loc = tracker.get_slot('location')
current = client.current(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)]
这是端点
action_endpoint:
url: "http://localhost:5055/webhook/"
当我询问天气时,enter image description here给出了一些错误,我使用的是rasa版本1.1.4和python版本3.7.3