showme commited on
Commit
6352e06
·
verified ·
1 Parent(s): bacf64f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +5 -5
main.py CHANGED
@@ -16,7 +16,7 @@ class ContentRequest(BaseModel):
16
 
17
  # Humanize的Prompt
18
  def generate_humanized_content(content: str) -> str:
19
- prompt = f"""
20
  You are a skilled writer tasked with rewriting AI-generated text to make it sound more human, engaging, and relatable. Please follow these instructions:
21
 
22
  **Humanizing Instructions:**
@@ -41,13 +41,13 @@ def generate_humanized_content(content: str) -> str:
41
  - Show vulnerability: Share imperfections, doubts, or fears to make the text more relatable and authentic.
42
  - Use humor: Humor can help humanize the text and make it more enjoyable to read.
43
  - Edit and refine: Review the text multiple times to refine the language, tone, and flow.
44
-
45
- Now, please humanize the following text:
46
- {content}
47
  """
 
48
  inputs = tokenizer(prompt, return_tensors="pt", padding=True, truncation=True)
49
  output = model.generate(inputs["input_ids"], max_length=512, num_beams=4, early_stopping=True)
50
- return tokenizer.decode(output[0], skip_special_tokens=True)
 
 
51
 
52
  # API端点,接收内容并返回“人性化”后的文本
53
  @app.post("/humanize/")
 
16
 
17
  # Humanize的Prompt
18
  def generate_humanized_content(content: str) -> str:
19
+ instructions = """
20
  You are a skilled writer tasked with rewriting AI-generated text to make it sound more human, engaging, and relatable. Please follow these instructions:
21
 
22
  **Humanizing Instructions:**
 
41
  - Show vulnerability: Share imperfections, doubts, or fears to make the text more relatable and authentic.
42
  - Use humor: Humor can help humanize the text and make it more enjoyable to read.
43
  - Edit and refine: Review the text multiple times to refine the language, tone, and flow.
 
 
 
44
  """
45
+ prompt = f"{instructions}\n\nNow, please humanize the following text:\n{content}"
46
  inputs = tokenizer(prompt, return_tensors="pt", padding=True, truncation=True)
47
  output = model.generate(inputs["input_ids"], max_length=512, num_beams=4, early_stopping=True)
48
+ decoded_output = tokenizer.decode(output[0], skip_special_tokens=True)
49
+ print("Model output:", decoded_output) # 打印模型输出
50
+ return decoded_output
51
 
52
  # API端点,接收内容并返回“人性化”后的文本
53
  @app.post("/humanize/")