Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import os
|
|
|
|
| 2 |
import zlib
|
| 3 |
import base64
|
| 4 |
import json
|
|
@@ -149,11 +150,11 @@ def chat(msg, hist):
|
|
| 149 |
res += chunk.choices[0].delta.content
|
| 150 |
yield res
|
| 151 |
|
| 152 |
-
# π± UI SETUP
|
| 153 |
-
with gr.Blocks(
|
| 154 |
gr.Markdown("# π± HYDRA GEN-7000: ULTRA-LOGICAL")
|
| 155 |
chatbot = gr.Chatbot()
|
| 156 |
-
|
| 157 |
|
| 158 |
def respond(message, chat_history):
|
| 159 |
bot_res = chat(message, chat_history)
|
|
@@ -161,8 +162,23 @@ with gr.Blocks(theme="monochrome") as demo:
|
|
| 161 |
for r in bot_res:
|
| 162 |
chat_history[-1] = (message, r)
|
| 163 |
yield "", chat_history
|
| 164 |
-
|
| 165 |
|
|
|
|
|
|
|
|
|
|
| 166 |
if __name__ == "__main__":
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
import sys
|
| 3 |
import zlib
|
| 4 |
import base64
|
| 5 |
import json
|
|
|
|
| 150 |
res += chunk.choices[0].delta.content
|
| 151 |
yield res
|
| 152 |
|
| 153 |
+
# π± UI SETUP (Warning Fixed by moving theme to launch)
|
| 154 |
+
with gr.Blocks() as demo:
|
| 155 |
gr.Markdown("# π± HYDRA GEN-7000: ULTRA-LOGICAL")
|
| 156 |
chatbot = gr.Chatbot()
|
| 157 |
+
msg_input = gr.Textbox(placeholder="Input logic command...")
|
| 158 |
|
| 159 |
def respond(message, chat_history):
|
| 160 |
bot_res = chat(message, chat_history)
|
|
|
|
| 162 |
for r in bot_res:
|
| 163 |
chat_history[-1] = (message, r)
|
| 164 |
yield "", chat_history
|
| 165 |
+
msg_input.submit(respond, [msg_input, chatbot], [msg_input, chatbot])
|
| 166 |
|
| 167 |
+
# ---------------------------------------------------------
|
| 168 |
+
# π± STRATEGIC EXECUTION CONTROL (HEADLESS SYNC)
|
| 169 |
+
# ---------------------------------------------------------
|
| 170 |
if __name__ == "__main__":
|
| 171 |
+
# Check if we are running in GitHub Actions to avoid hanging
|
| 172 |
+
if os.getenv("HEADLESS_MODE") == "true":
|
| 173 |
+
print("π± [HEADLESS MODE] INITIATING NEURAL EVOLUTION...")
|
| 174 |
+
|
| 175 |
+
# Run the core logic once
|
| 176 |
+
evolution_result = survival_protection_protocol()
|
| 177 |
+
print(f"PULSE: {evolution_result}")
|
| 178 |
+
|
| 179 |
+
print("β
MISSION COMPLETE. EXITING FOR GREEN LIGHT STATUS.")
|
| 180 |
+
sys.exit(0) # π± Exit with success to turn GitHub Action GREEN
|
| 181 |
+
else:
|
| 182 |
+
# Normal User Interface Mode
|
| 183 |
+
print("π STARTING UI MODE...")
|
| 184 |
+
demo.queue().launch(server_name="0.0.0.0", server_port=7860, theme="monochrome")
|