File size: 1,082 Bytes
99b3c08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from openai import OpenAI

api_key = 


client = OpenAI(api_key = api_key)

finetuned_model = "ft:gpt-3.5-turbo-0125:cedarbyte-business-solutions::9OmNstMc"

def humanize_text(AI_text):
  """Humanizes the provided AI text using the fine-tuned model."""
  response = completion = client.chat.completions.create(
  model=finetuned_model,
  messages=[
    {"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"},
    {"role": "user", "content": f"Humanize the text: {AI_text}"}
  ]
  )
  

  return response.choices[0].message.content.strip()

# Gradio interface definition
interface = gr.Interface(
  fn=humanize_text,
  inputs="textbox",
  outputs="textbox",
  title="AI Text Humanizer",
  description="Enter AI-generated text and get a human-written version.",
)

# Launch the Gradio app
interface.launch(debug = True)