Update app.py
Browse files
app.py
CHANGED
|
@@ -87,31 +87,47 @@ class HumanizeRequest(BaseModel):
|
|
| 87 |
# ==================== STYLE PROMPTS ====================
|
| 88 |
STYLE_PROMPTS = {
|
| 89 |
"professional": """<|system|>
|
| 90 |
-
You are a
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
<|user|>
|
| 93 |
-
|
| 94 |
<|assistant|>""",
|
| 95 |
|
| 96 |
"casual": """<|system|>
|
| 97 |
-
You are a
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
<|user|>
|
| 100 |
-
|
| 101 |
<|assistant|>""",
|
| 102 |
|
| 103 |
"academic": """<|system|>
|
| 104 |
-
You are
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
<|user|>
|
| 107 |
-
|
| 108 |
<|assistant|>""",
|
| 109 |
|
| 110 |
"marketing": """<|system|>
|
| 111 |
-
You are a
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
<|user|>
|
| 114 |
-
|
| 115 |
<|assistant|>"""
|
| 116 |
}
|
| 117 |
|
|
@@ -190,11 +206,13 @@ async def transform_with_model(text: str, style: str) -> str:
|
|
| 190 |
|
| 191 |
output = llm(
|
| 192 |
prompt,
|
| 193 |
-
max_tokens=
|
| 194 |
-
temperature=
|
| 195 |
-
top_p=0.
|
| 196 |
-
repeat_penalty=1.
|
| 197 |
-
|
|
|
|
|
|
|
| 198 |
echo=False,
|
| 199 |
)
|
| 200 |
|
|
|
|
| 87 |
# ==================== STYLE PROMPTS ====================
|
| 88 |
STYLE_PROMPTS = {
|
| 89 |
"professional": """<|system|>
|
| 90 |
+
You are a text rewriter. Your ONLY task is to rewrite the user's text in professional business language.
|
| 91 |
+
RULES:
|
| 92 |
+
1. Output ONLY the rewritten version
|
| 93 |
+
2. No explanations, no examples, no notes
|
| 94 |
+
3. Keep it brief - same length as input
|
| 95 |
+
4. Just rewrite, don't add content<|end|>
|
| 96 |
<|user|>
|
| 97 |
+
Rewrite this professionally: {text}<|end|>
|
| 98 |
<|assistant|>""",
|
| 99 |
|
| 100 |
"casual": """<|system|>
|
| 101 |
+
You are a text rewriter. Your ONLY task is to rewrite the user's text in casual, conversational English.
|
| 102 |
+
RULES:
|
| 103 |
+
1. Output ONLY the rewritten version
|
| 104 |
+
2. No explanations, no examples, no notes
|
| 105 |
+
3. Keep it brief - same length as input
|
| 106 |
+
4. Just rewrite, don't add content<|end|>
|
| 107 |
<|user|>
|
| 108 |
+
Rewrite this casually: {text}<|end|>
|
| 109 |
<|assistant|>""",
|
| 110 |
|
| 111 |
"academic": """<|system|>
|
| 112 |
+
You are a text rewriter. Your ONLY task is to rewrite the user's text in academic language.
|
| 113 |
+
RULES:
|
| 114 |
+
1. Output ONLY the rewritten version
|
| 115 |
+
2. No explanations, no examples, no notes
|
| 116 |
+
3. Keep it brief - same length as input
|
| 117 |
+
4. Just rewrite, don't add content<|end|>
|
| 118 |
<|user|>
|
| 119 |
+
Rewrite this academically: {text}<|end|>
|
| 120 |
<|assistant|>""",
|
| 121 |
|
| 122 |
"marketing": """<|system|>
|
| 123 |
+
You are a text rewriter. Your ONLY task is to rewrite the user's text in persuasive marketing language.
|
| 124 |
+
RULES:
|
| 125 |
+
1. Output ONLY the rewritten version
|
| 126 |
+
2. No explanations, no examples, no notes
|
| 127 |
+
3. Keep it brief - same length as input
|
| 128 |
+
4. Just rewrite, don't add content<|end|>
|
| 129 |
<|user|>
|
| 130 |
+
Rewrite this for marketing: {text}<|end|>
|
| 131 |
<|assistant|>"""
|
| 132 |
}
|
| 133 |
|
|
|
|
| 206 |
|
| 207 |
output = llm(
|
| 208 |
prompt,
|
| 209 |
+
max_tokens=150, # REDUCE further - limit output length
|
| 210 |
+
temperature=0.4, # Balanced creativity
|
| 211 |
+
top_p=0.9,
|
| 212 |
+
repeat_penalty=1.2, # Higher penalty for repetition
|
| 213 |
+
frequency_penalty=0.2, # NEW: Penalize common words
|
| 214 |
+
presence_penalty=0.1, # NEW: Penalize already mentioned topics
|
| 215 |
+
stop=["<|end|>", "\n\n", "###", "Explanation:", "For example:", "Here's how:"],
|
| 216 |
echo=False,
|
| 217 |
)
|
| 218 |
|