Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,4 @@
|
|
| 1 |
-
# app.py β Sovereign
|
| 2 |
-
# ------------------------------------------------------------------------------
|
| 3 |
-
# ARCHITECTURE: Async | Type Strict | Gradio 5+ | Live Preview | UIKit Mastery
|
| 4 |
-
# STATUS: FULLY FIXED | PRODUCTION READY | ZERO PLACEHOLDERS
|
| 5 |
-
# ------------------------------------------------------------------------------
|
| 6 |
-
|
| 7 |
import os
|
| 8 |
import json
|
| 9 |
import re
|
|
@@ -13,66 +8,84 @@ import asyncio
|
|
| 13 |
import uuid
|
| 14 |
from dataclasses import dataclass
|
| 15 |
from datetime import datetime
|
| 16 |
-
from typing import AsyncGenerator, Optional,
|
| 17 |
from collections import OrderedDict
|
| 18 |
|
| 19 |
import gradio as gr
|
| 20 |
from huggingface_hub import AsyncInferenceClient
|
| 21 |
|
| 22 |
-
# ===
|
| 23 |
class AlchemyLogger:
|
| 24 |
@staticmethod
|
| 25 |
def setup():
|
| 26 |
-
logger = logging.getLogger("
|
| 27 |
logger.setLevel(logging.INFO)
|
| 28 |
if not logger.handlers:
|
| 29 |
c_handler = logging.StreamHandler()
|
| 30 |
-
c_format = logging.Formatter('%(asctime)s | %(levelname)s | %(
|
| 31 |
c_handler.setFormatter(c_format)
|
| 32 |
logger.addHandler(c_handler)
|
| 33 |
try:
|
| 34 |
f_handler = logging.FileHandler('sovereign.log', encoding='utf-8')
|
| 35 |
f_handler.setFormatter(c_format)
|
| 36 |
logger.addHandler(f_handler)
|
| 37 |
-
except
|
| 38 |
pass
|
| 39 |
return logger
|
| 40 |
|
| 41 |
logger = AlchemyLogger.setup()
|
| 42 |
|
| 43 |
-
# ===
|
| 44 |
@dataclass(frozen=True)
|
| 45 |
class AppConfig:
|
| 46 |
HF_TOKEN: str = os.getenv("HF_TOKEN", "")
|
| 47 |
LLM_MODEL: str = os.getenv("LLM_MODEL", "Qwen/Qwen2.5-Coder-32B-Instruct")
|
| 48 |
FLUX_MODEL: str = os.getenv("FLUX_MODEL", "black-forest-labs/FLUX.1-schnell")
|
| 49 |
-
MAX_TOKENS: int =
|
| 50 |
-
TEMPERATURE: float =
|
| 51 |
-
MAX_HISTORY: int =
|
| 52 |
-
CACHE_SIZE: int =
|
| 53 |
-
REQUESTS_PER_MINUTE: int =
|
| 54 |
-
|
| 55 |
-
def validate(self) -> None:
|
| 56 |
-
logger.info(f"Configuration Loaded: LLM={self.LLM_MODEL} | Vision={self.FLUX_MODEL}")
|
| 57 |
|
| 58 |
CONFIG = AppConfig()
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
class AlchemyUtils:
|
| 71 |
@staticmethod
|
| 72 |
-
def
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
class AsyncRateLimiter:
|
| 77 |
def __init__(self, rpm: int):
|
| 78 |
self.rate = rpm
|
|
@@ -92,86 +105,44 @@ class AsyncRateLimiter:
|
|
| 92 |
|
| 93 |
class AsyncLRUCache:
|
| 94 |
def __init__(self, capacity: int):
|
| 95 |
-
self.cache: OrderedDict[str, str] = OrderedDict()
|
| 96 |
self.capacity = capacity
|
| 97 |
self.lock = asyncio.Lock()
|
| 98 |
|
| 99 |
-
async def get(self, key: str) -> Optional[str]:
|
| 100 |
async with self.lock:
|
| 101 |
if key not in self.cache:
|
| 102 |
return None
|
| 103 |
self.cache.move_to_end(key)
|
| 104 |
return self.cache[key]
|
| 105 |
|
| 106 |
-
async def set(self, key: str, value: str):
|
| 107 |
async with self.lock:
|
| 108 |
self.cache[key] = value
|
| 109 |
self.cache.move_to_end(key)
|
| 110 |
if len(self.cache) > self.capacity:
|
| 111 |
self.cache.popitem(last=False)
|
| 112 |
|
| 113 |
-
# ===
|
| 114 |
-
class ImageGenerator:
|
| 115 |
-
def __init__(self, client: AsyncInferenceClient):
|
| 116 |
-
self.client = client
|
| 117 |
-
|
| 118 |
-
async def generate(self, prompt: str):
|
| 119 |
-
try:
|
| 120 |
-
img = await self.client.text_to_image(prompt, model=CONFIG.FLUX_MODEL)
|
| 121 |
-
return img, f"Generated: {prompt[:60]}..."
|
| 122 |
-
except Exception as e:
|
| 123 |
-
return None, f"Image gen failed: {e}"
|
| 124 |
-
|
| 125 |
-
class PreviewEngine:
|
| 126 |
-
async def capture_preview(self, html_content: str) -> Optional[bytes]:
|
| 127 |
-
try:
|
| 128 |
-
from playwright.async_api import async_playwright
|
| 129 |
-
async with async_playwright() as p:
|
| 130 |
-
browser = await p.chromium.launch(headless=True)
|
| 131 |
-
page = await browser.new_page()
|
| 132 |
-
full_html = f"""
|
| 133 |
-
<!DOCTYPE html>
|
| 134 |
-
<html lang="en">
|
| 135 |
-
<head>
|
| 136 |
-
<meta charset="UTF-8">
|
| 137 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 138 |
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uikit@3/dist/css/uikit.min.css">
|
| 139 |
-
<script src="https://cdn.jsdelivr.net/npm/uikit@3/dist/js/uikit.min.js"></script>
|
| 140 |
-
<script src="https://cdn.jsdelivr.net/npm/uikit@3/dist/js/uikit-icons.min.js"></script>
|
| 141 |
-
</head>
|
| 142 |
-
<body class="uk-background-default">{html_content}</body>
|
| 143 |
-
</html>"""
|
| 144 |
-
await page.set_content(full_html, wait_until="networkidle")
|
| 145 |
-
screenshot = await page.screenshot(type="png")
|
| 146 |
-
await browser.close()
|
| 147 |
-
return screenshot
|
| 148 |
-
except Exception as e:
|
| 149 |
-
logger.error(f"Preview failed: {e}")
|
| 150 |
-
return None
|
| 151 |
-
|
| 152 |
class SovereignAgent:
|
| 153 |
def __init__(self):
|
| 154 |
self.client = AsyncInferenceClient(token=CONFIG.HF_TOKEN)
|
| 155 |
self.limiter = AsyncRateLimiter(CONFIG.REQUESTS_PER_MINUTE)
|
| 156 |
self.cache = AsyncLRUCache(CONFIG.CACHE_SIZE)
|
| 157 |
-
|
| 158 |
-
self.preview_engine = PreviewEngine()
|
| 159 |
-
logger.info("Sovereign UIKitV3 Agent Online")
|
| 160 |
|
| 161 |
-
def
|
| 162 |
-
return str(uuid.uuid5(uuid.NAMESPACE_DNS, json.dumps(history[-10:], sort_keys=True) +
|
| 163 |
|
| 164 |
-
async def
|
| 165 |
if not await self.limiter.acquire():
|
| 166 |
-
|
| 167 |
-
return
|
| 168 |
-
|
| 169 |
-
messages = [{"role": "system", "content": SYSTEM_PROMPT}] + history[-CONFIG.MAX_HISTORY:] + [{"role": "user", "content": message}]
|
| 170 |
-
key = self._hash(history, message)
|
| 171 |
|
|
|
|
| 172 |
if cached := await self.cache.get(key):
|
| 173 |
-
|
| 174 |
-
|
|
|
|
| 175 |
|
| 176 |
full = ""
|
| 177 |
try:
|
|
@@ -183,69 +154,88 @@ class SovereignAgent:
|
|
| 183 |
stream=True
|
| 184 |
)
|
| 185 |
async for chunk in stream:
|
| 186 |
-
if chunk.choices and (
|
| 187 |
-
full +=
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
preview = await self.preview_engine.capture_preview(full)
|
| 200 |
-
if preview:
|
| 201 |
-
yield full + "\n\n**Live Preview Captured**"
|
| 202 |
-
|
| 203 |
-
await self.cache.set(key, full)
|
| 204 |
except Exception as e:
|
| 205 |
-
|
|
|
|
| 206 |
|
| 207 |
-
# ===
|
| 208 |
-
def
|
| 209 |
agent = SovereignAgent()
|
| 210 |
|
| 211 |
with gr.Blocks(
|
| 212 |
-
theme=gr.themes.Soft(),
|
| 213 |
css="""
|
| 214 |
-
.
|
| 215 |
-
|
| 216 |
""",
|
| 217 |
-
title="
|
| 218 |
) as demo:
|
| 219 |
gr.HTML("""
|
| 220 |
-
<div style="text-align:
|
| 221 |
-
<h1
|
| 222 |
-
<p style="color:#94a3b8;">
|
| 223 |
</div>
|
| 224 |
""")
|
| 225 |
|
| 226 |
-
gr.
|
| 227 |
-
|
| 228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
examples=[
|
| 230 |
-
"
|
| 231 |
-
"
|
| 232 |
-
"
|
| 233 |
-
"
|
| 234 |
],
|
| 235 |
-
|
| 236 |
-
show_progress=True
|
| 237 |
)
|
| 238 |
|
| 239 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
return demo
|
| 241 |
|
| 242 |
-
# === 8. LAUNCH ===
|
| 243 |
if __name__ == "__main__":
|
| 244 |
-
logger.info("Launching
|
| 245 |
-
demo =
|
| 246 |
demo.queue(max_size=40).launch(
|
| 247 |
server_name="0.0.0.0",
|
| 248 |
server_port=7860,
|
| 249 |
-
show_error=True
|
| 250 |
-
share=False
|
| 251 |
)
|
|
|
|
| 1 |
+
# app.py β Sovereign UI Architect (FULL Premium Edition - 262 lines)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import os
|
| 3 |
import json
|
| 4 |
import re
|
|
|
|
| 8 |
import uuid
|
| 9 |
from dataclasses import dataclass
|
| 10 |
from datetime import datetime
|
| 11 |
+
from typing import AsyncGenerator, List, Optional, Tuple
|
| 12 |
from collections import OrderedDict
|
| 13 |
|
| 14 |
import gradio as gr
|
| 15 |
from huggingface_hub import AsyncInferenceClient
|
| 16 |
|
| 17 |
+
# ====================== ADVANCED LOGGING ======================
|
| 18 |
class AlchemyLogger:
|
| 19 |
@staticmethod
|
| 20 |
def setup():
|
| 21 |
+
logger = logging.getLogger("SovereignUI")
|
| 22 |
logger.setLevel(logging.INFO)
|
| 23 |
if not logger.handlers:
|
| 24 |
c_handler = logging.StreamHandler()
|
| 25 |
+
c_format = logging.Formatter('%(asctime)s | %(levelname)s | %(message)s')
|
| 26 |
c_handler.setFormatter(c_format)
|
| 27 |
logger.addHandler(c_handler)
|
| 28 |
try:
|
| 29 |
f_handler = logging.FileHandler('sovereign.log', encoding='utf-8')
|
| 30 |
f_handler.setFormatter(c_format)
|
| 31 |
logger.addHandler(f_handler)
|
| 32 |
+
except Exception:
|
| 33 |
pass
|
| 34 |
return logger
|
| 35 |
|
| 36 |
logger = AlchemyLogger.setup()
|
| 37 |
|
| 38 |
+
# ====================== CONFIG ======================
|
| 39 |
@dataclass(frozen=True)
|
| 40 |
class AppConfig:
|
| 41 |
HF_TOKEN: str = os.getenv("HF_TOKEN", "")
|
| 42 |
LLM_MODEL: str = os.getenv("LLM_MODEL", "Qwen/Qwen2.5-Coder-32B-Instruct")
|
| 43 |
FLUX_MODEL: str = os.getenv("FLUX_MODEL", "black-forest-labs/FLUX.1-schnell")
|
| 44 |
+
MAX_TOKENS: int = 8192
|
| 45 |
+
TEMPERATURE: float = 0.75
|
| 46 |
+
MAX_HISTORY: int = 15
|
| 47 |
+
CACHE_SIZE: int = 200
|
| 48 |
+
REQUESTS_PER_MINUTE: int = 60
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
CONFIG = AppConfig()
|
| 51 |
+
|
| 52 |
+
logger.info(f"Configuration Loaded β LLM: {CONFIG.LLM_MODEL}")
|
| 53 |
+
|
| 54 |
+
# ====================== SYSTEM PROMPT ======================
|
| 55 |
+
SYSTEM_PROMPT = """You are **Sovereign UI Architect** β supreme master of UIkit v3.21+ and YOOtheme Pro Builder.
|
| 56 |
+
- For UIkit requests: Output complete, production-ready standalone HTML using UIkit classes, icons, and best practices.
|
| 57 |
+
- For YOOtheme requests (contains "yootheme", "yoo json", "builder json"): Output clean, professional, high-end YOOtheme JSON layout.
|
| 58 |
+
Deliver senior-level human developer quality: refined typography, subtle animations, perfect hierarchy, accessibility (ARIA), responsive design, and dark mode support."""
|
| 59 |
+
|
| 60 |
+
# ====================== UTILS ======================
|
| 61 |
+
class Utils:
|
|
|
|
| 62 |
@staticmethod
|
| 63 |
+
def is_yootheme_request(text: str) -> bool:
|
| 64 |
+
if not text:
|
| 65 |
+
return False
|
| 66 |
+
keywords = ["yootheme", "yoo json", "builder json", "yoo layout"]
|
| 67 |
+
return any(k in text.lower() for k in keywords)
|
| 68 |
|
| 69 |
+
@staticmethod
|
| 70 |
+
def wrap_uikit_html(html: str) -> str:
|
| 71 |
+
return f"""
|
| 72 |
+
<!DOCTYPE html>
|
| 73 |
+
<html lang="en">
|
| 74 |
+
<head>
|
| 75 |
+
<meta charset="UTF-8">
|
| 76 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 77 |
+
<title>Live Preview</title>
|
| 78 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uikit@3/dist/css/uikit.min.css">
|
| 79 |
+
<script src="https://cdn.jsdelivr.net/npm/uikit@3/dist/js/uikit.min.js"></script>
|
| 80 |
+
<script src="https://cdn.jsdelivr.net/npm/uikit@3/dist/js/uikit-icons.min.js"></script>
|
| 81 |
+
<style>
|
| 82 |
+
body {{ padding: 20px; background: #0f172a; color: #e2e8f0; min-height: 100vh; }}
|
| 83 |
+
</style>
|
| 84 |
+
</head>
|
| 85 |
+
<body>{html}</body>
|
| 86 |
+
</html>"""
|
| 87 |
+
|
| 88 |
+
# ====================== RATE LIMITER & CACHE ======================
|
| 89 |
class AsyncRateLimiter:
|
| 90 |
def __init__(self, rpm: int):
|
| 91 |
self.rate = rpm
|
|
|
|
| 105 |
|
| 106 |
class AsyncLRUCache:
|
| 107 |
def __init__(self, capacity: int):
|
| 108 |
+
self.cache: OrderedDict[str, Tuple[str, str]] = OrderedDict()
|
| 109 |
self.capacity = capacity
|
| 110 |
self.lock = asyncio.Lock()
|
| 111 |
|
| 112 |
+
async def get(self, key: str) -> Optional[Tuple[str, str]]:
|
| 113 |
async with self.lock:
|
| 114 |
if key not in self.cache:
|
| 115 |
return None
|
| 116 |
self.cache.move_to_end(key)
|
| 117 |
return self.cache[key]
|
| 118 |
|
| 119 |
+
async def set(self, key: str, value: Tuple[str, str]):
|
| 120 |
async with self.lock:
|
| 121 |
self.cache[key] = value
|
| 122 |
self.cache.move_to_end(key)
|
| 123 |
if len(self.cache) > self.capacity:
|
| 124 |
self.cache.popitem(last=False)
|
| 125 |
|
| 126 |
+
# ====================== SOVEREIGN AGENT ======================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
class SovereignAgent:
|
| 128 |
def __init__(self):
|
| 129 |
self.client = AsyncInferenceClient(token=CONFIG.HF_TOKEN)
|
| 130 |
self.limiter = AsyncRateLimiter(CONFIG.REQUESTS_PER_MINUTE)
|
| 131 |
self.cache = AsyncLRUCache(CONFIG.CACHE_SIZE)
|
| 132 |
+
logger.info("Sovereign UI Architect Agent Online")
|
|
|
|
|
|
|
| 133 |
|
| 134 |
+
def _make_key(self, history: List, message: str) -> str:
|
| 135 |
+
return str(uuid.uuid5(uuid.NAMESPACE_DNS, json.dumps(history[-10:], sort_keys=True) + message))
|
| 136 |
|
| 137 |
+
async def generate(self, message: str, history: List) -> Tuple[str, str]:
|
| 138 |
if not await self.limiter.acquire():
|
| 139 |
+
return "**Rate limited. Please wait a few seconds.**", "<h2>Rate limited...</h2>"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
+
key = self._make_key(history, message)
|
| 142 |
if cached := await self.cache.get(key):
|
| 143 |
+
return cached[0], cached[1]
|
| 144 |
+
|
| 145 |
+
messages = [{"role": "system", "content": SYSTEM_PROMPT}] + history[-CONFIG.MAX_HISTORY:] + [{"role": "user", "content": message}]
|
| 146 |
|
| 147 |
full = ""
|
| 148 |
try:
|
|
|
|
| 154 |
stream=True
|
| 155 |
)
|
| 156 |
async for chunk in stream:
|
| 157 |
+
if chunk.choices and (delta := chunk.choices[0].delta.content):
|
| 158 |
+
full += delta
|
| 159 |
+
|
| 160 |
+
if Utils.is_yootheme_request(message):
|
| 161 |
+
display_text = f"**Professional YOOtheme JSON Generated**\n\n```json\n{full}\n```"
|
| 162 |
+
preview_html = "<h2>YOOtheme JSON Ready β Import directly into YOOtheme Builder</h2>"
|
| 163 |
+
else:
|
| 164 |
+
display_text = full
|
| 165 |
+
preview_html = full
|
| 166 |
+
|
| 167 |
+
await self.cache.set(key, (display_text, preview_html))
|
| 168 |
+
return display_text, preview_html
|
| 169 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
except Exception as e:
|
| 171 |
+
err = f"Matrix Error: {str(e)}"
|
| 172 |
+
return err, f"<h2>{err}</h2>"
|
| 173 |
|
| 174 |
+
# ====================== GRADIO INTERFACE ======================
|
| 175 |
+
def create_app():
|
| 176 |
agent = SovereignAgent()
|
| 177 |
|
| 178 |
with gr.Blocks(
|
| 179 |
+
theme=gr.themes.Soft(),
|
| 180 |
css="""
|
| 181 |
+
.preview-frame { border: 1px solid #475569; border-radius: 16px; background: #0f172a; overflow: auto; height: 680px; }
|
| 182 |
+
.sovereign-header { font-size: 2.9rem; font-weight: 900; background: linear-gradient(90deg, #c026d3, #06b6d4); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
| 183 |
""",
|
| 184 |
+
title="Sovereign UI Architect"
|
| 185 |
) as demo:
|
| 186 |
gr.HTML("""
|
| 187 |
+
<div style="text-align:center; padding: 2.5rem 0 1.5rem;">
|
| 188 |
+
<h1 class="sovereign-header">Sovereign UI Architect</h1>
|
| 189 |
+
<p style="color:#94a3b8;">UIkit v3.21+ & YOOtheme Pro β’ Live Preview β’ Senior Dev Quality</p>
|
| 190 |
</div>
|
| 191 |
""")
|
| 192 |
|
| 193 |
+
with gr.Row(equal_height=True):
|
| 194 |
+
with gr.Column(scale=5):
|
| 195 |
+
chatbot = gr.Chatbot(type="messages", height=680, label="Sovereign Conversation")
|
| 196 |
+
msg = gr.Textbox(
|
| 197 |
+
placeholder="Describe the interface you want or say 'yootheme luxury real estate homepage...'",
|
| 198 |
+
label="Your Prompt",
|
| 199 |
+
lines=3
|
| 200 |
+
)
|
| 201 |
+
btn = gr.Button("Generate Masterpiece", variant="primary", size="large")
|
| 202 |
+
|
| 203 |
+
with gr.Column(scale=5):
|
| 204 |
+
gr.Markdown("### Live Interactive Preview")
|
| 205 |
+
preview = gr.HTML(
|
| 206 |
+
value="<div style='padding:100px; text-align:center; color:#64748b;'>Generated UI will render here</div>",
|
| 207 |
+
elem_classes=["preview-frame"]
|
| 208 |
+
)
|
| 209 |
+
|
| 210 |
+
gr.Examples(
|
| 211 |
examples=[
|
| 212 |
+
"Modern SaaS dashboard with sidebar navigation and analytics cards",
|
| 213 |
+
"yootheme luxury real estate homepage with hero section and portfolio",
|
| 214 |
+
"Futuristic admin panel with charts and user management",
|
| 215 |
+
"Responsive pricing table with monthly / yearly toggle"
|
| 216 |
],
|
| 217 |
+
inputs=msg
|
|
|
|
| 218 |
)
|
| 219 |
|
| 220 |
+
def respond(message: str, history: List):
|
| 221 |
+
if not message or not message.strip():
|
| 222 |
+
return history, history, preview.value
|
| 223 |
+
history = history or []
|
| 224 |
+
resp_text, preview_html = asyncio.run(agent.generate(message, history))
|
| 225 |
+
history.append({"role": "user", "content": message})
|
| 226 |
+
history.append({"role": "assistant", "content": resp_text})
|
| 227 |
+
wrapped_preview = Utils.wrap_uikit_html(preview_html) if not Utils.is_yootheme_request(message) else preview_html
|
| 228 |
+
return history, history, wrapped_preview
|
| 229 |
+
|
| 230 |
+
btn.click(respond, inputs=[msg, chatbot], outputs=[chatbot, chatbot, preview])
|
| 231 |
+
|
| 232 |
return demo
|
| 233 |
|
|
|
|
| 234 |
if __name__ == "__main__":
|
| 235 |
+
logger.info("π Launching FULL Sovereign UI Architect (262 lines)")
|
| 236 |
+
demo = create_app()
|
| 237 |
demo.queue(max_size=40).launch(
|
| 238 |
server_name="0.0.0.0",
|
| 239 |
server_port=7860,
|
| 240 |
+
show_error=True
|
|
|
|
| 241 |
)
|