Когда я запускаю эту команду:
$python -m rasa_core.server
-d <DIALOGUE_MODEL_PATH>
-u <NLU_MODEL_PATH>
--debug
-o out.log
--cors *
Когда я использую терминал для команд curl -XPOST, я получаю следующие ожидаемые результаты.
$ curl -XPOST localhost:5005/conversations/default/respond -d '{"query":"Hello"}'
[{"recipient_id": "default", "text": "Hello! How can I help?"}]
И сервер, кажется, работаетхорошо:
2018-06-06 09:28:14+0100 [-] 2018-06-06 09:28:14 DEBUG rasa_core.tracker_store - Creating a new tracker for id 'default'.
2018-06-06 09:28:15+0100 [-] /home/mike/Programing/Rasa/myflaskapp/myFlaskAppenv/lib/python3.5/site-packages/sklearn/preprocessing/label.py:151: builtins.DeprecationWarning: The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.
2018-06-06 09:28:15+0100 [-] 2018-06-06 09:28:15 DEBUG rasa_core.processor - Received user message 'I am sad' with intent '{'name': 'inform', 'confidence': 0.9091038037055945}' and entities '[{'start': 5, 'entity': 'mood', 'value': 'sad', 'extractor': 'ner_crf', 'end': 8, 'confidence': 0.5274867092381141}]'
2018-06-06 09:28:15+0100 [-] 2018-06-06 09:28:15 DEBUG rasa_core.processor - Logged UserUtterance - tracker now has 3 events
2018-06-06 09:28:15+0100 [-] 2018-06-06 09:28:15 DEBUG rasa_core.processor - Current slot values:
2018-06-06 09:28:15+0100 [-] location: None
2018-06-06 09:28:15+0100 [-] adjective: None
2018-06-06 09:28:15+0100 [-] information: None
2018-06-06 09:28:15+0100 [-] mood: sad
2018-06-06 09:28:15+0100 [-] 2018-06-06 09:28:15 DEBUG rasa_core.policies.memoization - Current tracker state [
2018-06-06 09:28:15+0100 [-] None
2018-06-06 09:28:15+0100 [-] None
2018-06-06 09:28:15+0100 [-] [('intent_inform', 1), ('entity_mood', 1), ('slot_mood_0', 1), ('prev_action_listen', 1)]]
2018-06-06 09:28:15+0100 [-] 2018-06-06 09:28:15 DEBUG rasa_core.policies.memoization - Used memorised next action '9'
2018-06-06 09:28:19+0100 [-] 2018-06-06 09:28:19 DEBUG rasa_core.policies.ensemble - Predicted next action 'utter_sadness' with prob 1.00.
2018-06-06 09:28:19+0100 [-] 2018-06-06 09:28:19 DEBUG rasa_core.processor - Bot utterance 'BotUttered(text: be a tough guy, data: null)'
2018-06-06 09:28:19+0100 [-] 2018-06-06 09:28:19 DEBUG rasa_core.processor - Action 'utter_sadness' ended with events '[]'
2018-06-06 09:28:19+0100 [-] 2018-06-06 09:28:19 DEBUG rasa_core.policies.memoization - Current tracker state [
2018-06-06 09:28:19+0100 [-] None
2018-06-06 09:28:19+0100 [-] [('intent_inform', 1), ('entity_mood', 1), ('slot_mood_0', 1), ('prev_action_listen', 1)]
2018-06-06 09:28:19+0100 [-] [('intent_inform', 1), ('entity_mood', 1), ('slot_mood_0', 1), ('prev_utter_sadness', 1)]]
2018-06-06 09:28:19+0100 [-] 2018-06-06 09:28:19 DEBUG rasa_core.policies.memoization - Used memorised next action '0'
2018-06-06 09:28:19+0100 [-] 2018-06-06 09:28:19 DEBUG rasa_core.policies.ensemble - Predicted next action 'action_listen' with prob 1.00.
2018-06-06 09:28:19+0100 [-] 2018-06-06 09:28:19 DEBUG rasa_core.processor - Action 'action_listen' ended with events '[]'
2018-06-06 09:28:19+0100 [-] 2018-06-06 09:28:19 DEBUG rasa_core.processor - Current topic: None
2018-06-06 09:28:19+0100 [-] "127.0.0.1" - - [06/Jun/2018:08:28:13 +0000] "POST /conversations/default/respond HTTP/1.1" 200 55 "-" "curl/7.47.0"
Но когда я пытаюсь отправить сообщение через графический интерфейс, я получаю исключение:
Expecting value: line 1 column 1 (char 0)
127.0.0.1 - - [06/Jun/2018 09:33:46] "POST /chat HTTP/1.1" 200
И только это с терминала сервера Rasa:
2018-06-06 09:41:14+0100 [-] "127.0.0.1" - - [06/Jun/2018:08:41:13 +0000] "GET /parse?q=Hi HTTP/1.1" 404 233 "-" "python-requests/2.18.4"
Вот часть app.py
, которая может быть проблематичной, я думаю:
@app.route('/chat',methods=["POST"])
def chat():
try:
user_message = request.form["text"]
response = requests.get("http://localhost:5005/parse",params={"q":user_message})
response = response.json()
print("response :\n",response)
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:
get_random_response = lambda intent:random.choice(intent_response_dict[intent])
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..."})
** Поэтому я ищу только те же ответы, полученные скоманда CURL на графической странице, созданной Flask.**
На данный момент я получаю только: