簡體   English   中英

Rasa bot糟糕的請求和cors代理問題

[英]Rasa bot bad request and cors proxy issue

Rasa核心版本13.7 nlu版本14.6 os windows 10 python版本3.5

我創建了rasa chatbot並訓練了nlu以及對話模型。我已經設法在控制台中成功運行這個機器人但是當我們嘗試將其作為http服務器運行時,我們得到一個cors代理錯誤,如下所示我們用來運行的命令服務器是

  • python -m rasa_core.run -d models / dialog -u models / nlu / default / stem_nlu --enable_api --credentials credentials.yml --cors“*”我也嘗試過
  • python -m rasa_core.run -d models / dialog -u models / nlu / default / stem_nlu --enable_api --credentials credentials.yml --cors“*”-c rest no no luck

    我也試過了

    • python -m rasa_core.run -d models / dialog -u models / nlu / default / stem_nlu --enable_api --credentials credentials.yml --cors“*”-c休息沒有運氣我嘗試通過瀏覽器和郵遞員發送請求

      localhost:5005 / conversations / deafult / respond我得到{“code”:400,“details”:{“in”:“query”,“parameter”:“query”},“help”:null,“message”: “缺少消息參數。”,“reason”:“InvalidParameter”,“status”:“failure”,“version”:“0.13.7”}

並嘗試過

       localhost:5005/webhooks/rest/webhook 

我有

     Bad Request
     The browser (or proxy) sent a request that this server could not understand.

bot服務器顯示

       options 127.0.0.1 - - [2019-04-15 17:34:30] "OPTIONS /webhooks/rest/webhook HTTP/1.1" 200 306 0.001031

然后發布請求

     127.0.0.1 - - [2019-04-15 17:34:30] "POST /webhooks/rest/webhook 
  HTTP/1.1" 400 352 0.000000

我們使用如下腳本$(document).ready(function(){

$("#button").click(function(){
var message=document.getElementById("message").value;
 console.log(message);
$.ajaxSetup({
 headers: {"Content-Type": "application/json"}
 });

$.ajax({
 url: "http://localhost:5005/webhooks/rest/webhook",
 type: "POST",
 data: '{ "sender": message}'
 }).done(function(data) {

    console.log(data);
 })

明確提到CORS需要接受所有API調用。 轉到RASA項目文件夾並運行以下命令:

rasa run --enable-api --cors "*"

現在你不會看到cors錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM