From 2daff0d6c356208c8587f8b2c5bd3813650182cd Mon Sep 17 00:00:00 2001 From: "majiahui@haimaqingfan.com" Date: Tue, 7 Nov 2023 15:24:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E4=B8=AA=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E7=89=88=E4=B8=8A=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flask_drop_rewrite_request.py | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/flask_drop_rewrite_request.py b/flask_drop_rewrite_request.py index 5b8c2d1..5adb1de 100644 --- a/flask_drop_rewrite_request.py +++ b/flask_drop_rewrite_request.py @@ -42,6 +42,7 @@ pantten_biaoti_0 = '^[1-9一二三四五六七八九ⅠⅡⅢⅣⅤⅥⅦⅧⅨ] pantten_biaoti_1 = '^第[一二三四五六七八九]章\s{0,}?[\u4e00-\u9fa5a-zA-Z]+' pantten_biaoti_2 = '^[0-9.]+\s{0,}?[\u4e00-\u9fa5a-zA-Z]+' pantten_biaoti_3 = '^[((][1-9一二三四五六七八九ⅠⅡⅢⅣⅤⅥⅦⅧⅨ][)_)][、.]{0,}?\s{0,}?[\u4e00-\u9fa5a-zA-Z]+' +chatgpt_url = "http://114.116.25.228:12000/predict" class log: @@ -349,12 +350,31 @@ def main(texts: dict): # index = output.request_id # generated_text = output.outputs[0].text # generated_text_list[int(index)] = generated_text - generated_text_list = dialog_line_parse( - "http://192.168.31.145:14010/predict", - { - "texts":text_sentence - } - )["resilt"] + + ## ============================================================ + # generated_text_list = dialog_line_parse( + # chatgpt_url, + # { + # "texts": text_sentence + # } + # )["data"] + + ## ==================================================================== + + input_data = [] + for i in range(len(text_sentence)): + input_data.append([url, {"texts": text_sentence[i]}]) + + with concurrent.futures.ThreadPoolExecutor() as executor: + # 使用submit方法将任务提交给线程池,并获取Future对象 + futures = [executor.submit(dialog_line_parse, i[0], i[1]) for i in input_data] + + # 使用as_completed获取已完成的任务,并获取返回值 + results = [future.result() for future in concurrent.futures.as_completed(futures)] + + generated_text_list = [] + for dan in results: + generated_text_list.append(dan["data"]) for i in range(len(generated_text_list)): # if len(text_list[i][0]) > 7: