I’m trying to get the current temperature using api, and passing the location slot. I’ve used only spacy pipeline. I can see from the actions CLI that the custom action is being executed, and fetches the temperature which I’ve printed. Then why this error?
config.yml
pipeline:
- name: "SpacyNLP" # Language model
- name: "SpacyTokenizer" # Tokenizer
- name: "SpacyFeaturizer" # Featurizer
- name: "SpacyEntityExtractor" #Entity Extractor
- name: "EntitySynonymMapper" # Maps synonymous entity values to the same value.
- name: "SklearnIntentClassifier" # Sklearn intent classifier
nlu.yml
- intent: get_weather
examples: |
- what's the weather in [Kolkata](GPE)
- what's the weather in [Mumbai](GPE)
- what is the weather in [Delhi](GPE)
- what is the weather in [Kolkata](GPE)
- whats the weather in [Kolkata](GPE)
- whats the weather in [Delhi](GPE)
stories.yml
- story: weather path
steps:
- intent: get_weather
- action: action_weather
domain.yml
slots:
PERSON:
type: text
GPE:
type: text
entities:
- PERSON
- GPE
intents:
- greeting
- how_are_you
- bye
- my_name_is
- get_weather
actions: # actions define the responses of your bot.
- utter_greeting # Simple text response names start with utter_.
- utter_how_i_am
- utter_bye
- utter_its_nice_to_meet_you
- action_weather
responses:
utter_greeting:
- text: "Hi! Could you please help me with your name?"
- text: "Hello, my friend. What can I call you?"
utter_how_i_am:
- text: "I am doing ok."
- text: "I am good."
utter_bye:
- text: "Bye."
- text: "Good bye."
utter_its_nice_to_meet_you:
- text: "It's nice to meet you, {PERSON}."
- text: "Nice to meet you, {PERSON}."
actions.py
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
import requests
class ActionGetWeather(Action):
def name(self):
return "action_weather"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
location = tracker.get_slot("GPE")
#person = tracker.get_slot("PERSON")
params = {"appid": "xxxxxxxx" , 'q': location, "units": "metric"}
response = requests.get("https://api.openweathermap.org/data/2.5/weather",params = params).json()
temp = str(response['main']['temp'])
print(temp)
dispatcher.utter_message(temp)
return []