From 8a4beb9d7fe290f195d852984a868ad2a22a315e Mon Sep 17 00:00:00 2001 From: xszyou Date: Thu, 24 Aug 2023 09:59:10 +0800 Subject: [PATCH] Update nlp_ChatGLM2.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修正查库顺序 --- ai_module/nlp_ChatGLM2.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/ai_module/nlp_ChatGLM2.py b/ai_module/nlp_ChatGLM2.py index 544156e..55c65cf 100644 --- a/ai_module/nlp_ChatGLM2.py +++ b/ai_module/nlp_ChatGLM2.py @@ -1,26 +1,26 @@ import json import requests from core.content_db import Content_Db -content_db = Content_Db() -list = content_db.get_list('all','desc',10) -answer_info = dict() -chat_list = [] -for val in list: - answer_info = dict() - if val[0] == "member": - answer_info["role"] = "user" - answer_info["content"] = val[2] - elif val[0] == "fay": - answer_info["role"] = "bot" - answer_info["content"] = val[2] - chat_list.append(answer_info) + def question(cont): - print(chat_list) + content_db = Content_Db() + list = content_db.get_list('all','desc',10) + answer_info = dict() + chat_list = [] + for val in list: + answer_info = dict() + if val[0] == "member": + answer_info["role"] = "user" + answer_info["content"] = val[2] + elif val[0] == "fay": + answer_info["role"] = "bot" + answer_info["content"] = val[2] + chat_list.append(answer_info) content = { "prompt":"请简单回复我。" + cont, "history":chat_list} - url = "http://192.168.1.23:8000" + url = "http://127.0.0.1:8000" req = json.dumps(content) headers = {'content-type': 'application/json'} r = requests.post(url, headers=headers, data=req)