Browse Source

英文降重优化

master
majiahui@haimaqingfan.com 5 months ago
parent
commit
9bb0fff002
  1. 23
      flask_drop_rewrite_request.py

23
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

Loading…
Cancel
Save