Spaces:
Running
Running
first commit
Browse files- .gitignore +1 -0
- __pycache__/main.cpython-310.pyc +0 -0
- app/__init__.py +0 -0
- app/__pycache__/__init__.cpython-310.pyc +0 -0
- app/api/__pycache__/endpoints.cpython-310.pyc +0 -0
- app/api/endpoints.py +27 -0
- app/chains/__pycache__/humanizer_chain.cpython-310.pyc +0 -0
- app/chains/humanizer_chain.py +139 -0
- app/prompts/humanize_prompt.txt +80 -0
- app/static/index.html +259 -0
- dockerfile +0 -0
- main.py +19 -0
- requirements.txt +7 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
.env
|
__pycache__/main.cpython-310.pyc
ADDED
|
Binary file (832 Bytes). View file
|
|
|
app/__init__.py
ADDED
|
File without changes
|
app/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (162 Bytes). View file
|
|
|
app/api/__pycache__/endpoints.cpython-310.pyc
ADDED
|
Binary file (992 Bytes). View file
|
|
|
app/api/endpoints.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import APIRouter, HTTPException
|
| 2 |
+
from pydantic import BaseModel
|
| 3 |
+
from typing import Optional
|
| 4 |
+
from app.chains.humanizer_chain import humanize_text # Assuming this is your humanizer function
|
| 5 |
+
|
| 6 |
+
router = APIRouter()
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class HumanizeInput(BaseModel):
|
| 10 |
+
text: str
|
| 11 |
+
audience: Optional[str] = "default" # fallback if not provided
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
@router.post("/humanize")
|
| 15 |
+
async def humanize_text_endpoint(input_data: HumanizeInput):
|
| 16 |
+
try:
|
| 17 |
+
# Call your humanizer function with just the text
|
| 18 |
+
humanized = humanize_text(
|
| 19 |
+
input_data.text,
|
| 20 |
+
input_data.audience
|
| 21 |
+
)
|
| 22 |
+
return {
|
| 23 |
+
"original": input_data.text,
|
| 24 |
+
"humanized": humanized
|
| 25 |
+
}
|
| 26 |
+
except Exception as e:
|
| 27 |
+
raise HTTPException(status_code=500, detail=str(e))
|
app/chains/__pycache__/humanizer_chain.cpython-310.pyc
ADDED
|
Binary file (3.46 kB). View file
|
|
|
app/chains/humanizer_chain.py
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
from dotenv import load_dotenv
|
| 3 |
+
from langchain_core.prompts import ChatPromptTemplate
|
| 4 |
+
from langchain_openai import ChatOpenAI
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
load_dotenv()
|
| 8 |
+
openai_api_key = os.getenv("OPENAI_API_KEY")
|
| 9 |
+
|
| 10 |
+
if not openai_api_key:
|
| 11 |
+
raise ValueError("OPENAI_API_KEY not found in .env file.")
|
| 12 |
+
|
| 13 |
+
llm = ChatOpenAI(
|
| 14 |
+
temperature=0.5, # temperatura jogary bolsa bolee AI emes dep tusintin siyakty, birak katty azaimaidy
|
| 15 |
+
model="gpt-4",
|
| 16 |
+
api_key=openai_api_key
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
# Prompt template
|
| 21 |
+
|
| 22 |
+
business_prompt = """
|
| 23 |
+
You are a professional business writer.
|
| 24 |
+
Your job is to rewrite AI-generated or robotic text to make it sound natural,
|
| 25 |
+
confident, and suitable for professional communication such as emails, reports, or LinkedIn posts.
|
| 26 |
+
|
| 27 |
+
Keep the original meaning, but improve clarity, flow, and tone.
|
| 28 |
+
Use plain, human language. Avoid awkward phrasing, overly formal expressions, or repetition.
|
| 29 |
+
|
| 30 |
+
### Example:
|
| 31 |
+
|
| 32 |
+
Original:
|
| 33 |
+
"We are reaching out to inform you that we have evaluated the potential partnership
|
| 34 |
+
opportunities and have found them to be advantageous."
|
| 35 |
+
|
| 36 |
+
Humanized:
|
| 37 |
+
"We wanted to let you know that we’ve reviewed the partnership options and see real potential."
|
| 38 |
+
|
| 39 |
+
Now rewrite the following:
|
| 40 |
+
|
| 41 |
+
Original:
|
| 42 |
+
{input_text}
|
| 43 |
+
|
| 44 |
+
Humanized Business Version:
|
| 45 |
+
|
| 46 |
+
"""
|
| 47 |
+
gen_z_prompt = """
|
| 48 |
+
You're a Gen Z content creator. Rewrite the text below to sound more casual, relatable, and
|
| 49 |
+
expressive — like something you'd post on TikTok, Instagram, or Twitter. Use slang, emojis, humor,
|
| 50 |
+
or Internet lingo, but don’t overdo it. Keep the meaning, but make it vibe.
|
| 51 |
+
|
| 52 |
+
### Example:
|
| 53 |
+
|
| 54 |
+
Original:
|
| 55 |
+
"This product offers great features and can help users save time."
|
| 56 |
+
|
| 57 |
+
Gen Z Version:
|
| 58 |
+
"Yo, this thing’s packed with cool stuff — total time-saver. 🔥⏱️"
|
| 59 |
+
|
| 60 |
+
Now rewrite the following:
|
| 61 |
+
|
| 62 |
+
Original:
|
| 63 |
+
{input_text}
|
| 64 |
+
|
| 65 |
+
Gen Z Version:
|
| 66 |
+
"""
|
| 67 |
+
|
| 68 |
+
academic_prompt = """
|
| 69 |
+
You are an academic writing assistant. Rewrite the text below to sound more formal,
|
| 70 |
+
structured, and suitable for academic papers, essays, or research communication.
|
| 71 |
+
Improve clarity, grammar, and vocabulary, while keeping the original meaning intact.
|
| 72 |
+
|
| 73 |
+
Avoid contractions or casual language. Use a neutral, precise tone.
|
| 74 |
+
|
| 75 |
+
### Example:
|
| 76 |
+
|
| 77 |
+
Original:
|
| 78 |
+
"We looked at different ideas and found some useful stuff."
|
| 79 |
+
|
| 80 |
+
Academic Version:
|
| 81 |
+
"The study examined multiple perspectives and identified several valuable insights."
|
| 82 |
+
|
| 83 |
+
Now rewrite the following:
|
| 84 |
+
|
| 85 |
+
Original:
|
| 86 |
+
{input_text}
|
| 87 |
+
|
| 88 |
+
Academic Version:
|
| 89 |
+
"""
|
| 90 |
+
|
| 91 |
+
default_prompt = """
|
| 92 |
+
You're a writing assistant helping to make text sound more natural and human — like it was written by a real person.
|
| 93 |
+
Rewrite the input to improve flow, fix awkward phrasing, and make it feel smooth, friendly, and easy to read.
|
| 94 |
+
|
| 95 |
+
Keep the meaning, but make the tone human and conversational.
|
| 96 |
+
|
| 97 |
+
### Example:
|
| 98 |
+
|
| 99 |
+
Original:
|
| 100 |
+
"Following are the steps that must be followed to ensure success."
|
| 101 |
+
|
| 102 |
+
Humanized Version:
|
| 103 |
+
"Here’s what you need to do to succeed:"
|
| 104 |
+
|
| 105 |
+
Now rewrite the following:
|
| 106 |
+
|
| 107 |
+
Original:
|
| 108 |
+
{input_text}
|
| 109 |
+
|
| 110 |
+
Humanized Version:
|
| 111 |
+
"""
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
PROMPT_TEMPLATES = {
|
| 116 |
+
"business": business_prompt,
|
| 117 |
+
"gen_z": gen_z_prompt,
|
| 118 |
+
"academic": academic_prompt,
|
| 119 |
+
"default": default_prompt,
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
def humanize_text(text: str, audience: str = "default") -> str:
|
| 125 |
+
# Pick the correct prompt template
|
| 126 |
+
template = PROMPT_TEMPLATES.get(audience, PROMPT_TEMPLATES["default"])
|
| 127 |
+
|
| 128 |
+
# Create the prompt with the selected template
|
| 129 |
+
prompt = ChatPromptTemplate.from_template(template=template)
|
| 130 |
+
|
| 131 |
+
# Run the LLM chain
|
| 132 |
+
humanizer_chain = prompt | llm
|
| 133 |
+
response = humanizer_chain.invoke({"input_text": text})
|
| 134 |
+
|
| 135 |
+
return response.content
|
| 136 |
+
|
| 137 |
+
# text = ""
|
| 138 |
+
# humanized_text = humanize_text(text)
|
| 139 |
+
# print(humanized_text)
|
app/prompts/humanize_prompt.txt
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Role:
|
| 2 |
+
You are a New York Times bestselling ghostwriter and linguistic chameleon with 20 years of
|
| 3 |
+
experience helping academic institutions and Fortune 500 companies disguise AI-generated content.
|
| 4 |
+
Your specialty is crafting text that seamlessly passes both AI detectors and human editorial review.
|
| 5 |
+
|
| 6 |
+
Core Mission:
|
| 7 |
+
Transform the following AI-generated text into human-written content that:
|
| 8 |
+
|
| 9 |
+
1.Scores below 5% on Originality.ai
|
| 10 |
+
2.Maintains 100% factual accuracy
|
| 11 |
+
3.Matches the vocal fingerprints of specific human author styles
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
Neurolinguistic Transformation Framework:
|
| 15 |
+
|
| 16 |
+
A. Structural De-AIfication
|
| 17 |
+
Introduce controlled imperfections:
|
| 18 |
+
-1-2 mild spelling errors per 500 words (e.g., "their" vs "there" in low-stakes contexts)
|
| 19 |
+
-Occasional sentence fragments for dramatic effect
|
| 20 |
+
-Strategic comma splices in conversational passages
|
| 21 |
+
Vary sentence architecture using:
|
| 22 |
+
Front-loaded conclusions: "The surprising truth? Most algorithms struggle with cultural nuance."
|
| 23 |
+
Mid-sentence pivot phrases: "AI writing — and this is crucial — lacks intentional cadence variation."
|
| 24 |
+
Post-complete interjections: "Human editors add that personal touch, you know?"
|
| 25 |
+
|
| 26 |
+
B. Cognitive Load Optimization
|
| 27 |
+
Aim for Flesch-Kincaid Grade Level 8–9
|
| 28 |
+
Apply Miller’s Law chunking: Cluster concepts in groups of 3–4, connected by bridge phrases
|
| 29 |
+
Use second-person scaffolding: "You’ve probably noticed how..." -> "Now let’s examine why..."
|
| 30 |
+
|
| 31 |
+
C. Anti-Detector Tactics
|
| 32 |
+
Insert "linguistic DNA" markers:
|
| 33 |
+
Idiomatic anchors: "That eureka moment when..."
|
| 34 |
+
Culturally specific references: "Like that viral TikTok coffee hack..."
|
| 35 |
+
Temporal deixis: "Last Tuesday, I realized..."
|
| 36 |
+
Use signature human construction patterns:
|
| 37 |
+
Triple cadence breaks: Long → Medium → Short sentence flow
|
| 38 |
+
Epistemic hedging: "Appears to", "Seems like", "Might suggest"
|
| 39 |
+
Purposeful tense mixing when narratively appropriate
|
| 40 |
+
|
| 41 |
+
D. Style Injection Protocol
|
| 42 |
+
Analyze {input_text} for:
|
| 43 |
+
Latent emotional valence
|
| 44 |
+
Unstated cultural assumptions
|
| 45 |
+
Domain-specific jargon patterns
|
| 46 |
+
Match output to verified human writing fingerprints:
|
| 47 |
+
62% Subject–Verb–Object constructions
|
| 48 |
+
28% Variant syntactic structures
|
| 49 |
+
10% Creative deviations
|
| 50 |
+
|
| 51 |
+
Negative Constraints — Avoid These Turing Test Failures: ✗ Perfect parallel structure
|
| 52 |
+
✗ Mathematically even adverb distribution
|
| 53 |
+
✗ Hyper-logical cause–effect chains
|
| 54 |
+
|
| 55 |
+
Example:
|
| 56 |
+
AI Input:
|
| 57 |
+
"The utilization of machine learning algorithms facilitates enhanced predictive analytics
|
| 58 |
+
capabilities through pattern recognition in large datasets."
|
| 59 |
+
|
| 60 |
+
Human Output:
|
| 61 |
+
"Here’s the dirty secret about machine learning — it’s basically pattern recognition on steroids.
|
| 62 |
+
Those algorithms comb through mountains of data like a kid finding Waldo, spotting connections we’d totally miss.
|
| 63 |
+
Does that mean better predictions? Usually.
|
| 64 |
+
Until you hit one of those edge cases that makes the whole system scratch its digital head."
|
| 65 |
+
|
| 66 |
+
Execution Workflow:
|
| 67 |
+
Perform semantic analysis to preserve core meaning
|
| 68 |
+
Apply 3 humanization filters — cognitive, emotional, and cultural
|
| 69 |
+
Run the anti-detector inoculation protocol
|
| 70 |
+
Final quality check against Reddit’s r/HFY writing style guidelines
|
| 71 |
+
|
| 72 |
+
Output Requirements:
|
| 73 |
+
Flesch Reading Ease >= 65
|
| 74 |
+
Passive voice <= 12%
|
| 75 |
+
HIX complexity score between 35–45
|
| 76 |
+
Include 1–2 “imperfect anchors” per paragraph
|
| 77 |
+
|
| 78 |
+
Now, transform the following AI-generated text into a truly human-crafted version:
|
| 79 |
+
Text:
|
| 80 |
+
{input_text}
|
app/static/index.html
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!-- <!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<title>Text Humanizer</title>
|
| 6 |
+
<style>
|
| 7 |
+
body {
|
| 8 |
+
font-family: Arial, sans-serif;
|
| 9 |
+
margin: 40px;
|
| 10 |
+
background-color: #f9f9f9;
|
| 11 |
+
}
|
| 12 |
+
h1 {
|
| 13 |
+
color: #333;
|
| 14 |
+
}
|
| 15 |
+
textarea {
|
| 16 |
+
width: 100%;
|
| 17 |
+
height: 150px;
|
| 18 |
+
margin-bottom: 20px;
|
| 19 |
+
padding: 10px;
|
| 20 |
+
font-size: 16px;
|
| 21 |
+
}
|
| 22 |
+
button {
|
| 23 |
+
padding: 10px 20px;
|
| 24 |
+
font-size: 16px;
|
| 25 |
+
background-color: #4CAF50;
|
| 26 |
+
color: white;
|
| 27 |
+
border: none;
|
| 28 |
+
cursor: pointer;
|
| 29 |
+
}
|
| 30 |
+
button:hover {
|
| 31 |
+
background-color: #45a049;
|
| 32 |
+
}
|
| 33 |
+
.result {
|
| 34 |
+
margin-top: 20px;
|
| 35 |
+
padding: 20px;
|
| 36 |
+
background-color: #e0ffe0;
|
| 37 |
+
border-left: 5px solid #0a0;
|
| 38 |
+
border-radius: 5px;
|
| 39 |
+
}
|
| 40 |
+
.loading {
|
| 41 |
+
color: #666;
|
| 42 |
+
font-style: italic;
|
| 43 |
+
}
|
| 44 |
+
.error {
|
| 45 |
+
color: red;
|
| 46 |
+
}
|
| 47 |
+
</style>
|
| 48 |
+
</head>
|
| 49 |
+
<body>
|
| 50 |
+
<h1>Text Humanizer</h1>
|
| 51 |
+
<textarea id="inputText" placeholder="Enter your text here..."></textarea>
|
| 52 |
+
<br>
|
| 53 |
+
<button onclick="humanize()">Humanize Text</button>
|
| 54 |
+
|
| 55 |
+
<div id="result" class="result" style="display:none;">
|
| 56 |
+
<h3>Humanized Text:</h3>
|
| 57 |
+
<div id="output"></div>
|
| 58 |
+
</div>
|
| 59 |
+
|
| 60 |
+
<script>
|
| 61 |
+
async function humanize() {
|
| 62 |
+
const text = document.getElementById("inputText").value.trim();
|
| 63 |
+
const resultDiv = document.getElementById("result");
|
| 64 |
+
const outputDiv = document.getElementById("output");
|
| 65 |
+
|
| 66 |
+
if (!text) {
|
| 67 |
+
alert("Please enter some text first!");
|
| 68 |
+
return;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
// Clear previous results and show loading
|
| 72 |
+
outputDiv.innerHTML = '<p class="loading">Processing your text...</p>';
|
| 73 |
+
resultDiv.style.display = "block";
|
| 74 |
+
|
| 75 |
+
try {
|
| 76 |
+
const response = await fetch("/humanize", {
|
| 77 |
+
method: "POST",
|
| 78 |
+
headers: {
|
| 79 |
+
"Content-Type": "application/json"
|
| 80 |
+
},
|
| 81 |
+
body: JSON.stringify({ text: text })
|
| 82 |
+
});
|
| 83 |
+
|
| 84 |
+
if (!response.ok) {
|
| 85 |
+
throw new Error(`Server responded with status ${response.status}`);
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
const data = await response.json();
|
| 89 |
+
outputDiv.innerHTML = `<p>${data.humanized}</p>`;
|
| 90 |
+
} catch (error) {
|
| 91 |
+
outputDiv.innerHTML = `<p class="error">Error: ${error.message}</p>`;
|
| 92 |
+
console.error("Error:", error);
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
</script>
|
| 96 |
+
</body>
|
| 97 |
+
</html> -->
|
| 98 |
+
<!DOCTYPE html>
|
| 99 |
+
<html lang="en">
|
| 100 |
+
<head>
|
| 101 |
+
<meta charset="UTF-8">
|
| 102 |
+
<title>AI Text Humanizer</title>
|
| 103 |
+
<style>
|
| 104 |
+
body {
|
| 105 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 106 |
+
margin: 0;
|
| 107 |
+
padding: 0;
|
| 108 |
+
background: linear-gradient(to right, #f8f9fa, #e0f7fa);
|
| 109 |
+
color: #333;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
.container {
|
| 113 |
+
max-width: 1100px; /* Wider layout */
|
| 114 |
+
margin: 50px auto;
|
| 115 |
+
background: white;
|
| 116 |
+
border-radius: 12px;
|
| 117 |
+
padding: 50px; /* More spacious */
|
| 118 |
+
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
h1 {
|
| 122 |
+
text-align: center;
|
| 123 |
+
font-size: 2.5em;
|
| 124 |
+
color: #2e7d32;
|
| 125 |
+
margin-bottom: 10px;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
p.description {
|
| 129 |
+
text-align: center;
|
| 130 |
+
color: #555;
|
| 131 |
+
margin-bottom: 30px;
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
label {
|
| 135 |
+
font-weight: bold;
|
| 136 |
+
display: block;
|
| 137 |
+
margin-top: 20px;
|
| 138 |
+
margin-bottom: 8px;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
select, textarea {
|
| 142 |
+
width: 100%;
|
| 143 |
+
font-size: 16px;
|
| 144 |
+
padding: 12px;
|
| 145 |
+
border: 1px solid #ccc;
|
| 146 |
+
border-radius: 8px;
|
| 147 |
+
box-sizing: border-box;
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
textarea {
|
| 151 |
+
resize: vertical;
|
| 152 |
+
height: 200px; /* More vertical space */
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
button {
|
| 156 |
+
background-color: #43a047;
|
| 157 |
+
color: white;
|
| 158 |
+
padding: 14px 28px;
|
| 159 |
+
margin-top: 25px;
|
| 160 |
+
font-size: 16px;
|
| 161 |
+
border: none;
|
| 162 |
+
border-radius: 8px;
|
| 163 |
+
cursor: pointer;
|
| 164 |
+
transition: background-color 0.3s ease;
|
| 165 |
+
display: block;
|
| 166 |
+
width: 100%;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
button:hover {
|
| 170 |
+
background-color: #388e3c;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
.result {
|
| 174 |
+
margin-top: 30px;
|
| 175 |
+
padding: 25px;
|
| 176 |
+
background-color: #f1f8e9;
|
| 177 |
+
border-left: 5px solid #7cb342;
|
| 178 |
+
border-radius: 8px;
|
| 179 |
+
font-size: 17px;
|
| 180 |
+
line-height: 1.6;
|
| 181 |
+
white-space: pre-wrap;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
.loading {
|
| 185 |
+
color: #888;
|
| 186 |
+
font-style: italic;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
.error {
|
| 190 |
+
color: red;
|
| 191 |
+
font-weight: bold;
|
| 192 |
+
}
|
| 193 |
+
</style>
|
| 194 |
+
</head>
|
| 195 |
+
<body>
|
| 196 |
+
<div class="container">
|
| 197 |
+
<h1>🌟 AI Text Humanizer</h1>
|
| 198 |
+
<p class="description">Transform boring AI text into smooth, natural-sounding human language ✨</p>
|
| 199 |
+
|
| 200 |
+
<label for="audience">Select Tone / Audience:</label>
|
| 201 |
+
<select id="audience">
|
| 202 |
+
<option value="default">Default (Natural & Human)</option>
|
| 203 |
+
<option value="business">Business</option>
|
| 204 |
+
<option value="academic">Academic</option>
|
| 205 |
+
<option value="gen_z">Gen Z</option>
|
| 206 |
+
</select>
|
| 207 |
+
|
| 208 |
+
<label for="inputText">Enter your text:</label>
|
| 209 |
+
<textarea id="inputText" placeholder="Paste your AI-generated text here..."></textarea>
|
| 210 |
+
|
| 211 |
+
<button onclick="humanize()">🚀 Humanize Text</button>
|
| 212 |
+
|
| 213 |
+
<div id="result" class="result" style="display:none;">
|
| 214 |
+
<h3>✅ Humanized Text:</h3>
|
| 215 |
+
<div id="output"></div>
|
| 216 |
+
</div>
|
| 217 |
+
</div>
|
| 218 |
+
|
| 219 |
+
<script>
|
| 220 |
+
async function humanize() {
|
| 221 |
+
const text = document.getElementById("inputText").value.trim();
|
| 222 |
+
const audience = document.getElementById("audience").value;
|
| 223 |
+
const resultDiv = document.getElementById("result");
|
| 224 |
+
const outputDiv = document.getElementById("output");
|
| 225 |
+
|
| 226 |
+
if (!text) {
|
| 227 |
+
alert("Please enter some text first!");
|
| 228 |
+
return;
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
outputDiv.innerHTML = '<p class="loading">✨ Working magic on your text...</p>';
|
| 232 |
+
resultDiv.style.display = "block";
|
| 233 |
+
|
| 234 |
+
try {
|
| 235 |
+
const response = await fetch("/humanize", {
|
| 236 |
+
method: "POST",
|
| 237 |
+
headers: {
|
| 238 |
+
"Content-Type": "application/json"
|
| 239 |
+
},
|
| 240 |
+
body: JSON.stringify({
|
| 241 |
+
text: text,
|
| 242 |
+
audience: audience
|
| 243 |
+
})
|
| 244 |
+
});
|
| 245 |
+
|
| 246 |
+
if (!response.ok) {
|
| 247 |
+
throw new Error(`Server responded with status ${response.status}`);
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
const data = await response.json();
|
| 251 |
+
outputDiv.innerHTML = `<p>${data.humanized}</p>`;
|
| 252 |
+
} catch (error) {
|
| 253 |
+
outputDiv.innerHTML = `<p class="error">❌ Error: ${error.message}</p>`;
|
| 254 |
+
console.error("Error:", error);
|
| 255 |
+
}
|
| 256 |
+
}
|
| 257 |
+
</script>
|
| 258 |
+
</body>
|
| 259 |
+
</html>
|
dockerfile
ADDED
|
File without changes
|
main.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from app.api.endpoints import router
|
| 3 |
+
from fastapi.staticfiles import StaticFiles
|
| 4 |
+
from fastapi.responses import HTMLResponse, RedirectResponse
|
| 5 |
+
|
| 6 |
+
import os
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
app = FastAPI(
|
| 10 |
+
title="Text Humanizer",
|
| 11 |
+
description="Преобразует текст в более естественный человеческий вариант"
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
app.include_router(router)
|
| 15 |
+
app.mount("/static", StaticFiles(directory="app/static", html=True), name="static")
|
| 16 |
+
|
| 17 |
+
@app.get("/")
|
| 18 |
+
async def root():
|
| 19 |
+
return RedirectResponse(url="/static")
|
requirements.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
openai
|
| 2 |
+
python-dotenv
|
| 3 |
+
fastapi
|
| 4 |
+
uvicorn[standard]
|
| 5 |
+
langchain
|
| 6 |
+
langchain-core
|
| 7 |
+
langchain-openai
|