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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
HIX-Gen: Multi-Agent Writing Suite
|
| 3 |
+
A professional AI writing platform powered by Google Gemini
|
| 4 |
+
Designed for Hugging Face Spaces deployment
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import os
|
| 8 |
+
import gradio as gr
|
| 9 |
+
import google.generativeai as genai
|
| 10 |
+
from dotenv import load_dotenv
|
| 11 |
+
import time
|
| 12 |
+
|
| 13 |
+
# ββ Load environment variables (for local dev) ββββββββββββββββββββββββββββββ
|
| 14 |
+
load_dotenv()
|
| 15 |
+
|
| 16 |
+
# ββ Gemini API Setup βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 17 |
+
def get_gemini_client():
|
| 18 |
+
api_key = os.environ.get("GEMINI_API_KEY")
|
| 19 |
+
if not api_key:
|
| 20 |
+
raise ValueError("GEMINI_API_KEY not set. Please add it in HF Spaces Secrets.")
|
| 21 |
+
genai.configure(api_key=api_key)
|
| 22 |
+
return genai.GenerativeModel("gemini-1.5-flash")
|
| 23 |
+
|
| 24 |
+
# ββ Multi-Agent Core βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 25 |
+
def multi_agent_pipeline(agent1_prompt: str, agent2_prompt: str, input_text: str) -> tuple[str, str]:
|
| 26 |
+
"""
|
| 27 |
+
Two-agent pipeline:
|
| 28 |
+
Agent 1 β Draft / core transformation
|
| 29 |
+
Agent 2 β Polish for human tone & naturalness
|
| 30 |
+
Returns (agent1_output, final_output)
|
| 31 |
+
"""
|
| 32 |
+
model = get_gemini_client()
|
| 33 |
+
|
| 34 |
+
# Agent 1: Generator / Transformer
|
| 35 |
+
draft_response = model.generate_content(
|
| 36 |
+
f"{agent1_prompt}\n\n--- INPUT ---\n{input_text}"
|
| 37 |
+
)
|
| 38 |
+
draft = draft_response.text.strip()
|
| 39 |
+
|
| 40 |
+
# Agent 2: Refiner / Humanizer
|
| 41 |
+
final_response = model.generate_content(
|
| 42 |
+
f"{agent2_prompt}\n\n--- DRAFT TO REFINE ---\n{draft}"
|
| 43 |
+
)
|
| 44 |
+
final = final_response.text.strip()
|
| 45 |
+
|
| 46 |
+
return draft, final
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 50 |
+
# MODULE 1 β AI HUMANIZER
|
| 51 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 52 |
+
HUMANIZER_AGENT1 = """You are Agent-1: an expert linguistic analyst.
|
| 53 |
+
Your task is to rewrite the following AI-generated text by:
|
| 54 |
+
1. Replacing robotic, overly formal phrases with natural conversational language.
|
| 55 |
+
2. Varying sentence length (mix short punchy sentences with longer flowing ones).
|
| 56 |
+
3. Adding subtle filler nuances humans use (e.g., "Honestly,", "Look,", "Here's the thing β").
|
| 57 |
+
4. Removing dead giveaways: excessive bullet points, hollow transitions like "In conclusion", "Furthermore", "It is worth noting".
|
| 58 |
+
5. Keeping ALL the original meaning and facts intact.
|
| 59 |
+
Output ONLY the rewritten text with no explanations."""
|
| 60 |
+
|
| 61 |
+
HUMANIZER_AGENT2 = """You are Agent-2: a professional editor and AI-bypass specialist.
|
| 62 |
+
Review the draft below and make it even more human by:
|
| 63 |
+
1. Injecting mild personal perspective where appropriate (e.g., "I'd argue...", "Most people miss...").
|
| 64 |
+
2. Fixing any remaining stiff phrasing or AI-sounding patterns.
|
| 65 |
+
3. Ensuring the tone is warm, engaging, and reads like a real expert wrote it.
|
| 66 |
+
4. Double-checking the text would pass AI detectors (Originality.ai, GPTZero, etc.).
|
| 67 |
+
Output ONLY the final polished text. No explanations, no meta-commentary."""
|
| 68 |
+
|
| 69 |
+
def run_humanizer(ai_text: str, progress=gr.Progress()):
|
| 70 |
+
if not ai_text.strip():
|
| 71 |
+
return "", "", "β οΈ Please paste some AI-generated text first."
|
| 72 |
+
try:
|
| 73 |
+
progress(0.2, desc="Agent 1: Rewriting for natural flow...")
|
| 74 |
+
draft, final = multi_agent_pipeline(HUMANIZER_AGENT1, HUMANIZER_AGENT2, ai_text)
|
| 75 |
+
progress(1.0, desc="Done!")
|
| 76 |
+
return draft, final, "β
Humanization complete! Two agents processed your text."
|
| 77 |
+
except Exception as e:
|
| 78 |
+
return "", "", f"β Error: {str(e)}"
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 82 |
+
# MODULE 2 β AI WRITER
|
| 83 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 84 |
+
WRITER_TEMPLATES = {
|
| 85 |
+
"π Blog Post": {
|
| 86 |
+
"agent1": """You are Agent-1: a skilled content strategist and blog writer.
|
| 87 |
+
Write a complete, engaging blog post based on the topic and details provided.
|
| 88 |
+
Structure: Hook intro β 3-4 body sections with subheadings β Strong conclusion with CTA.
|
| 89 |
+
Tone: Conversational yet authoritative. Use real examples. Avoid fluff.
|
| 90 |
+
Output ONLY the blog post content.""",
|
| 91 |
+
"agent2": """You are Agent-2: a senior editor at a top digital publication.
|
| 92 |
+
Polish this blog post draft to be publication-ready:
|
| 93 |
+
1. Strengthen the opening hook.
|
| 94 |
+
2. Ensure smooth transitions between sections.
|
| 95 |
+
3. Add a compelling meta-description at the top (marked with [META]:).
|
| 96 |
+
4. Make the CTA irresistible.
|
| 97 |
+
Output ONLY the final polished blog post.""",
|
| 98 |
+
"fields": ["Topic / Title", "Target Audience", "Key Points to Cover", "Tone (casual/formal/witty)"]
|
| 99 |
+
},
|
| 100 |
+
"π§ Professional Email": {
|
| 101 |
+
"agent1": """You are Agent-1: an expert business communications writer.
|
| 102 |
+
Draft a professional email based on the context provided.
|
| 103 |
+
Requirements: Clear subject line, concise body (3-4 short paragraphs max), clear ask or CTA.
|
| 104 |
+
Tone: Professional but human β not robotic corporate-speak.
|
| 105 |
+
Output ONLY the email (Subject + Body).""",
|
| 106 |
+
"agent2": """You are Agent-2: a C-suite communications coach.
|
| 107 |
+
Refine this email draft to be razor-sharp and persuasive:
|
| 108 |
+
1. Ensure the subject line is compelling (opens get noticed).
|
| 109 |
+
2. Tighten every sentence β kill filler words.
|
| 110 |
+
3. Make the ask crystal clear.
|
| 111 |
+
4. Close with confidence, not desperation.
|
| 112 |
+
Output ONLY the final email.""",
|
| 113 |
+
"fields": ["Email Purpose", "Recipient (role/context)", "Key Message", "Desired Outcome"]
|
| 114 |
+
},
|
| 115 |
+
"π± Social Media Post": {
|
| 116 |
+
"agent1": """You are Agent-1: a viral social media copywriter.
|
| 117 |
+
Create an engaging social media post based on the input.
|
| 118 |
+
Requirements: Hook in first line (no "I", start with action/question/stat), relevant hashtags, platform-optimized length.
|
| 119 |
+
Make it share-worthy and conversation-starting.
|
| 120 |
+
Output ONLY the post content.""",
|
| 121 |
+
"agent2": """You are Agent-2: a growth hacking social media specialist.
|
| 122 |
+
Supercharge this post draft:
|
| 123 |
+
1. Make the opening hook impossible to scroll past.
|
| 124 |
+
2. Add a pattern-interrupt (unexpected angle, bold claim, or relatable pain point).
|
| 125 |
+
3. Optimize hashtags for reach (mix niche + broad).
|
| 126 |
+
4. Add an engagement CTA.
|
| 127 |
+
Output ONLY the final post. Include platform recommendations at the end [BEST FOR: ...].""",
|
| 128 |
+
"fields": ["Topic / Message", "Target Platform (LinkedIn/X/Instagram)", "Brand Voice", "Goal (awareness/leads/engagement)"]
|
| 129 |
+
}
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
def run_writer(template_type: str, field1: str, field2: str, field3: str, field4: str, progress=gr.Progress()):
|
| 133 |
+
if not field1.strip():
|
| 134 |
+
return "", "", "β οΈ Please fill in at least the first field."
|
| 135 |
+
try:
|
| 136 |
+
template = WRITER_TEMPLATES[template_type]
|
| 137 |
+
combined_input = f"""
|
| 138 |
+
Field 1 - {WRITER_TEMPLATES[template_type]['fields'][0]}: {field1}
|
| 139 |
+
Field 2 - {WRITER_TEMPLATES[template_type]['fields'][1]}: {field2}
|
| 140 |
+
Field 3 - {WRITER_TEMPLATES[template_type]['fields'][2]}: {field3}
|
| 141 |
+
Field 4 - {WRITER_TEMPLATES[template_type]['fields'][3]}: {field4}
|
| 142 |
+
""".strip()
|
| 143 |
+
|
| 144 |
+
progress(0.2, desc="Agent 1: Generating first draft...")
|
| 145 |
+
draft, final = multi_agent_pipeline(template["agent1"], template["agent2"], combined_input)
|
| 146 |
+
progress(1.0, desc="Done!")
|
| 147 |
+
return draft, final, f"β
{template_type} generated successfully by 2 AI agents."
|
| 148 |
+
except Exception as e:
|
| 149 |
+
return "", "", f"β Error: {str(e)}"
|
| 150 |
+
|
| 151 |
+
def update_writer_labels(template_type: str):
|
| 152 |
+
fields = WRITER_TEMPLATES[template_type]["fields"]
|
| 153 |
+
return (
|
| 154 |
+
gr.update(label=fields[0], placeholder=f"Enter {fields[0].lower()}..."),
|
| 155 |
+
gr.update(label=fields[1], placeholder=f"Enter {fields[1].lower()}..."),
|
| 156 |
+
gr.update(label=fields[2], placeholder=f"Enter {fields[2].lower()}..."),
|
| 157 |
+
gr.update(label=fields[3], placeholder=f"Enter {fields[3].lower()}..."),
|
| 158 |
+
)
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 162 |
+
# MODULE 3 β SMART EDITOR
|
| 163 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 164 |
+
EDITOR_MODES = {
|
| 165 |
+
"π Summarize": {
|
| 166 |
+
"agent1": """You are Agent-1: a master summarizer.
|
| 167 |
+
Condense the input text into a clear, accurate summary.
|
| 168 |
+
Preserve all KEY points, remove redundancy, keep it ~20-30% of original length.
|
| 169 |
+
Use bullet points for long content, prose for short content.
|
| 170 |
+
Output ONLY the summary.""",
|
| 171 |
+
"agent2": """You are Agent-2: a communications expert.
|
| 172 |
+
Refine this summary to be more impactful:
|
| 173 |
+
1. Lead with the single most important takeaway.
|
| 174 |
+
2. Ensure every bullet/sentence earns its place.
|
| 175 |
+
3. End with the key implication or action item.
|
| 176 |
+
Output ONLY the final polished summary."""
|
| 177 |
+
},
|
| 178 |
+
"β¨ Improve Writing": {
|
| 179 |
+
"agent1": """You are Agent-1: an expert writing coach.
|
| 180 |
+
Improve the given text by:
|
| 181 |
+
1. Fixing grammar, spelling, and punctuation errors.
|
| 182 |
+
2. Improving clarity and flow.
|
| 183 |
+
3. Strengthening weak word choices (replace vague words with precise ones).
|
| 184 |
+
4. Restructuring awkward sentences.
|
| 185 |
+
Keep the author's voice and intent intact.
|
| 186 |
+
Output ONLY the improved text.""",
|
| 187 |
+
"agent2": """You are Agent-2: an award-winning editor.
|
| 188 |
+
Do a final pass on this improved draft:
|
| 189 |
+
1. Elevate the most impactful sentences.
|
| 190 |
+
2. Ensure the opening grabs attention.
|
| 191 |
+
3. Cut any remaining filler or redundancy.
|
| 192 |
+
4. Verify the tone is consistent throughout.
|
| 193 |
+
Output ONLY the final polished text."""
|
| 194 |
+
},
|
| 195 |
+
"π Change Tone": {
|
| 196 |
+
"agent1": """You are Agent-1: a tone adaptation specialist.
|
| 197 |
+
The user will specify a target tone in their input. Rewrite the text in that exact tone.
|
| 198 |
+
Common tones: formal, casual, confident, empathetic, persuasive, academic, friendly.
|
| 199 |
+
Maintain all factual content while completely transforming the voice.
|
| 200 |
+
Output ONLY the rewritten text.""",
|
| 201 |
+
"agent2": """You are Agent-2: a brand voice consultant.
|
| 202 |
+
Review the tone-adapted draft and ensure:
|
| 203 |
+
1. The new tone is consistent from start to finish (no tone slippage).
|
| 204 |
+
2. The language feels authentic to that tone (word choice, sentence rhythm).
|
| 205 |
+
3. It still communicates the core message clearly.
|
| 206 |
+
Output ONLY the final version."""
|
| 207 |
+
},
|
| 208 |
+
"π Expand": {
|
| 209 |
+
"agent1": """You are Agent-1: a content expansion specialist.
|
| 210 |
+
Expand the given text with:
|
| 211 |
+
1. More detail, context, and explanation.
|
| 212 |
+
2. Relevant examples or analogies.
|
| 213 |
+
3. Supporting evidence or reasoning.
|
| 214 |
+
4. Smooth transitions between ideas.
|
| 215 |
+
Target: 2-3x the original length while adding REAL value (not padding).
|
| 216 |
+
Output ONLY the expanded text.""",
|
| 217 |
+
"agent2": """You are Agent-2: a senior content strategist.
|
| 218 |
+
Review the expanded draft and:
|
| 219 |
+
1. Remove any filler that crept in.
|
| 220 |
+
2. Ensure new additions feel organic, not bolted-on.
|
| 221 |
+
3. Strengthen the opening and closing.
|
| 222 |
+
4. Verify the expanded version flows naturally.
|
| 223 |
+
Output ONLY the final polished expanded text."""
|
| 224 |
+
}
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
def run_editor(text: str, mode: str, extra_instruction: str, progress=gr.Progress()):
|
| 228 |
+
if not text.strip():
|
| 229 |
+
return "", "", "β οΈ Please enter some text to edit."
|
| 230 |
+
try:
|
| 231 |
+
config = EDITOR_MODES[mode]
|
| 232 |
+
full_input = text
|
| 233 |
+
if extra_instruction.strip():
|
| 234 |
+
full_input = f"[Special Instruction: {extra_instruction}]\n\n{text}"
|
| 235 |
+
|
| 236 |
+
progress(0.2, desc=f"Agent 1: Applying {mode}...")
|
| 237 |
+
draft, final = multi_agent_pipeline(config["agent1"], config["agent2"], full_input)
|
| 238 |
+
progress(1.0, desc="Done!")
|
| 239 |
+
return draft, final, f"β
{mode} complete! Text processed by 2 AI agents."
|
| 240 |
+
except Exception as e:
|
| 241 |
+
return "", "", f"β Error: {str(e)}"
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 245 |
+
# GRADIO UI β Dark Professional Theme
|
| 246 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 247 |
+
custom_css = """
|
| 248 |
+
/* ββ Global Reset & Base βββββββββββββββββββββββββββββββββββββββββββββ */
|
| 249 |
+
@import url('https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300&family=Syne:wght@400;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');
|
| 250 |
+
|
| 251 |
+
:root {
|
| 252 |
+
--bg-void: #080b0f;
|
| 253 |
+
--bg-deep: #0d1117;
|
| 254 |
+
--bg-panel: #111620;
|
| 255 |
+
--bg-card: #161c27;
|
| 256 |
+
--bg-input: #1a2130;
|
| 257 |
+
--border-dim: #1f2d3d;
|
| 258 |
+
--border-glow: #2a3f5a;
|
| 259 |
+
--accent-cyan: #00d4ff;
|
| 260 |
+
--accent-teal: #00b894;
|
| 261 |
+
--accent-amber: #f0a500;
|
| 262 |
+
--accent-rose: #ff4d6d;
|
| 263 |
+
--text-primary: #e8edf5;
|
| 264 |
+
--text-secondary: #8899aa;
|
| 265 |
+
--text-muted: #4a5568;
|
| 266 |
+
--font-display: 'Syne', sans-serif;
|
| 267 |
+
--font-body: 'DM Sans', sans-serif;
|
| 268 |
+
--font-mono: 'DM Mono', monospace;
|
| 269 |
+
--radius: 10px;
|
| 270 |
+
--shadow-panel: 0 4px 24px rgba(0,0,0,0.4);
|
| 271 |
+
--glow-cyan: 0 0 20px rgba(0,212,255,0.15);
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
* { box-sizing: border-box; }
|
| 275 |
+
|
| 276 |
+
body, .gradio-container {
|
| 277 |
+
background: var(--bg-void) !important;
|
| 278 |
+
font-family: var(--font-body) !important;
|
| 279 |
+
color: var(--text-primary) !important;
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
/* ββ Header / Brand ββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 283 |
+
.hix-header {
|
| 284 |
+
background: linear-gradient(135deg, var(--bg-deep) 0%, var(--bg-panel) 100%);
|
| 285 |
+
border-bottom: 1px solid var(--border-dim);
|
| 286 |
+
padding: 28px 40px 24px;
|
| 287 |
+
text-align: center;
|
| 288 |
+
position: relative;
|
| 289 |
+
overflow: hidden;
|
| 290 |
+
}
|
| 291 |
+
|
| 292 |
+
.hix-header::before {
|
| 293 |
+
content: '';
|
| 294 |
+
position: absolute;
|
| 295 |
+
top: 0; left: 0; right: 0; bottom: 0;
|
| 296 |
+
background: radial-gradient(ellipse 60% 50% at 50% -20%, rgba(0,212,255,0.08) 0%, transparent 70%);
|
| 297 |
+
pointer-events: none;
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
.hix-logo {
|
| 301 |
+
font-family: var(--font-display);
|
| 302 |
+
font-weight: 800;
|
| 303 |
+
font-size: 2.4rem;
|
| 304 |
+
letter-spacing: -0.02em;
|
| 305 |
+
background: linear-gradient(135deg, var(--accent-cyan) 0%, #7b9fff 50%, var(--accent-teal) 100%);
|
| 306 |
+
-webkit-background-clip: text;
|
| 307 |
+
-webkit-text-fill-color: transparent;
|
| 308 |
+
background-clip: text;
|
| 309 |
+
margin: 0;
|
| 310 |
+
line-height: 1;
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
.hix-tagline {
|
| 314 |
+
font-family: var(--font-mono);
|
| 315 |
+
font-size: 0.75rem;
|
| 316 |
+
color: var(--text-secondary);
|
| 317 |
+
letter-spacing: 0.12em;
|
| 318 |
+
text-transform: uppercase;
|
| 319 |
+
margin-top: 6px;
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
.hix-badge {
|
| 323 |
+
display: inline-block;
|
| 324 |
+
background: rgba(0,212,255,0.1);
|
| 325 |
+
border: 1px solid rgba(0,212,255,0.25);
|
| 326 |
+
color: var(--accent-cyan);
|
| 327 |
+
font-family: var(--font-mono);
|
| 328 |
+
font-size: 0.65rem;
|
| 329 |
+
letter-spacing: 0.1em;
|
| 330 |
+
padding: 3px 10px;
|
| 331 |
+
border-radius: 20px;
|
| 332 |
+
margin-top: 10px;
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
/* ββ Tab Navigation βββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 336 |
+
.tabs > .tab-nav {
|
| 337 |
+
background: var(--bg-panel) !important;
|
| 338 |
+
border-bottom: 1px solid var(--border-dim) !important;
|
| 339 |
+
padding: 0 20px !important;
|
| 340 |
+
gap: 4px !important;
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
.tabs > .tab-nav > button {
|
| 344 |
+
font-family: var(--font-display) !important;
|
| 345 |
+
font-weight: 600 !important;
|
| 346 |
+
font-size: 0.82rem !important;
|
| 347 |
+
letter-spacing: 0.04em !important;
|
| 348 |
+
color: var(--text-muted) !important;
|
| 349 |
+
background: transparent !important;
|
| 350 |
+
border: none !important;
|
| 351 |
+
border-bottom: 2px solid transparent !important;
|
| 352 |
+
padding: 14px 18px !important;
|
| 353 |
+
border-radius: 0 !important;
|
| 354 |
+
transition: all 0.2s ease !important;
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
.tabs > .tab-nav > button:hover {
|
| 358 |
+
color: var(--text-secondary) !important;
|
| 359 |
+
background: rgba(255,255,255,0.03) !important;
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
.tabs > .tab-nav > button.selected {
|
| 363 |
+
color: var(--accent-cyan) !important;
|
| 364 |
+
border-bottom-color: var(--accent-cyan) !important;
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
/* ββ Panels & Cards βββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 368 |
+
.tab-content, .tabitem {
|
| 369 |
+
background: var(--bg-deep) !important;
|
| 370 |
+
padding: 24px !important;
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
.section-card {
|
| 374 |
+
background: var(--bg-card);
|
| 375 |
+
border: 1px solid var(--border-dim);
|
| 376 |
+
border-radius: var(--radius);
|
| 377 |
+
padding: 20px;
|
| 378 |
+
margin-bottom: 16px;
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
.section-label {
|
| 382 |
+
font-family: var(--font-display);
|
| 383 |
+
font-size: 0.7rem;
|
| 384 |
+
font-weight: 600;
|
| 385 |
+
letter-spacing: 0.12em;
|
| 386 |
+
text-transform: uppercase;
|
| 387 |
+
color: var(--text-muted);
|
| 388 |
+
margin-bottom: 12px;
|
| 389 |
+
display: flex;
|
| 390 |
+
align-items: center;
|
| 391 |
+
gap: 8px;
|
| 392 |
+
}
|
| 393 |
+
|
| 394 |
+
.section-label::after {
|
| 395 |
+
content: '';
|
| 396 |
+
flex: 1;
|
| 397 |
+
height: 1px;
|
| 398 |
+
background: var(--border-dim);
|
| 399 |
+
}
|
| 400 |
+
|
| 401 |
+
/* ββ Inputs βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 402 |
+
textarea, .gr-textbox textarea {
|
| 403 |
+
background: var(--bg-input) !important;
|
| 404 |
+
border: 1px solid var(--border-dim) !important;
|
| 405 |
+
border-radius: var(--radius) !important;
|
| 406 |
+
color: var(--text-primary) !important;
|
| 407 |
+
font-family: var(--font-body) !important;
|
| 408 |
+
font-size: 0.9rem !important;
|
| 409 |
+
line-height: 1.6 !important;
|
| 410 |
+
transition: border-color 0.2s ease !important;
|
| 411 |
+
}
|
| 412 |
+
|
| 413 |
+
textarea:focus, .gr-textbox textarea:focus {
|
| 414 |
+
border-color: var(--accent-cyan) !important;
|
| 415 |
+
box-shadow: 0 0 0 3px rgba(0,212,255,0.08) !important;
|
| 416 |
+
outline: none !important;
|
| 417 |
+
}
|
| 418 |
+
|
| 419 |
+
.gr-textbox label span, label span {
|
| 420 |
+
font-family: var(--font-display) !important;
|
| 421 |
+
font-size: 0.78rem !important;
|
| 422 |
+
font-weight: 600 !important;
|
| 423 |
+
letter-spacing: 0.06em !important;
|
| 424 |
+
text-transform: uppercase !important;
|
| 425 |
+
color: var(--text-secondary) !important;
|
| 426 |
+
}
|
| 427 |
+
|
| 428 |
+
/* ββ Dropdowns / Selects βββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 429 |
+
.gr-dropdown, select {
|
| 430 |
+
background: var(--bg-input) !important;
|
| 431 |
+
border: 1px solid var(--border-dim) !important;
|
| 432 |
+
border-radius: var(--radius) !important;
|
| 433 |
+
color: var(--text-primary) !important;
|
| 434 |
+
font-family: var(--font-body) !important;
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
/* ββ Buttons βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 438 |
+
button.primary, .gr-button.primary, button[variant="primary"] {
|
| 439 |
+
background: linear-gradient(135deg, #006fff 0%, var(--accent-cyan) 100%) !important;
|
| 440 |
+
border: none !important;
|
| 441 |
+
border-radius: var(--radius) !important;
|
| 442 |
+
color: #fff !important;
|
| 443 |
+
font-family: var(--font-display) !important;
|
| 444 |
+
font-weight: 700 !important;
|
| 445 |
+
font-size: 0.85rem !important;
|
| 446 |
+
letter-spacing: 0.06em !important;
|
| 447 |
+
padding: 12px 28px !important;
|
| 448 |
+
transition: all 0.25s ease !important;
|
| 449 |
+
box-shadow: 0 4px 16px rgba(0,111,255,0.3) !important;
|
| 450 |
+
}
|
| 451 |
+
|
| 452 |
+
button.primary:hover, .gr-button.primary:hover {
|
| 453 |
+
transform: translateY(-1px) !important;
|
| 454 |
+
box-shadow: 0 6px 24px rgba(0,212,255,0.4) !important;
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
button.secondary, .gr-button.secondary {
|
| 458 |
+
background: var(--bg-card) !important;
|
| 459 |
+
border: 1px solid var(--border-glow) !important;
|
| 460 |
+
border-radius: var(--radius) !important;
|
| 461 |
+
color: var(--text-secondary) !important;
|
| 462 |
+
font-family: var(--font-display) !important;
|
| 463 |
+
font-weight: 600 !important;
|
| 464 |
+
font-size: 0.82rem !important;
|
| 465 |
+
transition: all 0.2s ease !important;
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
button.secondary:hover {
|
| 469 |
+
border-color: var(--accent-cyan) !important;
|
| 470 |
+
color: var(--accent-cyan) !important;
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
/* ββ Status Bar βββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 474 |
+
.status-ok { color: var(--accent-teal) !important; font-family: var(--font-mono) !important; font-size: 0.8rem !important; }
|
| 475 |
+
.status-err { color: var(--accent-rose) !important; font-family: var(--font-mono) !important; font-size: 0.8rem !important; }
|
| 476 |
+
|
| 477 |
+
/* ββ Agent Output Labels βββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 478 |
+
.agent1-label { border-left: 3px solid var(--accent-amber) !important; padding-left: 10px !important; }
|
| 479 |
+
.agent2-label { border-left: 3px solid var(--accent-cyan) !important; padding-left: 10px !important; }
|
| 480 |
+
|
| 481 |
+
/* ββ Footer βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 482 |
+
.hix-footer {
|
| 483 |
+
text-align: center;
|
| 484 |
+
padding: 20px;
|
| 485 |
+
border-top: 1px solid var(--border-dim);
|
| 486 |
+
font-family: var(--font-mono);
|
| 487 |
+
font-size: 0.7rem;
|
| 488 |
+
color: var(--text-muted);
|
| 489 |
+
background: var(--bg-panel);
|
| 490 |
+
}
|
| 491 |
+
|
| 492 |
+
/* ββ Scrollbar ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 493 |
+
::-webkit-scrollbar { width: 6px; height: 6px; }
|
| 494 |
+
::-webkit-scrollbar-track { background: var(--bg-deep); }
|
| 495 |
+
::-webkit-scrollbar-thumb { background: var(--border-glow); border-radius: 3px; }
|
| 496 |
+
::-webkit-scrollbar-thumb:hover { background: var(--accent-cyan); }
|
| 497 |
+
|
| 498 |
+
/* ββ Accordion ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
| 499 |
+
.gr-accordion {
|
| 500 |
+
background: var(--bg-card) !important;
|
| 501 |
+
border: 1px solid var(--border-dim) !important;
|
| 502 |
+
border-radius: var(--radius) !important;
|
| 503 |
+
}
|
| 504 |
+
"""
|
| 505 |
+
|
| 506 |
+
# ββ Build Gradio App βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 507 |
+
with gr.Blocks(
|
| 508 |
+
theme=gr.themes.Base(
|
| 509 |
+
primary_hue="cyan",
|
| 510 |
+
secondary_hue="blue",
|
| 511 |
+
neutral_hue="slate",
|
| 512 |
+
font=gr.themes.GoogleFont("DM Sans"),
|
| 513 |
+
),
|
| 514 |
+
css=custom_css,
|
| 515 |
+
title="HIX-Gen: Multi-Agent Writing Suite",
|
| 516 |
+
) as demo:
|
| 517 |
+
|
| 518 |
+
# ββ Header ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 519 |
+
gr.HTML("""
|
| 520 |
+
<div class="hix-header">
|
| 521 |
+
<h1 class="hix-logo">HIX-Gen</h1>
|
| 522 |
+
<p class="hix-tagline">Multi-Agent Writing Suite</p>
|
| 523 |
+
<span class="hix-badge">β‘ Powered by Google Gemini Β· Dual-Agent Architecture</span>
|
| 524 |
+
</div>
|
| 525 |
+
""")
|
| 526 |
+
|
| 527 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 528 |
+
# TABS
|
| 529 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 530 |
+
with gr.Tabs():
|
| 531 |
+
|
| 532 |
+
# ββ Tab 1: AI Humanizer ββββββββββββββββββββββββββββββββββββββββββ
|
| 533 |
+
with gr.TabItem("𧬠AI Humanizer"):
|
| 534 |
+
gr.HTML("""
|
| 535 |
+
<div style="padding:16px 0 8px">
|
| 536 |
+
<p style="color:#8899aa;font-size:0.9rem;line-height:1.6;margin:0">
|
| 537 |
+
Paste robotic AI-generated text and our <strong style="color:#00d4ff">dual-agent system</strong> will transform it
|
| 538 |
+
into natural, human-sounding prose that bypasses AI detectors.
|
| 539 |
+
</p>
|
| 540 |
+
</div>
|
| 541 |
+
""")
|
| 542 |
+
with gr.Row():
|
| 543 |
+
with gr.Column(scale=1):
|
| 544 |
+
h_input = gr.Textbox(
|
| 545 |
+
label="π€ AI-Generated Text (Input)",
|
| 546 |
+
placeholder="Paste your AI-generated text here. For example: 'It is important to note that effective communication is a fundamental aspect that contributes significantly to organizational success...'",
|
| 547 |
+
lines=10,
|
| 548 |
+
elem_classes=["section-card"]
|
| 549 |
+
)
|
| 550 |
+
h_btn = gr.Button("π Humanize Text", variant="primary")
|
| 551 |
+
h_status = gr.Markdown("", elem_classes=["status-ok"])
|
| 552 |
+
|
| 553 |
+
with gr.Column(scale=1):
|
| 554 |
+
h_draft = gr.Textbox(
|
| 555 |
+
label="π Agent 1 β Natural Draft",
|
| 556 |
+
lines=5,
|
| 557 |
+
interactive=False,
|
| 558 |
+
elem_classes=["agent1-label"]
|
| 559 |
+
)
|
| 560 |
+
h_final = gr.Textbox(
|
| 561 |
+
label="β¨ Agent 2 β Final Human Output",
|
| 562 |
+
lines=8,
|
| 563 |
+
interactive=False,
|
| 564 |
+
elem_classes=["agent2-label"]
|
| 565 |
+
)
|
| 566 |
+
|
| 567 |
+
h_btn.click(
|
| 568 |
+
fn=run_humanizer,
|
| 569 |
+
inputs=[h_input],
|
| 570 |
+
outputs=[h_draft, h_final, h_status]
|
| 571 |
+
)
|
| 572 |
+
|
| 573 |
+
# ββ Tab 2: AI Writer βββββββββββββββββββββββββββββββββββββββββββββ
|
| 574 |
+
with gr.TabItem("βοΈ AI Writer"):
|
| 575 |
+
gr.HTML("""
|
| 576 |
+
<div style="padding:16px 0 8px">
|
| 577 |
+
<p style="color:#8899aa;font-size:0.9rem;line-height:1.6;margin:0">
|
| 578 |
+
Select a content template, fill in your details, and let two AI agents craft and polish your content.
|
| 579 |
+
</p>
|
| 580 |
+
</div>
|
| 581 |
+
""")
|
| 582 |
+
with gr.Row():
|
| 583 |
+
with gr.Column(scale=1):
|
| 584 |
+
w_template = gr.Dropdown(
|
| 585 |
+
choices=list(WRITER_TEMPLATES.keys()),
|
| 586 |
+
value="π Blog Post",
|
| 587 |
+
label="Content Template",
|
| 588 |
+
)
|
| 589 |
+
w_f1 = gr.Textbox(label="Topic / Title", placeholder="Enter topic / title...", lines=2)
|
| 590 |
+
w_f2 = gr.Textbox(label="Target Audience", placeholder="Enter target audience...", lines=2)
|
| 591 |
+
w_f3 = gr.Textbox(label="Key Points to Cover", placeholder="Enter key points...", lines=3)
|
| 592 |
+
w_f4 = gr.Textbox(label="Tone (casual/formal/witty)", placeholder="Enter tone...", lines=1)
|
| 593 |
+
w_btn = gr.Button("π Generate Content", variant="primary")
|
| 594 |
+
w_status = gr.Markdown("", elem_classes=["status-ok"])
|
| 595 |
+
|
| 596 |
+
with gr.Column(scale=1):
|
| 597 |
+
w_draft = gr.Textbox(
|
| 598 |
+
label="π Agent 1 β First Draft",
|
| 599 |
+
lines=8,
|
| 600 |
+
interactive=False,
|
| 601 |
+
elem_classes=["agent1-label"]
|
| 602 |
+
)
|
| 603 |
+
w_final = gr.Textbox(
|
| 604 |
+
label="β¨ Agent 2 β Polished Output",
|
| 605 |
+
lines=12,
|
| 606 |
+
interactive=False,
|
| 607 |
+
elem_classes=["agent2-label"]
|
| 608 |
+
)
|
| 609 |
+
|
| 610 |
+
# Dynamic field labels
|
| 611 |
+
w_template.change(
|
| 612 |
+
fn=update_writer_labels,
|
| 613 |
+
inputs=[w_template],
|
| 614 |
+
outputs=[w_f1, w_f2, w_f3, w_f4]
|
| 615 |
+
)
|
| 616 |
+
|
| 617 |
+
w_btn.click(
|
| 618 |
+
fn=run_writer,
|
| 619 |
+
inputs=[w_template, w_f1, w_f2, w_f3, w_f4],
|
| 620 |
+
outputs=[w_draft, w_final, w_status]
|
| 621 |
+
)
|
| 622 |
+
|
| 623 |
+
# ββ Tab 3: Smart Editor ββββββββββββββββββββββββββββββββββββββββββ
|
| 624 |
+
with gr.TabItem("π§ Smart Editor"):
|
| 625 |
+
gr.HTML("""
|
| 626 |
+
<div style="padding:16px 0 8px">
|
| 627 |
+
<p style="color:#8899aa;font-size:0.9rem;line-height:1.6;margin:0">
|
| 628 |
+
Paste any text and choose an editing mode. Two agents will transform your content with precision.
|
| 629 |
+
</p>
|
| 630 |
+
</div>
|
| 631 |
+
""")
|
| 632 |
+
with gr.Row():
|
| 633 |
+
with gr.Column(scale=1):
|
| 634 |
+
e_mode = gr.Dropdown(
|
| 635 |
+
choices=list(EDITOR_MODES.keys()),
|
| 636 |
+
value="β¨ Improve Writing",
|
| 637 |
+
label="Editing Mode",
|
| 638 |
+
)
|
| 639 |
+
e_input = gr.Textbox(
|
| 640 |
+
label="π Your Text",
|
| 641 |
+
placeholder="Paste the text you want to edit here...",
|
| 642 |
+
lines=10,
|
| 643 |
+
elem_classes=["section-card"]
|
| 644 |
+
)
|
| 645 |
+
e_extra = gr.Textbox(
|
| 646 |
+
label="π‘ Special Instructions (optional)",
|
| 647 |
+
placeholder="e.g. 'Make it sound like a Gen-Z influencer' or 'Focus on the technical aspects' or 'Target tone: empathetic'",
|
| 648 |
+
lines=2
|
| 649 |
+
)
|
| 650 |
+
e_btn = gr.Button("π Process Text", variant="primary")
|
| 651 |
+
e_status = gr.Markdown("", elem_classes=["status-ok"])
|
| 652 |
+
|
| 653 |
+
with gr.Column(scale=1):
|
| 654 |
+
e_draft = gr.Textbox(
|
| 655 |
+
label="π Agent 1 β Processed Draft",
|
| 656 |
+
lines=8,
|
| 657 |
+
interactive=False,
|
| 658 |
+
elem_classes=["agent1-label"]
|
| 659 |
+
)
|
| 660 |
+
e_final = gr.Textbox(
|
| 661 |
+
label="β¨ Agent 2 β Final Output",
|
| 662 |
+
lines=12,
|
| 663 |
+
interactive=False,
|
| 664 |
+
elem_classes=["agent2-label"]
|
| 665 |
+
)
|
| 666 |
+
|
| 667 |
+
e_btn.click(
|
| 668 |
+
fn=run_editor,
|
| 669 |
+
inputs=[e_input, e_mode, e_extra],
|
| 670 |
+
outputs=[e_draft, e_final, e_status]
|
| 671 |
+
)
|
| 672 |
+
|
| 673 |
+
# ββ Tab 4: About βββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 674 |
+
with gr.TabItem("βΉοΈ About"):
|
| 675 |
+
gr.HTML("""
|
| 676 |
+
<div style="max-width:720px;margin:32px auto;padding:0 16px">
|
| 677 |
+
|
| 678 |
+
<h2 style="font-family:'Syne',sans-serif;font-weight:800;font-size:1.6rem;color:#e8edf5;margin-bottom:8px">
|
| 679 |
+
HIX-Gen: Multi-Agent Writing Suite
|
| 680 |
+
</h2>
|
| 681 |
+
<p style="color:#8899aa;font-size:0.9rem;line-height:1.7;margin-bottom:24px">
|
| 682 |
+
A professional AI writing platform built with a <strong style="color:#00d4ff">dual-agent architecture</strong>
|
| 683 |
+
β one agent generates, a second refines. Every output goes through two expert AI passes.
|
| 684 |
+
</p>
|
| 685 |
+
|
| 686 |
+
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:16px;margin-bottom:32px">
|
| 687 |
+
|
| 688 |
+
<div style="background:#161c27;border:1px solid #1f2d3d;border-radius:10px;padding:20px">
|
| 689 |
+
<div style="color:#f0a500;font-size:1.4rem;margin-bottom:8px">π§¬</div>
|
| 690 |
+
<div style="font-family:'Syne',sans-serif;font-weight:700;color:#e8edf5;margin-bottom:6px">AI Humanizer</div>
|
| 691 |
+
<div style="color:#8899aa;font-size:0.82rem;line-height:1.6">Transforms robotic AI text into natural, human-sounding prose that passes AI detectors.</div>
|
| 692 |
+
</div>
|
| 693 |
+
|
| 694 |
+
<div style="background:#161c27;border:1px solid #1f2d3d;border-radius:10px;padding:20px">
|
| 695 |
+
<div style="color:#00b894;font-size:1.4rem;margin-bottom:8px">βοΈ</div>
|
| 696 |
+
<div style="font-family:'Syne',sans-serif;font-weight:700;color:#e8edf5;margin-bottom:6px">AI Writer</div>
|
| 697 |
+
<div style="color:#8899aa;font-size:0.82rem;line-height:1.6">Template-based content generation: Blog Posts, Emails, Social Media β all dual-agent polished.</div>
|
| 698 |
+
</div>
|
| 699 |
+
|
| 700 |
+
<div style="background:#161c27;border:1px solid #1f2d3d;border-radius:10px;padding:20px">
|
| 701 |
+
<div style="color:#00d4ff;font-size:1.4rem;margin-bottom:8px">π§</div>
|
| 702 |
+
<div style="font-family:'Syne',sans-serif;font-weight:700;color:#e8edf5;margin-bottom:6px">Smart Editor</div>
|
| 703 |
+
<div style="color:#8899aa;font-size:0.82rem;line-height:1.6">Summarize, improve, change tone, or expand any text with surgical AI precision.</div>
|
| 704 |
+
</div>
|
| 705 |
+
</div>
|
| 706 |
+
|
| 707 |
+
<div style="background:#111620;border:1px solid #1f2d3d;border-radius:10px;padding:20px;margin-bottom:20px">
|
| 708 |
+
<div style="font-family:'Syne',sans-serif;font-weight:700;color:#e8edf5;margin-bottom:12px">βοΈ Tech Stack</div>
|
| 709 |
+
<div style="display:grid;grid-template-columns:auto 1fr;gap:6px 20px;font-size:0.85rem">
|
| 710 |
+
<span style="color:#8899aa">AI Engine</span><span style="color:#00d4ff;font-family:'DM Mono',monospace">Google Gemini 1.5 Flash</span>
|
| 711 |
+
<span style="color:#8899aa">Framework</span><span style="color:#00d4ff;font-family:'DM Mono',monospace">Gradio 4.x</span>
|
| 712 |
+
<span style="color:#8899aa">Architecture</span><span style="color:#00d4ff;font-family:'DM Mono',monospace">Dual-Agent Pipeline</span>
|
| 713 |
+
<span style="color:#8899aa">Platform</span><span style="color:#00d4ff;font-family:'DM Mono',monospace">Hugging Face Spaces</span>
|
| 714 |
+
<span style="color:#8899aa">Theme</span><span style="color:#00d4ff;font-family:'DM Mono',monospace">Custom Dark UI</span>
|
| 715 |
+
</div>
|
| 716 |
+
</div>
|
| 717 |
+
|
| 718 |
+
<p style="color:#4a5568;font-size:0.78rem;font-family:'DM Mono',monospace;text-align:center">
|
| 719 |
+
Built as an open-source HIX.AI-inspired clone Β· MIT License
|
| 720 |
+
</p>
|
| 721 |
+
</div>
|
| 722 |
+
""")
|
| 723 |
+
|
| 724 |
+
# ββ Footer βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 725 |
+
gr.HTML("""
|
| 726 |
+
<div class="hix-footer">
|
| 727 |
+
HIX-Gen v1.0 Β· Dual-Agent Architecture Β· Powered by Google Gemini 1.5 Flash Β· Deployed on Hugging Face Spaces
|
| 728 |
+
</div>
|
| 729 |
+
""")
|
| 730 |
+
|
| 731 |
+
# ββ Launch βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 732 |
+
if __name__ == "__main__":
|
| 733 |
+
demo.launch(
|
| 734 |
+
server_name="0.0.0.0",
|
| 735 |
+
server_port=7860,
|
| 736 |
+
show_error=True,
|
| 737 |
+
)
|