Spaces:
Running
Running
import gradio as gr | |
from openai import OpenAI | |
import os | |
api_key = os.getenv("OPENAI_API_KEY") | |
client = OpenAI(api_key = api_key) | |
list_of_ai_words = ['Advancement in the realm', 'Aims to bridge', | |
'Aims to democratize', | |
'Aims to foster innovation and collaboration', | |
'Becomes increasingly evident', 'Behind the Veil', | |
'Breaking barriers', | |
'Breakthrough has the potential to revolutionize the way', | |
'Bringing us', 'Bringing us closer to a future', | |
'By combining the capabilities', 'By harnessing the power', | |
'Capturing the attention', 'Continue to advance', | |
'Continue to make significant strides', | |
'Continue to push the boundaries', 'Continues to progress rapidly', | |
'Crucial to be mindful', 'Crucially', 'Cutting-edge', | |
'Drive the next big', | |
'Encompasses a wide range of real-life scenarios', | |
'Enhancement further enhances', 'Ensures that even', | |
'Essential to understand the nuances', 'Excitement', | |
'Exciting opportunities', 'Exciting possibilities', | |
'Exciting times lie ahead as we unlock the potential of', | |
'Excitingly', 'Expanded its capabilities', | |
'Expect to witness transformative breakthroughs', | |
'Expect to witness transformative breakthroughs in their capabilities', | |
'Exploration of various potential answers', | |
'Explore the fascinating world', 'Exploring new frontiers', | |
'Exploring this avenue', 'Foster the development', | |
'Future might see us placing', 'Groundbreaking way', | |
'Groundbreaking advancement', 'Groundbreaking study', | |
'Groundbreaking technology', | |
'Have come a long way in recent years', 'Hold promise', | |
'Implications are profound', | |
'Improved efficiency in countless ways', 'In conclusion', | |
'In the fast-paced world', 'Innovative service', | |
'Intrinsic differences', 'It discovered an intriguing approach', | |
'It remains to be seen', | |
'It serves as a stepping stone towards the realization', | |
'Latest breakthrough signifies', 'Latest offering', | |
'Let’s delve into the exciting details', | |
'Main message to take away', 'Make informed decisions', | |
'Mark a significant step forward', 'Mind-boggling figure', | |
'More robust evaluation', 'Navigate the landscape', 'Notably', | |
'One step closer', 'One thing is clear', 'Only time will tell', | |
'Opens up exciting possibilities', | |
'Paving the way for enhanced performance', | |
'Possibilities are endless', 'Potentially revolutionizing the way', | |
'Push the boundaries', 'Raise fairness concerns', | |
'Raise intriguing questions', 'Rapid pace of development', | |
'Rapidly developing', 'Redefine the future', | |
'Remarkable abilities', 'Remarkable breakthrough', | |
'Remarkable proficiency', 'Remarkable success', 'Remarkable tool', | |
'Remarkably', 'Renowned', 'Represent a major milestone', | |
'Represents a significant milestone in the field', | |
'Revolutionize the way', 'Revolutionizing the way', | |
'Risks of drawing unsupported conclusions', | |
'Seeking trustworthiness', 'Significant step forward', | |
'Significant strides', 'The necessity of clear understanding', | |
'There is still room for improvement', 'Transformative power', | |
'Truly exciting', 'Uncover hidden trends', | |
'Understanding of the capabilities', 'Unleashing the potential', | |
'Unlocking the power', 'Unraveling', | |
'We can improve understanding and decision-making', | |
'Welcome your thoughts', 'What sets this apart', 'What’s more', | |
'With the introduction', 'Amazing', 'Disruptive', 'Remarkable', | |
'Breakthrough', 'Paving the way', 'State-of-the-art', | |
'The rapid pace of development', 'Unprecedented', 'Revolutionary', | |
'Innovative', 'Revolutionize the way...', | |
'Significantly enhances...', 'Bringing us one step closer', | |
'Next-generation', 'Remember', 'Dive', 'Dazzling', 'Enhance', | |
'Discover', 'Divine', 'Unveiling', 'Comprehensive', | |
'Inquire', 'Discern', 'Vigilance', 'In conclusion', | |
'Embark', 'Journey', 'Elevate', 'Evolution', 'Shift', | |
'Prevailing', 'Unleash', | |
'Let us embark on a journey of', 'Facilitate', | |
'Unveil', 'Elucidate', 'Leverage', 'Utilize', | |
'Strategize', 'Innovate', 'Synthesize', 'Expedite', | |
'Cultivate', 'Delineate', 'Articulate', 'Navigate', | |
'Proliferate', 'Augment', 'Diversify', 'Conceptualize', | |
'Manifest', 'Ponder', 'Scrutinize', 'Elicit', | |
'Enumerate', 'Empower', 'Disseminate', 'Culminate', | |
'Harness', 'Perceive', 'Actualize', 'Harmonize', | |
'Accentuate', 'Illuminate', 'Reiterate', 'Mitigate', | |
'Galvanize', 'Transcend', 'Advocate', 'Exemplify', | |
'Validate', 'Consolidate', 'Mediate', 'Conjecture', | |
'Ascertain', 'Contextualize', 'Amplify', 'Elaborate', | |
'Synergize', 'Correlate', 'Quantify', | |
'Extrapolate', 'Substantiate', 'Deconstruct', 'Engage', | |
'Envision', 'Speculate', 'Expound', 'Interpret', | |
'Juxtapose', 'Encompass', 'Revitalize', | |
'Assimilate', 'Collaborate', 'Deliberate', | |
'Aggregate', 'Fortify', 'Acclimate', 'Differentiate', | |
'Reconcile', 'Decipher', 'Theorize', 'Alleviate', | |
'Align', 'Dissect', 'Formulate', 'Evaluate', | |
'Converge', 'Introspect', 'Scaffold', 'Emulate', | |
'Reconfigure', 'Incubate', 'Permeate', 'Benchmark', | |
'Calibrate', 'Recapitulate', 'Orchestrate', | |
'Retrofit', 'Transmute', 'Delve', 'Furthermore', 'Tapestry', | |
'consequently', 'in addition to', 'extremely', 'significantly', | |
"In today's world", 'embarked', 'invaluable', 'relentless', | |
'groundbreaking', 'endeavor', 'enlightening', 'insights', | |
'esteemed', 'shed light', 'in the realm of', | |
'deep understanding', 'deliving', 'unlock', 'unleash', 'foster', | |
'Intricate', 'interplay', 'hurdle', 'Dive deep', 'bespoke', | |
'Nevertheless', 'Ultimately', 'pivotal', 'adhere', 'amplify', | |
'Absolutely', 'Its important to note', 'overall', | |
'due to the fact that', 'fostering', 'A tapestry of', 'All about', | |
'This is about'] | |
# finetuned_model = "ft:gpt-3.5-turbo-0125:cedarbyte-business-solutions::9PRHsQbf" | |
finetuned_model = "ft:gpt-3.5-turbo-0125:cedarbyte-business-solutions::9Pthp1Dc" | |
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 INPUT AND THE OUTPUT TEXT SHOULD HAVE THE SAME FORMAT. | |
THE HEADINGS AND THE BULLETS IN THE INPUT SHOULD REMAIN IN PLACE"""}, | |
{"role": "user", "content": f"Your output SHOULD NOT CONTAIN ANY OF THE WORD FROM THE LIST OF WORDS: {list_of_ai_words}"}, | |
{"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"}, | |
{"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}"} | |
] | |
) | |
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) |