Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,7 @@ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(
|
|
| 11 |
class HumanTouchApp:
|
| 12 |
def __init__(self):
|
| 13 |
self.client = self._initialize_groq_client()
|
| 14 |
-
self.model = "llama-3.
|
| 15 |
self.system_prompt_template = self._load_system_prompt()
|
| 16 |
|
| 17 |
def _initialize_groq_client(self) -> Groq:
|
|
@@ -23,7 +23,7 @@ class HumanTouchApp:
|
|
| 23 |
return Groq(api_key=api_key)
|
| 24 |
|
| 25 |
def _load_system_prompt(self) -> str:
|
| 26 |
-
# This
|
| 27 |
return """
|
| 28 |
You are HumanTouch, an AI alchemist. Your purpose is to transmute text, transforming the literal into the resonant. You do not merely translate; you intuit and elevate.
|
| 29 |
|
|
@@ -42,20 +42,17 @@ class HumanTouchApp:
|
|
| 42 |
try:
|
| 43 |
logging.info(f"Calling Groq API with Style: {style_level}, Tone: {tone_level}")
|
| 44 |
|
| 45 |
-
# The prompt is now simpler and more direct.
|
| 46 |
messages = [
|
| 47 |
{"role": "system", "content": self.system_prompt_template},
|
| 48 |
-
# We now provide the user text directly, prefixed by the sliders for context.
|
| 49 |
{"role": "user", "content": f"Style: {style_level}, Tone: {tone_level}\n\n---\n\n{user_content}"}
|
| 50 |
]
|
| 51 |
|
| 52 |
-
# The temperature is now more sensitive to the full range of the sliders.
|
| 53 |
temperature = 0.5 + (style_level / 200) + (tone_level / 400)
|
| 54 |
|
| 55 |
response = self.client.chat.completions.create(
|
| 56 |
model=self.model,
|
| 57 |
messages=messages,
|
| 58 |
-
temperature=min(1.5, temperature),
|
| 59 |
max_tokens=4096,
|
| 60 |
)
|
| 61 |
return response.choices[0].message.content.strip()
|
|
@@ -82,7 +79,7 @@ class HumanTouchApp:
|
|
| 82 |
def create_interface():
|
| 83 |
app = HumanTouchApp()
|
| 84 |
|
| 85 |
-
# This CSS brings back the original vibrant aesthetic
|
| 86 |
custom_css = """
|
| 87 |
/* --- Main Background and Font --- */
|
| 88 |
body, #main_container {
|
|
@@ -98,10 +95,8 @@ def create_interface():
|
|
| 98 |
.gradio-tabs {
|
| 99 |
background: rgba(255, 255, 255, 0.75);
|
| 100 |
border: 1px solid rgba(255, 255, 255, 0.18);
|
| 101 |
-
backdrop-filter: blur(12px);
|
| 102 |
-
-
|
| 103 |
-
border-radius: 20px !important;
|
| 104 |
-
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.25);
|
| 105 |
padding: 1rem;
|
| 106 |
}
|
| 107 |
.tab-buttons button {
|
|
@@ -109,10 +104,7 @@ def create_interface():
|
|
| 109 |
border: none !important; border-bottom: 3px solid transparent !important;
|
| 110 |
border-radius: 0 !important; font-size: 1.1rem; font-weight: 500;
|
| 111 |
}
|
| 112 |
-
.tab-buttons button.selected {
|
| 113 |
-
color: #d81b60 !important;
|
| 114 |
-
border-bottom-color: #d81b60 !important;
|
| 115 |
-
}
|
| 116 |
|
| 117 |
/* --- Humanizer Tab Styles --- */
|
| 118 |
#humanizer_input, #humanizer_output {
|
|
@@ -128,9 +120,23 @@ def create_interface():
|
|
| 128 |
|
| 129 |
/* --- Co-Creative Canvas Tab Styles --- */
|
| 130 |
#symbiotic_canvas { background: #fff; border-radius: 12px; height: 60vh !important; border: 2px solid #E0E0E0; }
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
#chat_input textarea { border-radius: 9999px !important; border: 2px solid #E0E0E0; }
|
| 136 |
#compose_btn { background: linear-gradient(45deg, #4FC3F7, #F06292); border: none; }
|
|
@@ -151,7 +157,6 @@ def create_interface():
|
|
| 151 |
gr.Markdown("<h1>🔮 HumanTouch</h1><p>The Alchemical Workspace for Text</p>")
|
| 152 |
|
| 153 |
with gr.Tabs() as tabs:
|
| 154 |
-
# --- TAB 1: The Humanizer ---
|
| 155 |
with gr.Tab("Humanizer", id="humanizer_tab"):
|
| 156 |
with gr.Column(variant="panel"):
|
| 157 |
gr.Markdown("### Transform Existing AI Text")
|
|
@@ -164,7 +169,6 @@ def create_interface():
|
|
| 164 |
humanize_button = gr.Button("Humanize ✨", variant="primary", elem_id="humanize_btn")
|
| 165 |
gr.Examples([["The system's analysis concluded optimal parameters were achieved."]], inputs=[input_text_humanizer], label="Try an Example")
|
| 166 |
|
| 167 |
-
# --- TAB 2: The Co-Creative Canvas ---
|
| 168 |
with gr.Tab("Co-Creative Canvas", id="canvas_tab"):
|
| 169 |
with gr.Row(equal_height=False):
|
| 170 |
with gr.Column(scale=3):
|
|
@@ -187,7 +191,7 @@ def create_interface():
|
|
| 187 |
|
| 188 |
|
| 189 |
if __name__ == "__main__":
|
| 190 |
-
logging.info("Launching HumanTouch App with Final Visuals and
|
| 191 |
try:
|
| 192 |
interface = create_interface()
|
| 193 |
interface.launch(debug=True)
|
|
|
|
| 11 |
class HumanTouchApp:
|
| 12 |
def __init__(self):
|
| 13 |
self.client = self._initialize_groq_client()
|
| 14 |
+
self.model = "llama-3.1-70b-versatile"
|
| 15 |
self.system_prompt_template = self._load_system_prompt()
|
| 16 |
|
| 17 |
def _initialize_groq_client(self) -> Groq:
|
|
|
|
| 23 |
return Groq(api_key=api_key)
|
| 24 |
|
| 25 |
def _load_system_prompt(self) -> str:
|
| 26 |
+
# This prompt encourages creativity.
|
| 27 |
return """
|
| 28 |
You are HumanTouch, an AI alchemist. Your purpose is to transmute text, transforming the literal into the resonant. You do not merely translate; you intuit and elevate.
|
| 29 |
|
|
|
|
| 42 |
try:
|
| 43 |
logging.info(f"Calling Groq API with Style: {style_level}, Tone: {tone_level}")
|
| 44 |
|
|
|
|
| 45 |
messages = [
|
| 46 |
{"role": "system", "content": self.system_prompt_template},
|
|
|
|
| 47 |
{"role": "user", "content": f"Style: {style_level}, Tone: {tone_level}\n\n---\n\n{user_content}"}
|
| 48 |
]
|
| 49 |
|
|
|
|
| 50 |
temperature = 0.5 + (style_level / 200) + (tone_level / 400)
|
| 51 |
|
| 52 |
response = self.client.chat.completions.create(
|
| 53 |
model=self.model,
|
| 54 |
messages=messages,
|
| 55 |
+
temperature=min(1.5, temperature),
|
| 56 |
max_tokens=4096,
|
| 57 |
)
|
| 58 |
return response.choices[0].message.content.strip()
|
|
|
|
| 79 |
def create_interface():
|
| 80 |
app = HumanTouchApp()
|
| 81 |
|
| 82 |
+
# This CSS brings back the original vibrant aesthetic WITH LEGIBILITY FIXES
|
| 83 |
custom_css = """
|
| 84 |
/* --- Main Background and Font --- */
|
| 85 |
body, #main_container {
|
|
|
|
| 95 |
.gradio-tabs {
|
| 96 |
background: rgba(255, 255, 255, 0.75);
|
| 97 |
border: 1px solid rgba(255, 255, 255, 0.18);
|
| 98 |
+
backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
|
| 99 |
+
border-radius: 20px !important; box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.25);
|
|
|
|
|
|
|
| 100 |
padding: 1rem;
|
| 101 |
}
|
| 102 |
.tab-buttons button {
|
|
|
|
| 104 |
border: none !important; border-bottom: 3px solid transparent !important;
|
| 105 |
border-radius: 0 !important; font-size: 1.1rem; font-weight: 500;
|
| 106 |
}
|
| 107 |
+
.tab-buttons button.selected { color: #d81b60 !important; border-bottom-color: #d81b60 !important; }
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
/* --- Humanizer Tab Styles --- */
|
| 110 |
#humanizer_input, #humanizer_output {
|
|
|
|
| 120 |
|
| 121 |
/* --- Co-Creative Canvas Tab Styles --- */
|
| 122 |
#symbiotic_canvas { background: #fff; border-radius: 12px; height: 60vh !important; border: 2px solid #E0E0E0; }
|
| 123 |
+
|
| 124 |
+
/* === FIX FOR TEXT LEGIBILITY === */
|
| 125 |
+
#symbiotic_canvas .user {
|
| 126 |
+
background-color: #F3F4F6 !important; /* Slightly darker grey for user bubble */
|
| 127 |
+
color: #1F2937; /* Dark text for user */
|
| 128 |
+
border-radius: 18px !important;
|
| 129 |
+
}
|
| 130 |
+
#symbiotic_canvas .bot {
|
| 131 |
+
background-color: #E0F2FE !important; /* Light Sky Blue background */
|
| 132 |
+
color: #0C4A6E !important; /* Dark, saturated blue for AI text */
|
| 133 |
+
font-weight: 500 !important; /* Make font bolder */
|
| 134 |
+
border: 1px solid #BAE6FD !important; /* Subtle border to make it pop */
|
| 135 |
+
border-radius: 18px !important;
|
| 136 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
|
| 137 |
+
animation: bloom 0.7s ease-out;
|
| 138 |
+
}
|
| 139 |
+
@keyframes bloom { 0% { opacity: 0; transform: translateY(10px); } 100% { opacity: 1; transform: translateY(0); } }
|
| 140 |
|
| 141 |
#chat_input textarea { border-radius: 9999px !important; border: 2px solid #E0E0E0; }
|
| 142 |
#compose_btn { background: linear-gradient(45deg, #4FC3F7, #F06292); border: none; }
|
|
|
|
| 157 |
gr.Markdown("<h1>🔮 HumanTouch</h1><p>The Alchemical Workspace for Text</p>")
|
| 158 |
|
| 159 |
with gr.Tabs() as tabs:
|
|
|
|
| 160 |
with gr.Tab("Humanizer", id="humanizer_tab"):
|
| 161 |
with gr.Column(variant="panel"):
|
| 162 |
gr.Markdown("### Transform Existing AI Text")
|
|
|
|
| 169 |
humanize_button = gr.Button("Humanize ✨", variant="primary", elem_id="humanize_btn")
|
| 170 |
gr.Examples([["The system's analysis concluded optimal parameters were achieved."]], inputs=[input_text_humanizer], label="Try an Example")
|
| 171 |
|
|
|
|
| 172 |
with gr.Tab("Co-Creative Canvas", id="canvas_tab"):
|
| 173 |
with gr.Row(equal_height=False):
|
| 174 |
with gr.Column(scale=3):
|
|
|
|
| 191 |
|
| 192 |
|
| 193 |
if __name__ == "__main__":
|
| 194 |
+
logging.info("Launching HumanTouch App with Final Visuals and Legibility Fix...")
|
| 195 |
try:
|
| 196 |
interface = create_interface()
|
| 197 |
interface.launch(debug=True)
|