diff --git a/flask_drop_rewrite_request.py b/flask_drop_rewrite_request.py index 5228642..c4114c2 100644 --- a/flask_drop_rewrite_request.py +++ b/flask_drop_rewrite_request.py @@ -47,6 +47,9 @@ pantten_biaoti_3 = '^[((][1-9一二三四五六七八九ⅠⅡⅢⅣⅤⅥⅦ pantten_biaoti_4 = '(摘要)' pantten_biaoti_5 = '(致谢)' +prompt_qwen = "<|im_start|>user\n{}<|im_end|>\n<|im_start|>assistant\n" +prompt_qwen_think = "<|im_start|>user\n{}<|im_end|>\n<|im_start|>assistant\n\n\n\n\n" + def get_host_ip(): """ @@ -62,8 +65,8 @@ def get_host_ip(): return ip -chatgpt_url_predict = "http://{}:12001/predict".format(str(get_host_ip())) -chatgpt_url_search = "http://{}:12001/search".format(str(get_host_ip())) +chatgpt_url_predict = "http://{}:12003/predict".format(str(get_host_ip())) +chatgpt_url_search = "http://{}:12003/search".format(str(get_host_ip())) def smtp_f(name): @@ -512,13 +515,14 @@ def english_ulit(sentence): # 判断句子长度 if sentence != "": if sentence[-1] == ".": - text = f"<|im_start|>user\nRewrite the following sentence fragment, ensuring that the meaning remains similar but with significant changes. The length of the rewritten sentence must be greater, not less. Additionally, the words in the short sentences must connect seamlessly with the preceding and following sentences:\n{sentence}<|im_end|>\n<|im_start|>assistant\n" + text = f"Rewrite the following sentence fragment, ensuring that the meaning remains similar but with significant changes. The length of the rewritten sentence must be greater, not less. Additionally, the words in the short sentences must connect seamlessly with the preceding and following sentences:\n{sentence}" else: - text = f"<|im_start|>user\nRewrite the following sentence, requiring the meaning to be similar but the change to be larger, and the number of words can only be more but not less:\n{sentence}<|im_end|>\n<|im_start|>assistant\n" + text = f"Rewrite the following sentence, requiring the meaning to be similar but the change to be larger, and the number of words can only be more but not less:\n{sentence}" else: if_change = False - text = f"<|im_start|>user\nThe following words remain unchanged\n{sentence}<|im_end|>\n<|im_start|>assistant\n" + text = f"The following words remain unchanged\n{sentence}" + text = prompt_qwen_think.format(text) return text, if_change @@ -530,15 +534,17 @@ def chinese_ulit(sentence): if len(sentence) > 9: if sentence[-1] == "。": - text = f"<|im_start|>user\n任务:改写句子\n改写下面半这句话,要求意思接近但是改动幅度比较大,字数只能多不能少,短句前后词跟上下句衔接不能有错误:\n{sentence}<|im_end|>\n<|im_start|>assistant\n" + text = f"任务:改写句子\n改写下面半这句话,要求意思接近但是改动幅度比较大,字数只能多不能少,短句前后词跟上下句衔接不能有错误:\n{sentence}" else: - text = f"<|im_start|>user\n任务:改写句子\n改写下面这句话,要求意思接近但是改动幅度比较大,字数只能多不能少:\n{sentence}<|im_end|>\n<|im_start|>assistant\n" + text = f"任务:改写句子\n改写下面这句话,要求意思接近但是改动幅度比较大,字数只能多不能少:\n{sentence}" else: - text = f"<|im_start|>user\n下面词不做任何变化:\n{sentence}<|im_end|>\n<|im_start|>assistant\n" + text = f"下面词不做任何变化:\n{sentence}" if_change = False + text = prompt_qwen_think.format(text) return text, if_change + text = prompt_qwen_think.format(text) # 判断标题 result_biaoti_list_0 = re.findall(pantten_biaoti_0, sentence) result_biaoti_list_1 = re.findall(pantten_biaoti_1, sentence)