Update main.py
Browse files
main.py
CHANGED
@@ -17,16 +17,18 @@ class ContentRequest(BaseModel):
|
|
17 |
# Humanize的Prompt
|
18 |
def generate_humanized_content(content: str) -> str:
|
19 |
prompt = f"""
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
{content}
|
22 |
Rewrite:
|
23 |
"""
|
24 |
inputs = tokenizer(prompt, return_tensors="pt", padding=True, truncation=True)
|
25 |
-
|
26 |
-
output = model.generate(inputs["input_ids"], max_length=1024, num_beams=1, do_sample=True, temperature=0.7, top_k=50, early_stopping=True)
|
27 |
-
print("output:", output) # 打印模型输出1
|
28 |
decoded_output = tokenizer.decode(output[0], skip_special_tokens=True)
|
29 |
-
print("Model output:", decoded_output) # 打印模型输出
|
30 |
return decoded_output
|
31 |
|
32 |
# API端点,接收内容并返回“人性化”后的文本
|
|
|
17 |
# Humanize的Prompt
|
18 |
def generate_humanized_content(content: str) -> str:
|
19 |
prompt = f"""
|
20 |
+
Example input: "Summer is hot."
|
21 |
+
Example output: "Nothing beats lazy afternoons by the pool, sipping lemonade and watching the clouds drift by..."
|
22 |
+
|
23 |
+
Rewrite the following text to sound like a warm, engaging blog post written by a passionate human.
|
24 |
+
Use vivid imagery, personal anecdotes, and conversational language. Ensure the entire text is rewritten:
|
25 |
{content}
|
26 |
Rewrite:
|
27 |
"""
|
28 |
inputs = tokenizer(prompt, return_tensors="pt", padding=True, truncation=True)
|
29 |
+
output = model.generate(inputs["input_ids"], max_length=512, num_beams=8, do_sample=False, temperature=0.7, top_k=50, early_stopping=True)
|
|
|
|
|
30 |
decoded_output = tokenizer.decode(output[0], skip_special_tokens=True)
|
31 |
+
print("Model output:", decoded_output) # 打印模型输出
|
32 |
return decoded_output
|
33 |
|
34 |
# API端点,接收内容并返回“人性化”后的文本
|