Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -158,40 +158,37 @@ def paraphrase_text(text, replace_ratio=0.6):
|
|
| 158 |
|
| 159 |
# function to humanize text
|
| 160 |
def humanize_text(AI_text):
|
| 161 |
-
"""Humanizes
|
| 162 |
response = client.chat.completions.create(
|
| 163 |
-
model=finetuned_model,
|
| 164 |
-
temperature
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
messages=[
|
| 166 |
{"role": "system", "content": """
|
| 167 |
-
You are
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
ABOVE ALL, THE GRAMMAR AND THE SENSE OF THE SENTENCES MUST BE TOP NOTCH - DO NOT COMPROMISE ON THAT."""},
|
| 175 |
-
{"role": "system", "content": "YOU ARE TEXT HUMANIZER BUT YOU DO NOT REDUCE THE LENGTH OF THE SENTENCES. YOUR OUTPUT SENTENCES ARE OF EXACTLY THE SAME LENGTH AS THE INPUT"},
|
| 176 |
-
{"role": "user", "content": f"THE LANGUAGE OF THE INPUT AND THE OUTPUT MUST BE SAME. THE SENTENCES SHOULD NOT BE SHORT LENGTH - THEY SHOULD BE SAME AS IN THE INPUT. ALSO THE PARAGRAPHS SHOULD NOT BE SHORT EITHER - PARAGRAPHS MUST HAVE THE SAME LENGTH"},
|
| 177 |
-
{"role": "user", "content": f"THE GRAMMAR AND THE QUALITY OF THE SENTENCES MUST BE TOP NOTCH - EASY TO UNDERSTAND AND NO GRAMMATICAL ERRORS."},
|
| 178 |
-
{"role": "user", "content": "Use as many conjunctions and punctuations to make the sentence long. COMPOUND, COMPLEX, OR COMPOUND COMPLEX sentences are required"},
|
| 179 |
-
{"role": "user", "content": f"Humanize the text. Keep the output format i.e. the bullets and the headings as it is. THE GRAMMAR MUST BE TOP NOTCH WITH NO ERRORS AND EASY TO UNDERSTAND!!!!. \nTEXT: {AI_text}"}
|
| 180 |
]
|
| 181 |
)
|
| 182 |
|
| 183 |
-
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
def main_function(AI_text):
|
| 188 |
-
humanized_text = humanize_text(AI_text)
|
| 189 |
-
# humanized_text= transform_text(humanized_text)
|
| 190 |
return humanized_text
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
|
|
|
| 195 |
# Gradio interface definition
|
| 196 |
interface = gr.Interface(
|
| 197 |
fn=main_function,
|
|
|
|
| 158 |
|
| 159 |
# function to humanize text
|
| 160 |
def humanize_text(AI_text):
|
| 161 |
+
"""Humanizes AI-generated text using GPT + Paraphrasing."""
|
| 162 |
response = client.chat.completions.create(
|
| 163 |
+
model=finetuned_model, # This remains the same (gpt-3.5-turbo)
|
| 164 |
+
temperature=1.1, # Increased for more variation
|
| 165 |
+
max_tokens=500,
|
| 166 |
+
top_p=0.95,
|
| 167 |
+
frequency_penalty=0.3,
|
| 168 |
+
presence_penalty=0.5,
|
| 169 |
messages=[
|
| 170 |
{"role": "system", "content": """
|
| 171 |
+
You are an advanced AI text rewriter that makes AI-generated text sound fully human-written.
|
| 172 |
+
- Use natural synonyms, contractions, and varied sentence structures.
|
| 173 |
+
- Restructure sentences to be complex and nuanced.
|
| 174 |
+
- Avoid robotic phrasing or overly formal structures.
|
| 175 |
+
- Ensure the text feels like it was written by a real person.
|
| 176 |
+
"""},
|
| 177 |
+
{"role": "user", "content": f"Rewrite this text to make it more human:\n\n{AI_text}"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
]
|
| 179 |
)
|
| 180 |
|
| 181 |
+
gpt_output = response.choices[0].message.content.strip()
|
| 182 |
+
|
| 183 |
+
# Apply additional paraphrasing to GPT output
|
| 184 |
+
humanized_text = paraphrase_text(gpt_output)
|
| 185 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
return humanized_text
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
+
|
| 192 |
# Gradio interface definition
|
| 193 |
interface = gr.Interface(
|
| 194 |
fn=main_function,
|