-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_all.py
48 lines (38 loc) · 1.28 KB
/
run_all.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import logging
from rasa_core.agent import Agent
from rasa_core.interpreter import RasaNLUInterpreter
from rasa_core.utils import EndpointConfig
from core.bot_server_channel import BotServerInputChannel
logger = logging.getLogger(__name__)
# Creating the Interpreter and Agent
def load_agent():
action_endpoint = EndpointConfig(url="http://localhost:8000/webhook")
interpreter = RasaNLUInterpreter("./models/default/nlu")
agent = Agent.load(
"./models/dialogue",
interpreter=interpreter,
action_endpoint=action_endpoint,
)
return agent
# Creating the server
def main_server():
agent = load_agent()
print(agent)
web_channel = BotServerInputChannel(agent)
agent.handle_channels([web_channel], http_port=8001, serve_forever=True)
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="debug log for development and production"
)
parser.add_argument("-d", "--debug", help="Set the logging level")
args = parser.parse_args()
if args == "debug":
logging.DEBUG = True
else:
logging.DEBUG = False
main_server()