Spaces:
Runtime error
Runtime error
asd
Browse files
app.py
CHANGED
@@ -1,53 +1,53 @@
|
|
1 |
-
#
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
#
|
8 |
-
|
9 |
-
|
10 |
-
#
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
#
|
15 |
-
|
16 |
-
|
17 |
-
#
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
#
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
#
|
50 |
-
|
51 |
|
52 |
# # import gradio as gr
|
53 |
# # from openai import OpenAI
|
@@ -197,67 +197,67 @@
|
|
197 |
# # Launch the Gradio app
|
198 |
# interface.launch(debug=True)
|
199 |
|
200 |
-
import gradio as gr
|
201 |
-
from openai import OpenAI
|
202 |
-
import os
|
203 |
-
import re
|
204 |
|
205 |
-
# define the openai key
|
206 |
-
api_key = "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"
|
207 |
|
208 |
-
# make an instance of the openai client
|
209 |
-
client = OpenAI(api_key=api_key)
|
210 |
|
211 |
-
# finetuned model instance
|
212 |
-
finetuned_model = "ft:gpt-3.5-turbo-0125:personal::9qGC8cwZ"
|
213 |
|
214 |
-
# Function to clean the text
|
215 |
-
def clean_text(text):
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
|
222 |
-
# function to humanize the text
|
223 |
-
def humanize_text(AI_text):
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
|
247 |
-
|
248 |
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
|
253 |
-
# Gradio interface definition
|
254 |
-
interface = gr.Interface(
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
)
|
261 |
|
262 |
-
# Launch the Gradio app
|
263 |
-
interface.launch(debug=True)
|
|
|
1 |
+
# import dependencies
|
2 |
+
import gradio as gr
|
3 |
+
from openai import OpenAI
|
4 |
+
import os
|
5 |
+
import re
|
6 |
+
|
7 |
+
# define the openai key
|
8 |
+
api_key = "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"
|
9 |
+
|
10 |
+
# make an instance of the openai client
|
11 |
+
client = OpenAI(api_key = api_key)
|
12 |
+
|
13 |
+
|
14 |
+
# finetuned model instance
|
15 |
+
finetuned_model = "ft:gpt-3.5-turbo-0125:personal::9qGC8cwZ"
|
16 |
+
|
17 |
+
# function to humanize the text
|
18 |
+
def humanize_text(AI_text):
|
19 |
+
"""Humanizes the provided AI text using the fine-tuned model."""
|
20 |
+
response = completion = client.chat.completions.create(
|
21 |
+
model=finetuned_model,
|
22 |
+
temperature = 0.90,
|
23 |
+
messages=[
|
24 |
+
{"role": "system", "content": """
|
25 |
+
You are a text humanizer.
|
26 |
+
You humanize AI generated text.
|
27 |
+
The text must appear like humanly written.
|
28 |
+
THE INPUT AND THE OUTPUT TEXT SHOULD HAVE THE SAME FORMAT.
|
29 |
+
THE HEADINGS AND THE BULLETS IN THE INPUT SHOULD REMAIN IN PLACE"""},
|
30 |
+
{"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"},
|
31 |
+
{"role": "user", "content": f"Humanize the text. Keep the output format i.e. the bullets and the headings as it is and dont use the list of words that are not permissible. \nTEXT: {AI_text}"}
|
32 |
+
]
|
33 |
+
)
|
34 |
+
|
35 |
+
humanized_text = response.choices[0].message.content.strip()
|
36 |
+
|
37 |
+
return humanized_text
|
38 |
+
|
39 |
+
|
40 |
+
# Gradio interface definition
|
41 |
+
interface = gr.Interface(
|
42 |
+
fn=humanize_text,
|
43 |
+
inputs="textbox",
|
44 |
+
outputs="textbox",
|
45 |
+
title="AI Text Humanizer: NoaiGPT.com Demo",
|
46 |
+
description="Enter AI-generated text and get a human-written version.",
|
47 |
+
)
|
48 |
+
|
49 |
+
# Launch the Gradio app
|
50 |
+
interface.launch(debug = True)
|
51 |
|
52 |
# # import gradio as gr
|
53 |
# # from openai import OpenAI
|
|
|
197 |
# # Launch the Gradio app
|
198 |
# interface.launch(debug=True)
|
199 |
|
200 |
+
# import gradio as gr
|
201 |
+
# from openai import OpenAI
|
202 |
+
# import os
|
203 |
+
# import re
|
204 |
|
205 |
+
# # define the openai key
|
206 |
+
# api_key = "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"
|
207 |
|
208 |
+
# # make an instance of the openai client
|
209 |
+
# client = OpenAI(api_key=api_key)
|
210 |
|
211 |
+
# # finetuned model instance
|
212 |
+
# finetuned_model = "ft:gpt-3.5-turbo-0125:personal::9qGC8cwZ"
|
213 |
|
214 |
+
# # Function to clean the text
|
215 |
+
# def clean_text(text):
|
216 |
+
# # Remove double asterisks
|
217 |
+
# text = re.sub(r'\*\*', '', text)
|
218 |
+
# # Remove double hash symbols
|
219 |
+
# text = re.sub(r'##', '', text)
|
220 |
+
# return text
|
221 |
|
222 |
+
# # function to humanize the text
|
223 |
+
# def humanize_text(AI_text):
|
224 |
+
# """Humanizes the provided AI text using the fine-tuned model."""
|
225 |
+
# humanized_text = AI_text
|
226 |
+
# attempts = 0
|
227 |
+
# max_attempts = 10
|
228 |
+
|
229 |
+
# while attempts < max_attempts:
|
230 |
+
# response = client.chat.completions.create(
|
231 |
+
# model=finetuned_model,
|
232 |
+
# temperature=0.90,
|
233 |
+
# messages=[
|
234 |
+
# {"role": "system", "content": """
|
235 |
+
# You are a text humanizer.
|
236 |
+
# You humanize AI generated text.
|
237 |
+
# The text must appear like humanly written.
|
238 |
+
# THE INPUT AND THE OUTPUT TEXT SHOULD HAVE THE SAME FORMAT.
|
239 |
+
# THE HEADINGS AND THE BULLETS IN THE INPUT SHOULD REMAIN IN PLACE"""},
|
240 |
+
# {"role": "user", "content": "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"},
|
241 |
+
# {"role": "user", "content": f"Humanize the text. Keep the output format i.e. the bullets and the headings as it is and dont use the list of words that are not permissible. \nTEXT: {humanized_text}"}
|
242 |
+
# ]
|
243 |
+
# )
|
244 |
+
|
245 |
+
# humanized_text = response.choices[0].message.content.strip()
|
246 |
|
247 |
+
# attempts += 1
|
248 |
|
249 |
+
# # Clean the humanized text
|
250 |
+
# cleaned_text = clean_text(humanized_text)
|
251 |
+
# return cleaned_text
|
252 |
|
253 |
+
# # Gradio interface definition
|
254 |
+
# interface = gr.Interface(
|
255 |
+
# fn=humanize_text,
|
256 |
+
# inputs="textbox",
|
257 |
+
# outputs="textbox",
|
258 |
+
# title="AI Text Humanizer: NoaiGPT.com Demo",
|
259 |
+
# description="Enter AI-generated text and get a human-written version.",
|
260 |
+
# )
|
261 |
|
262 |
+
# # Launch the Gradio app
|
263 |
+
# interface.launch(debug=True)
|