Skip to content
This repository has been archived by the owner on Aug 22, 2019. It is now read-only.

Commit

Permalink
Merge 81cd779 into 8b4cf8d
Browse files Browse the repository at this point in the history
  • Loading branch information
tmbo committed Jan 20, 2019
2 parents 8b4cf8d + 81cd779 commit a8f8d4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
13 changes: 9 additions & 4 deletions rasa_core/channels/console.py
@@ -1,13 +1,15 @@
# this builtin is needed so we can overwrite in test
from builtins import input
import questionary

import json
import requests
from prompt_toolkit.styles import Style

from rasa_core import utils
from rasa_core.channels import UserMessage
from rasa_core.channels.channel import button_to_string, element_to_string,\
RestInput
from rasa_core.channels.channel import (
button_to_string, element_to_string,
RestInput)
from rasa_core.constants import DEFAULT_SERVER_URL
from rasa_core.interpreter import INTENT_MESSAGE_PREFIX

Expand All @@ -34,7 +36,10 @@ def print_bot_output(message, color=utils.bcolors.OKBLUE):


def get_cmd_input():
return input().strip()
return questionary.text("",
qmark="Your input ->",
style=Style([('qmark', '#b373d6'),
('', '#b373d6')])).ask().strip()


def send_message_receive_block(server_url, auth_token, sender_id, message):
Expand Down
8 changes: 4 additions & 4 deletions tests/utilities.py
Expand Up @@ -54,18 +54,18 @@ def mocked_cmd_input(package, text):
text = [text]

text_generator = itertools.cycle(text)
i = package.input
i = package.get_cmd_input

def mocked_input(_=None):
def mocked_input(*args, **kwargs):
value = next(text_generator)
print("wrote '{}' to input".format(value))
return value

package.input = mocked_input
package.get_cmd_input = mocked_input
try:
yield
finally:
package.input = i
package.get_cmd_input = i


def user_uttered(text: Text, confidence: float) -> UserUttered:
Expand Down

0 comments on commit a8f8d4a

Please sign in to comment.