Farhan1572 commited on
Commit
99b3c08
1 Parent(s): 0f0a2be

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from openai import OpenAI
3
+
4
+ api_key =
5
+
6
+
7
+ client = OpenAI(api_key = api_key)
8
+
9
+ finetuned_model = "ft:gpt-3.5-turbo-0125:cedarbyte-business-solutions::9OmNstMc"
10
+
11
+ def humanize_text(AI_text):
12
+ """Humanizes the provided AI text using the fine-tuned model."""
13
+ response = completion = client.chat.completions.create(
14
+ model=finetuned_model,
15
+ messages=[
16
+ {"role": "system", "content": "You are a text humanizer. You humanize AI generated text. The text must appear like humanly written. the paragraphs must be big and should look like humanly written. AVOID PASSIVE VOICE. use small sentences and long paragraphs. No headings, only paragraph based text"},
17
+ {"role": "user", "content": f"Humanize the text: {AI_text}"}
18
+ ]
19
+ )
20
+
21
+
22
+ return response.choices[0].message.content.strip()
23
+
24
+ # Gradio interface definition
25
+ interface = gr.Interface(
26
+ fn=humanize_text,
27
+ inputs="textbox",
28
+ outputs="textbox",
29
+ title="AI Text Humanizer",
30
+ description="Enter AI-generated text and get a human-written version.",
31
+ )
32
+
33
+ # Launch the Gradio app
34
+ interface.launch(debug = True)