From 9bb0fff0026e31395a334fb4a9dacee45a33b334 Mon Sep 17 00:00:00 2001 From: "majiahui@haimaqingfan.com" Date: Thu, 19 Dec 2024 14:24:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=B1=E6=96=87=E9=99=8D=E9=87=8D=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flask_drop_rewrite_request.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/flask_drop_rewrite_request.py b/flask_drop_rewrite_request.py index 96e184f..17936d5 100644 --- a/flask_drop_rewrite_request.py +++ b/flask_drop_rewrite_request.py @@ -206,7 +206,10 @@ def chulichangju_1(text, snetence_id, chulipangban_return_list, short_num): def request_api_chatgpt(prompt): data = { - "texts": prompt + "content": prompt, + "model": "gpt-4-turbo", + "top_p": 0.7, + "temperature": 0.9 } response = requests.post( chatgpt_url_predict, @@ -502,17 +505,15 @@ def has_chinese(s): def english_ulit(sentence): sentence = str(sentence).strip() if_change = True - # 判断句子长度 - - if "" != "": + if sentence != "": if sentence[-1] != ".": - text = f"User: 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}\nAssistant:" + text = f"<|role|>user<|says|>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}<|end|>\n<|role|>assistant<|says|>" else: - text = f"User: 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}\nAssistant:" + text = f"<|role|>user<|says|>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}<|end|>\n<|role|>assistant<|says|>" else: if_change = False - text = f"User: Hello\nAssistant:" + text = f"<|role|>user<|says|>The following words remain unchanged\n{sentence}<|end|>\n<|role|>assistant<|says|>" return text, if_change @@ -521,18 +522,16 @@ def chinese_ulit(sentence): max_length = 25 sentence = str(sentence).strip() if_change = True - - # 判断句子长度 if len(sentence) > 9: if sentence[-1] != "。": - text = f"User: 任务:改写句子\n改写下面半这句话,要求意思接近但是改动幅度比较大,字数只能多不能少,短句前后词跟上下句衔接不能有错误:\n{sentence}\nAssistant:" + text = f"<|role|>user<|says|>任务:改写句子\n改写下面半这句话,要求意思接近但是改动幅度比较大,字数只能多不能少,短句前后词跟上下句衔接不能有错误:\n{sentence}<|end|>\n<|role|>assistant<|says|>" else: - text = f"User: 任务:改写句子\n改写下面这句话,要求意思接近但是改动幅度比较大,字数只能多不能少:\n{sentence}\nAssistant:" + text = f"<|role|>user<|says|>任务:改写句子\n改写下面这句话,要求意思接近但是改动幅度比较大,字数只能多不能少:\n{sentence}<|end|>\n<|role|>assistant<|says|>" else: - text = f"User:下面词不做任何变化:\n{sentence}\nAssistant:" + text = f"<|role|>user<|says|>下面词不做任何变化:\n{sentence}<|end|>\n<|role|>assistant<|says|>" if_change = False return text, if_change