NoaiGPT commited on
Commit
b2dc742
·
1 Parent(s): 821c973
Files changed (2) hide show
  1. app.py +47 -4
  2. requirements.txt +1 -0
app.py CHANGED
@@ -1,7 +1,50 @@
 
1
  import gradio as gr
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = "sk-proj-UCoZZMs4MyfyHwXdHjT8T3BlbkFJjYkSZyPfIPNqXfXwoekm"
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.85,
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)
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ openai