File size: 2,176 Bytes
84669bc
 
 
 
936bfca
84669bc
 
936bfca
84669bc
 
936bfca
84669bc
287125f
35244e7
84669bc
 
 
 
 
 
 
 
 
 
c121d90
 
 
84669bc
c121d90
 
84669bc
 
99b3c08
dcf3cfa
84669bc
f367cad
99b3c08
84669bc
 
 
 
 
 
 
 
776fa07
84669bc
 
99b3c08
936bfca
 
 
99b3c08
9f91f15
84669bc
99b3c08
84669bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# import dependencies
import gradio as gr
from openai import OpenAI
import os

# define the openai key
api_key = os.getenv("OPENAI_API_KEY")

# make an instance of the openai client
client = OpenAI(api_key = api_key)

# finetuned model instance
finetuned_model = "ft:gpt-3.5-turbo-0125:personal::9rLkyNae"

# function to humanize the text
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 OUTPUT MUST BE HIGHLY READIBLE AND GRAMMATICALLY CORRECT.
    NO SPECIAL CHARACTERS AND WORDS ARE ALLOWED.
    DO HUMANIZE PARGRAPH BY PARAGRAPH - DO NOT ADD ANY EXTRA KNOWLEDGE ON YOUR OWN JUST FOCUS ON WHAT IS THERE IN THE PARAGRAPH AND HUMANIZE IT IN THE BEST POSSIBLE AND READIBLE GRAMMAR AND SENTENCES.
    THE HEADINGS AND THE BULLETS IN THE INPUT SHOULD REMAIN IN PLACE"""},
    {"role": "user", "content": f"THE LANGUAGE OF THE INPUT AND THE OUTPUT MUST BE SAME. THE SENTENCES SHOULD NOT BE SHORT LENGTH"},
    {"role": "user", "content": f"Humanize the text. KEEP ALL THE INSTRUCTIONS GIVEN IN MIND!! AND DONT HALLUCINATE!! \nTEXT: {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)






# import gradio as gr

# # Function to handle text submission
# def contact_info(text):
#     return "Contact [email protected] for Humanizer Application service"

# # Gradio interface definition
# interface = gr.Interface(
#     fn=contact_info,
#     inputs="textbox",
#     outputs="text",
#     title="AI TEXT HUMANIZER",
#     description="Enter AI text and get its humanizer equivalent"
# )

# # Launch the Gradio app
# if __name__ == "__main__":
#     interface.launch()