1 Star 24 Fork 13

quke/大学知识图谱

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
dingding.py 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
quke 提交于 2022-03-08 07:45 . 增加简称关系,增加省市的匹配
from flask import Flask, make_response, request
from chatbot_graph import ChatBotGraph
handler = ChatBotGraph()
app = Flask(__name__)
@app.after_request
def af_request(*resp_raw):
resp = make_response(*resp_raw)
resp.headers['Access-Control-Allow-Origin'] = '*'
resp.headers['Access-Control-Allow-Methods'] = 'GET,POST'
resp.headers['Access-Control-Allow-Headers'] = 'x-requested-with,content-type'
return resp
@app.route('/', methods=['GET', 'POST'])
def a():
print(request.json)
data = request.json
if not data:
return ''
text = data['text']['content'].strip()
user = data['senderNick']
user_id = user
print(text)
answer = handler.chat_main(text, user_id)
resp_text = {
"at": {
"atUserIds": [
user_id
],
"isAtAll": False
},
"msgtype": "markdown",
"markdown": {
"title": "快来问我啊",
"text": answer[0],
},
}
print(resp_text)
return resp_text
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5005, debug=False)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/qukequke/university-knowledge-map.git
git@gitee.com:qukequke/university-knowledge-map.git
qukequke
university-knowledge-map
大学知识图谱
master

搜索帮助