Gabi Cavalcante
dev python | pyladies | let's talk about tests and QA/QE
$ pip install rasa
$ rasa init
$ ls
__init__.py
actions.py
config.yml
credentials.yml
data/nlu.md
data/stories.md
domain.yml
endpoints.yml
models/
$ rasa train
$ rasa shell"""Install the following requirements:
dialogflow 0.5.1
google-api-core 1.4.1
"""
import dialogflow
from google.api_core.exceptions import InvalidArgument
DF_PROJECT_ID = 'google-project-id'
DF_LANGUAGE = 'en-US'
GOOGLE_APPLICATION_CREDENTIALS = '1234567abcdef.json'
SESSION_ID = 'current-user-id'
text_to_be_analyzed = "Hi! I'm David and I'd like to eat some sushi, can you help me?"
session_client = dialogflow.SessionsClient()
session = session_client.session_path(DF_PROJECT_ID, SESSION_ID)
text_input = dialogflow.types.TextInput(text=text_to_be_analyzed, language_code=DF_LANGUAGE)
query_input = dialogflow.types.QueryInput(text=text_input)
try:
response = session_client.detect_intent(session=session, query_input=query_input)
except InvalidArgument:
raise
print("Query text:", response.query_result.query_text)
print("Detected intent:", response.query_result.intent.display_name)
print("Detected intent confidence:", response.query_result.intent_detection_confidence)
By Gabi Cavalcante