个人技术分享

以上上一篇  Docker部署Azure chatgpt样例应用_群晖部署chatgpt-CSDN博客 xx为例

在app.py最下方有 /conversation 接口

在api.ts文件中可见调用了 /conversation 接口。

使用chrom浏览器F12查看 Networ-

本地运行后,使用postman调试。接口地址填写

http://127.0.0.1:5000/conversation

在header中填写 Content-Type application/json

body中填写如下测试值

{
  "messages": [
    {
      "role": "user",
      "content": "说说美国务卿安东尼奥不林肯是个怎样的人"
    }
  ]
}

发布到服务器后,Linux下使用curl命令调用

 curl -X POST -H "Content-Type: application/json" -d '{"messages": [
    {
      "role": "user",
      "content": "hi"
    }
  ]
}' http://ip:80/conversation

Windows使用curl命令在cmd执行

curl -X POST -H "Content-Type: application/json" -d "{\"messages\":[{\"role\":\"user\",\"content\":\"hi\"}]}" http://127.0.0.1:5000/conversation

如果json数据括号外面不适用双引号,和反斜杠 \,则报错

{"error":"400 Bad Request: The browser (or proxy) sent a request that this server could not understand."}