版本
rasa-core:0.9.0a3
rasa-nlu:0.12.3
问题
我有一个网络应用程序聊天和一个作为聊天机器人的 Rasa 服务器,我希望聊天机器人处理从第一个接收到的消息。
在本教程结束时,可以读到路径是通过执行“run_server.bat”脚本启动以下命令来启动 RASA-NLU 服务器。加载自定义训练模型并开始监听端口 5000:
$ python -m rasa_nlu.server --path projects
我尝试了以下操作,但终端告诉我该端口已在使用中
(myFlaskAppenv) mike@mike-thinks:~/Programing/Rasa/myflaskapp$ python -m rasa_nlu.server --path ~/Programing/Rasa/myflaskapp
/home/mike/Programing/Rasa/myflaskapp/myFlaskAppenv/lib/python3.5/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
2018-06-04 17:01:20+0100 [-] Log opened.
2018-06-04 17:01:20+0100 [-] Unhandled error in Deferred:
2018-06-04 17:01:20+0100 [-] Unhandled Error
Traceback (most recent call last):
File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/mike/Programing/Rasa/myflaskapp/myFlaskAppenv/lib/python3.5/site-packages/rasa_nlu/server.py", line 402, in <module>
rasa.app.run('0.0.0.0', cmdline_args.port)
File "/home/mike/Programing/Rasa/myflaskapp/myFlaskAppenv/lib/python3.5/site-packages/klein/app.py", line 392, in run
endpoint.listen(Site(self.resource()))
File "/home/mike/Programing/Rasa/myflaskapp/myFlaskAppenv/lib/python3.5/site-packages/twisted/internet/endpoints.py", line 488, in listen
interface=self._interface)
--- <exception caught here> ---
File "/home/mike/Programing/Rasa/myflaskapp/myFlaskAppenv/lib/python3.5/site-packages/twisted/internet/defer.py", line 121, in execute
result = callable(*args, **kw)
File "/home/mike/Programing/Rasa/myflaskapp/myFlaskAppenv/lib/python3.5/site-packages/twisted/internet/posixbase.py", line 495, in listenTCP
p.startListening()
File "/home/mike/Programing/Rasa/myflaskapp/myFlaskAppenv/lib/python3.5/site-packages/twisted/internet/tcp.py", line 980, in startListening
raise CannotListenError(self.interface, self.port, le)
twisted.internet.error.CannotListenError: Couldn't listen on 0.0.0.0:5000: [Errno 98] Address already in use.
的确 :
(myFlaskAppenv) mike@mike-thinks:~/Programing/Rasa/myflaskapp$ python app.py
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 213-078-895
* Detected change in '/home/mike/Programing/Rasa/myflaskapp/app.py', reloading
* Restarting with stat
* Debugger is active!
* Debugger PIN: 213-078-895
因此,当我尝试与聊天机器人交谈时,它让我在终端 lou 中输入app.py
了包含所有路线的信息:
127.0.0.1 - - [04/Jun/2018 16:42:46] "GET /parse?q=hi HTTP/1.1" 404 -
HOUSTON ! WE GOT AN EXCETPITON !
Expecting value: line 1 column 1 (char 0)
127.0.0.1 - - [04/Jun/2018 16:42:46] "POST /chat HTTP/1.1" 200 -
这里是app.py
指处理聊天机器人消息的部分,如果还有更多需要,请告诉我,但我认为这不是最重要的:
@app.route('/chat',methods=["POST"])
def chat():
try:
user_message = request.form["text"]
response = requests.get("http://localhost:5000/parse",params={"q":user_message})
response = response.json()
entities = response.get("entities")
topresponse = response["topScoringIntent"]
intent = topresponse.get("intent")
print("Intent {}, Entities {}".format(intent,entities))
if intent == "gst-info":
response_text = gst_info(entities)# "Sorry will get answer soon" #get_event(entities["day"],entities["time"],entities["place"])
elif intent == "gst-query":
response_text = gst_query(entities)
else:
response_text = get_random_response(intent)
return jsonify({"status":"success","response":response_text})
except Exception as e:
print("HOUSTON ! WE GOT AN EXCETPITON !")
print(e)
return jsonify({"status":"success","response":"Sorry I am not trained to do that yet..."})
那么,我应该使用什么命令让聊天机器人服务器开始监听和讨论端口 5000?