Spaces:
Sleeping
Sleeping
Update app.py
Browse files123456789101112131415161718192021222319 unmodified lines434445464748495051525354555657585960616263646566676869707172737475764 unmodified lines8182838485868788175 unmodified lines2642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573581 unmodified line3603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694705 unmodified lines4764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505511 unmodified line5535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925934 unmodified lines5985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436443 unmodified lines64864965065165265365424 unmodified lines679680681682683684685109 unmodified lines7957967977987998008013 unmodified lines805806807808You are incredibly patient, and I truly apologize for this persistent syntax error\! My mistake.The error `SyntaxError: invalid syntax` pointing to `usr_in.` on line 769 (or near there) means there's an incomplete line of code, likely a leftover from an incomplete thought or a copy-paste error during the last refactor.It seems I left a dangling `usr_in.` line without anything after it in the `clear_chat` function's return statement.Let's fix that immediately. The `clear_chat` function's return statement should correctly reset the `usr_in` component and the `ex_drop` (examples dropdown).**Here's the corrected `clear_chat` function:**```pythondef clear_chat():# Corrected: Removed the dangling 'usr_in.' and ensured all returns are correct# The order of returned values must match the outputs of the .click() methodsreturn [], "", "Ready to assist!", gr.File(value=None), None # Clear chat, user input, status, file upload, and examples dropdown```**And here's how it fits into the complete `app.py` file. Please replace the entire `app.py` content with this corrected version.**# app.pyimport os19 unmodified linesclient = OpenAI(api_key=os.getenv("OPENAI_API_KEY", "").strip())# Define model details including pricing and max context# Refer to OpenAI's official pricing and model docs for the most current information:# https://platform.openai.com/docs/models/overview# https://openai.com/api/pricing/# Prices are typically per 1 million tokens (USD)MODEL_DETAILS = {# GPT-4o family (latest and generally recommended for most tasks)"gpt-4o": {"input_price": 5.00, "output_price": 15.00, "max_context": 128_000, "description": "OpenAI's most capable and cost-effective multimodal model."},"gpt-4o-mini": {"input_price": 0.15, "output_price": 0.60, "max_context": 128_000, "description": "Highly affordable and fast, suitable for simpler tasks."},# Newer, more advanced reasoning models (if available in your region/access level)# Note: 'o3' and 'o4-mini' are speculative based on recent announcements/patterns.# Replace these with actual model names from your OpenAI access if different."o3": {"input_price": 2.00, "output_price": 8.00, "max_context": 200_000, "description": "Designed for complex reasoning and step-by-step problem-solving."},"o3-pro": {"input_price": 20.00, "output_price": 80.00, "max_context": 200_000, "description": "Premium reasoning model for high-stakes tasks, higher accuracy."},"o4-mini": {"input_price": 1.10, "output_price": 4.40, "max_context": 200_000, "description": "Balanced multimodal model, good for image+text on a budget."},# Older GPT-4 models (still available but consider migrating to -4o)"gpt-4-32k": {"input_price": 0.06, "output_price": 0.12, "max_context": 32_768, "description": "Larger context GPT-4 model (older generation)."},"gpt-4": {"input_price": 0.03, "output_price": 0.06, "max_context": 8_192, "description": "Original GPT-4 model (older generation)."},"gpt-3.5-turbo": {"input_price": 0.001, "output_price": 0.002, "max_context": 16_385, "description": "Cost-effective, fast, and good for general-purpose tasks."},}# Ensure models from environment variable are prioritized if set, otherwise use a default sensible list_env_models = os.getenv("OPENAI_MODEL_LIST", "gpt-4o,gpt-4o-mini,gpt-3.5-turbo")ALL_MODELS: List[str] = [m.strip() for m in _env_models.split(",") if m.strip() and m.strip() in MODEL_DETAILS]# Add any models from MODEL_DETAILS that weren't in the env variable, ensuring no duplicatesfor model in MODEL_DETAILS:if model not in ALL_MODELS:ALL_MODELS.append(model)4 unmodified linesraise ValueError("No valid OpenAI models configured. Please check MODEL_DETAILS or OPENAI_MODEL_LIST.")DEFAULT_MAX_CONTEXT = MODEL_DETAILS.get(ALL_MODELS[0], {}).get("max_context", 128_000)BUFFER_TOKENS = 500 # reserve for model replyDEFAULT_REPLY_MAX = 2_048 # tokensTEMPERATURE = 0.3# ────────────────────────────────175 unmodified linesyield hist, "", f"Error with model: **{sel_model}** - {e}", gr.File(value=None)def clear_chat():# This line was the culprit! It had a dangling 'usr_in.'# Corrected return values to match outputs of .click() method:return [], "", "Ready to assist!", gr.File(value=None), None, gr.Dropdown(value=None)# ────────────────────���───────────# 5 · UI# ────────────────────────────────# --- CUSTOM SYNTHWAVE CSS (EMBEDDED DIRECTLY) ---# This ensures the CSS is applied reliably by Gradio.# Font import must be at the very top of the style block.SYNTHWAVE_CSS = """@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');/* --- Global Synthwave Background (Applied to root HTML/body) --- */html.dark.gradio-container, /* Target the actual HTML element Gradio controls */body.gradio-container {background: linear-gradient(180deg, #1A0033 0%, #000000 100%) !important; /* Deep violet to black */background-attachment: fixed !important;font-family: 'Press Start 2P', cursive !important; /* Retro pixel font */color: #00FFC0 !important; /* Bright Teal/Cyan */text-shadow: 0 0 5px #00FFC0 !important; /* Subtle teal glow */}/* --- Gradio Component Overrides for Synthwave Vibe --- *//* Main App background and base colors for Gradio's internal variables */gradio-app {--background-fill-primary: #150020 !important; /* Darker violet for inner blocks */--background-fill-secondary: #000000 !important; /* Pure black for deepest elements */--border-color-accent: #00FFC0 !important; /* Bright Teal/Cyan accent for borders */--border-color-primary: #6A0DAD !important; /* Deeper violet border */--color-accent: #00FFC0 !important; /* Primary accent color (Teal) */--color-text-primary: #00FFC0 !important; /* Teal text */--color-text-secondary: #00A0B0 !important; /* Muted teal for secondary text */--color-text-subdued: #007080 !important; /* Darker teal for subdued text */--button-primary-background-color: #00FFC0 !important; /* Neon Teal primary button */--button-primary-border-color: #00FFC0 !important;--button-primary-text-color: #150020 !important; /* Dark text on bright button */--button-secondary-background-color: #6A0DAD !important; /* Deep Violet secondary button */--button-secondary-border-color: #FF00FF !important; /* Neon Magenta border */--button-secondary-text-color: #FF00FF !important; /* Neon Magenta text */--shadow-color: rgba(0, 255, 192, 0.5) !important; /* Teal glow shadow */--block-background-fill: #150020 !important; /* Dark violet blocks */--block-border-color: #6A0DAD !important; /* Block borders */--block-label-background-color: #200030 !important; /* Even darker label backgrounds */--block-title-text-color: #FF00FF !important; /* Neon Magenta for titles */--block-label-text-color: #FF00FF !important; /* Neon Magenta for labels */--block-shadow: 0 0 10px rgba(0, 255, 192, 0.3) !important; /* Soft teal glow for blocks */--form-gap: 20px !important; /* Increase gap between form elements */--link-text-color: #A020F0 !important; /* Violet link color */}/* Specific component overrides *//* Headers */h1 {color: #00FFC0 !important; /* Bright Teal */text-shadow: 0 0 10px #00FFC0, 0 0 20px #00FFC0, 0 0 30px #00FFC0 !important; /* Stronger glow */font-size: 3.5em !important; /* Larger for impact */letter-spacing: 7px !important; /* More spread out */margin-bottom: 10px !important;white-space: nowrap; /* Prevent wrapping if text shadow causes issues */}h2, h3, h4, h5, h6 {color: #FF00FF !important; /* Neon Magenta */text-shadow: 0 0 5px #FF00FF !important;letter-spacing: 2px !important;}/* Markdown text */gradio-app p, gradio-app .prose {color: #00A0B0 !important; /* Muted teal */text-shadow: none !important; /* Remove text shadow from regular paragraphs */font-size: 0.95em !important;}/* Textboxes and Inputs */gradio-app input[type="text"],gradio-app textarea,gradio-app select,.gr-dropdown { /* Apply to dropdowns as well */background-color: #1A0033 !important; /* Deep violet for inputs */border: 1px solid #FF00FF !important; /* Neon Magenta border */color: #00FFC0 !important; /* Bright Teal text */box-shadow: 0 0 8px rgba(255, 0, 255, 0.5) !important; /* Magenta glow for inputs */padding: 10px !important;font-family: 'Press Start 2P', cursive !important;transition: all 0.3s ease-in-out !important;1 unmodified linegradio-app input[type="text"]:focus,gradio-app textarea:focus,gradio-app select:focus,.gr-dropdown:focus-within { /* For dropdowns, use focus-within */border-color: #00FFC0 !important; /* Bright Teal on focus */box-shadow: 0 0 15px rgba(0, 255, 192, 0.7) !important; /* Stronger teal glow on focus */outline: none !important;}/* Chatbot bubbles */#component-chat .message.user {background-color: #6A0DAD !important; /* Deep Violet for user bubbles */color: #00FFC0 !important; /* Bright Teal text */border-radius: 10px 10px 0 10px !important;box-shadow: 0 0 8px rgba(255, 0, 255, 0.3) !important; /* Magenta glow */text-shadow: none !important;}#component-chat .message.bot {background-color: #1A0033 !important; /* Even deeper violet for bot bubbles */color: #FF00FF !important; /* Neon Magenta text */border-radius: 10px 10px 10px 0 !important;box-shadow: 0 0 8px rgba(0, 255, 192, 0.3) !important; /* Teal glow */text-shadow: none !important;}#component-chat .message-wrap.user .message-box {align-self: flex-end !important; /* Align user messages to the right */}#component-chat .message-wrap.bot .message-box {align-self: flex-start !important; /* Align bot messages to the left */}/* Buttons */.gr-button-primary {background-color: #00FFC0 !important; /* Bright Teal */color: #1A0033 !important; /* Dark violet text */text-shadow: none !important;box-shadow: 0 0 10px rgba(0, 255, 192, 0.5) !important; /* Teal glow */transition: all 0.3s ease-in-out !important;}.gr-button-primary:hover {background-color: #00E0A0 !important; /* Darker teal on hover */box-shadow: 0 0 15px rgba(0, 255, 192, 0.7) !important;}.gr-button-secondary {background-color: #6A0DAD !important; /* Deep Violet */color: #FF00FF !important; /* Neon Magenta text */text-shadow: none !important;border: 1px solid #FF00FF !important;box-shadow: 0 0 8px rgba(255, 0, 255, 0.5) !important; /* Magenta glow */transition: all 0.3s ease-in-out !important;}.gr-button-secondary:hover {background-color: #7A1DEB !important; /* Lighter violet on hover */box-shadow: 0 0 12px rgba(255, 0, 255, 0.7) !important;}/* Sliders */.gr-slider-fill {background-color: #FF00FF !important; /* Neon Magenta fill */}.gr-slider-track {background-color: #300040 !important; /* Darker track */}.gr-slider-thumb {background-color: #00FFC0 !important; /* Bright Teal thumb */border: 1px solid #00FFC0 !important;box-shadow: 0 0 8px rgba(0, 255, 192, 0.7) !important;}/* Tabs */.tabs-nav button {background-color: #1A0033 !important; /* Dark tab background */color: #FF00FF !important; /* Neon Magenta tab text */border-bottom: 2px solid #FF00FF !important;text-shadow: none !important;transition: all 0.2s ease-in-out !important;font-size: 1.1em !important; /* Slightly larger for tabs */letter-spacing: 1px !important;}.tabs-nav button.selected {background-color: #000000 !important; /* Pure black selected tab background */color: #00FFC0 !important; /* Bright Teal selected tab text */border-bottom: 2px solid #00FFC0 !important;text-shadow: 0 0 5px #00FFC0 !important; /* Teal glow for selected tab */}.tabs-nav button:hover {color: #00FFC0 !important; /* Teal on hover */text-shadow: 0 0 3px #00FFC0 !important;}/* Dropdown items (the options when clicked) */.gr-dropdown-item {background-color: #1A0033 !important;color: #00FFC0 !important;font-family: 'Press Start 2P', cursive !important;font-size: 1.0em !important; /* Adjusted for readability */}.gr-dropdown-item.selected {background-color: #6A0DAD !important; /* Deep violet for selected item */color: #FF00FF !important; /* Neon Magenta text */}.gr-dropdown-item:hover {background-color: #400060 !important; /* Slightly lighter violet on hover */}/* File Upload */.gr-upload-text {color: #00FFC0 !important;text-shadow: 0 0 3px #00FFC0 !important;5 unmodified linestext-shadow: none !important;box-shadow: 0 0 8px rgba(255, 0, 255, 0.3) !important;}.gr-file-input .primary-bg { /* Gradio's internal class for the upload icon background */background-color: #00FFC0 !important; /* Teal */color: #1A0033 !important;}/* Status Display */#status_display {color: #00FFC0 !important; /* Bright Teal */text-shadow: 0 0 5px #00FFC0 !important; /* Subtle glow */font-weight: bold !important;font-size: 1.1em !important;padding: 10px !important;background-color: #0A0015 !important; /* Very dark background */border: 1px solid #6A0DAD !important; /* Violet border */border-radius: 5px !important;margin-bottom: 15px !important;}/* General Link Styling (e.g., in chat output) */a {color: #FF00FF !important; /* Neon Magenta */text-decoration: underline !important;text-shadow: none !important;}a:hover {color: #00FFC0 !important; /* Bright Teal on hover */}/* Specific glow for markdown headers inside content (e.g., in chat output) */.gradio-app .prose h1, .gradio-app .prose h2, .gradio-app .prose h3,.gradio-app .prose h4, .gradio-app .prose h5, .gradio-app .prose h6 {color: #FF00FF !important; /* Magenta for consistency */text-shadow: 0 0 5px #FF00FF !important; /* Subtler magenta glow for markdown in chat */font-family: 'Press Start 2P', cursive !important;letter-spacing: 1px !important;}/* Custom scrollbar for synthwave */::-webkit-scrollbar {width: 12px !important; /* Slightly wider */background-color: #150020 !important; /* Dark background for scrollbar */}::-webkit-scrollbar-thumb {background-color: #FF00FF !important; /* Neon Magenta scrollbar thumb */border-radius: 6px !important;border: 3px solid #6A0DAD !important; /* Violet border */}::-webkit-scrollbar-thumb:hover {background-color: #00FFC0 !important; /* Bright Teal on hover */}/* Adjust font size for the pixel font to be readable */* {font-size: 18px !important; /* Increased base font size for readability */line-height: 1.6 !important; /* Improve line spacing for pixel font */}.gr-label {font-size: 1.2em !important; /* Labels should be legible and a bit larger */}.gr-text-input {font-size: 1.1em !important;}.message-body {font-size: 1.1em !important; /* Ensure chat text is readable */}/* Ensure font is applied to all Gradio text elements */.gradio-container, .gradio-container * {font-family: 'Press Start 2P', cursive !important;}1 unmodified linefont-family: 'Press Start 2P', cursive !important;}/* Adjust button padding for pixel font */.gr-button {padding: 12px 18px !important; /* Slightly larger buttons */}/* Hide Gradio's default theme toggle which might conflict with our forced dark mode */.dark-mode-toggle {display: none !important;}/* Ensure text in prompts and info is readable */.gr-prose p {font-size: 1em !important; /* Ensure these are also scaled */}"""# --- JAVASCRIPT FOR DARK MODE & SCROLL ---JAVASCRIPT_CODE = """// Function to force dark mode on Gradiofunction forceDarkMode() {const htmlElement = document.documentElement;// Ensure the 'dark' class is presentif (!htmlElement.classList.contains('dark')) {htmlElement.classList.add('dark');}}// Call forceDarkMode when the document is readydocument.addEventListener('DOMContentLoaded', forceDarkMode);// Also set up a MutationObserver to re-apply if Gradio removes it (unlikely but safe)const observer = new MutationObserver(forceDarkMode);observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });// Auto-scroll chat to bottom logicdocument.addEventListener('DOMContentLoaded', () => {const chat = document.querySelector('gradio-app').shadowRoot.querySelector('#component-chat .scroll-hide');if (chat) {4 unmodified lines});"""# --- Custom Gradio Theme for JadeGPT Synthwave (Minimal, as CSS handles most) ---# We still define a base theme in Python, but the visual overrides are in the embedded CSS.jade_synthwave_theme = gr.themes.Base(primary_hue=gr.themes.Color("hsl(180, 100%, 50%)", # Main Cyan"hsl(180, 100%, 40%)","hsl(180, 100%, 60%)","hsl(180, 100%, 70%)","hsl(180, 100%, 80%)","hsl(180, 100%, 90%)","hsl(180, 100%, 95%)","hsl(180, 100%, 97%)","hsl(180, 100%, 98%)","hsl(180, 100%, 99%)","hsl(180, 100%, 100%)"),secondary_hue=gr.themes.Color("hsl(280, 100%, 50%)", # Main Magenta"hsl(280, 100%, 40%)","hsl(280, 100%, 60%)","hsl(280, 100%, 70%)","hsl(280, 100%, 80%)","hsl(280, 100%, 90%)","hsl(280, 100%, 95%)","hsl(280, 100%, 97%)","hsl(280, 100%, 98%)","hsl(280, 100%, 99%)","hsl(280, 100%, 100%)"),neutral_hue=gr.themes.Color("hsl(240, 20%, 10%)", # Deep background"hsl(240, 20%, 15%)","hsl(240, 20%, 20%)","hsl(240, 20%, 25%)","hsl(240, 20%, 30%)","hsl(240, 20%, 35%)","hsl(240, 20%, 40%)","hsl(240, 20%, 45%)","hsl(240, 20%, 50%)","hsl(240, 20%, 55%)","hsl(240, 20%, 60%)"))3 unmodified linestheme=jade_synthwave_theme,analytics_enabled=False,) as demo:# Use gr.HTML to inject all CSS and JS directlygr.HTML(f"""<style>{SYNTHWAVE_CSS}24 unmodified linesheight=500,show_copy_button=True,layout="bubble",avatar_images=(None, "https://www.gradio.app/assets/img/logo.png") # Using a default Gradio logo for illustration, replace with a custom synthwave avatar if you have one!)with gr.Row():109 unmodified linesoutputs=[chat, usr_in, status_display, file_upload])# Corrected outputs for clear_btn.click() to ensure the dropdown is also clearedclear_btn.click(clear_chat, outputs=[chat, usr_in, status_display, file_upload, ex_drop])ex_btn.click(lambda q: q or "", inputs=ex_drop, outputs=usr_in)3 unmodified linesdemo.queue(max_size=32, default_concurrency_limit=int(os.getenv("JADEGPT_CONCURRENCY", "2")))if __name__ == "__main__":demo.launch()12319 unmodified lines23242526272829303132333435363738394041424 unmodified lines4748495051525354175 unmodified lines2302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103111 unmodified line3133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154165 unmodified lines4224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894901 unmodified line4924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225234 unmodified lines5285295305315325335345355365375385395405415425435445455465475485495505513 unmodified lines55555655755855956024 unmodified lines585586587588589590591109 unmodified lines7017027037047057063 unmodified lines710711712713# app.pyimport os19 unmodified linesclient = OpenAI(api_key=os.getenv("OPENAI_API_KEY", "").strip())MODEL_DETAILS = {"gpt-4o": {"input_price": 5.00, "output_price": 15.00, "max_context": 128_000, "description": "OpenAI's most capable and cost-effective multimodal model."},"gpt-4o-mini": {"input_price": 0.15, "output_price": 0.60, "max_context": 128_000, "description": "Highly affordable and fast, suitable for simpler tasks."},"o3": {"input_price": 2.00, "output_price": 8.00, "max_context": 200_000, "description": "Designed for complex reasoning and step-by-step problem-solving."},"o3-pro": {"input_price": 20.00, "output_price": 80.00, "max_context": 200_000, "description": "Premium reasoning model for high-stakes tasks, higher accuracy."},"o4-mini": {"input_price": 1.10, "output_price": 4.40, "max_context": 200_000, "description": "Balanced multimodal model, good for image+text on a budget."},"gpt-4-32k": {"input_price": 0.06, "output_price": 0.12, "max_context": 32_768, "description": "Larger context GPT-4 model (older generation)."},"gpt-4": {"input_price": 0.03, "output_price": 0.06, "max_context": 8_192, "description": "Original GPT-4 model (older generation)."},"gpt-3.5-turbo": {"input_price": 0.001, "output_price": 0.002, "max_context": 16_385, "description": "Cost-effective, fast, and good for general-purpose tasks."},}_env_models = os.getenv("OPENAI_MODEL_LIST", "gpt-4o,gpt-4o-mini,gpt-3.5-turbo")ALL_MODELS: List[str] = [m.strip() for m in _env_models.split(",") if m.strip() and m.strip() in MODEL_DETAILS]for model in MODEL_DETAILS:if model not in ALL_MODELS:ALL_MODELS.append(model)4 unmodified linesraise ValueError("No valid OpenAI models configured. Please check MODEL_DETAILS or OPENAI_MODEL_LIST.")DEFAULT_MAX_CONTEXT = MODEL_DETAILS.get(ALL_MODELS[0], {}).get("max_context", 128_000)BUFFER_TOKENS = 500DEFAULT_REPLY_MAX = 2_048TEMPERATURE = 0.3# ────────────────────────────────175 unmodified linesyield hist, "", f"Error with model: **{sel_model}** - {e}", gr.File(value=None)def clear_chat():# Corrected return values for gr.File and gr.Dropdown to clear them explicitly.# The order of returned values must match the outputs of the .click() methods.return [], "", "Ready to assist!", None, None # chat, user_in, status_display, file_upload, ex_drop# ────────────────────���───────────# 5 · UI# ────────────────────────────────# --- CUSTOM SYNTHWAVE CSS (EMBEDDED DIRECTLY) ---SYNTHWAVE_CSS = """@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');html.dark.gradio-container,body.gradio-container {background: linear-gradient(180deg, #1A0033 0%, #000000 100%) !important;background-attachment: fixed !important;font-family: 'Press Start 2P', cursive !important;color: #00FFC0 !important;text-shadow: 0 0 5px #00FFC0 !important;}gradio-app {--background-fill-primary: #150020 !important;--background-fill-secondary: #000000 !important;--border-color-accent: #00FFC0 !important;--border-color-primary: #6A0DAD !important;--color-accent: #00FFC0 !important;--color-text-primary: #00FFC0 !important;--color-text-secondary: #00A0B0 !important;--color-text-subdued: #007080 !important;--button-primary-background-color: #00FFC0 !important;--button-primary-border-color: #00FFC0 !important;--button-primary-text-color: #150020 !important;--button-secondary-background-color: #6A0DAD !important;--button-secondary-border-color: #FF00FF !important;--button-secondary-text-color: #FF00FF !important;--shadow-color: rgba(0, 255, 192, 0.5) !important;--block-background-fill: #150020 !important;--block-border-color: #6A0DAD !important;--block-label-background-color: #200030 !important;--block-title-text-color: #FF00FF !important;--block-label-text-color: #FF00FF !important;--block-shadow: 0 0 10px rgba(0, 255, 192, 0.3) !important;--form-gap: 20px !important;--link-text-color: #A020F0 !important;}h1 {color: #00FFC0 !important;text-shadow: 0 0 10px #00FFC0, 0 0 20px #00FFC0, 0 0 30px #00FFC0 !important;font-size: 3.5em !important;letter-spacing: 7px !important;margin-bottom: 10px !important;white-space: nowrap;}h2, h3, h4, h5, h6 {color: #FF00FF !important;text-shadow: 0 0 5px #FF00FF !important;letter-spacing: 2px !important;}gradio-app p, gradio-app .prose {color: #00A0B0 !important;text-shadow: none !important;font-size: 0.95em !important;}gradio-app input[type="text"],gradio-app textarea,gradio-app select,.gr-dropdown {background-color: #1A0033 !important;border: 1px solid #FF00FF !important;color: #00FFC0 !important;box-shadow: 0 0 8px rgba(255, 0, 255, 0.5) !important;padding: 10px !important;font-family: 'Press Start 2P', cursive !important;transition: all 0.3s ease-in-out !important;1 unmodified linegradio-app input[type="text"]:focus,gradio-app textarea:focus,gradio-app select:focus,.gr-dropdown:focus-within {border-color: #00FFC0 !important;box-shadow: 0 0 15px rgba(0, 255, 192, 0.7) !important;outline: none !important;}#component-chat .message.user {background-color: #6A0DAD !important;color: #00FFC0 !important;border-radius: 10px 10px 0 10px !important;box-shadow: 0 0 8px rgba(255, 0, 255, 0.3) !important;text-shadow: none !important;}#component-chat .message.bot {background-color: #1A0033 !important;color: #FF00FF !important;border-radius: 10px 10px 10px 0 !important;box-shadow: 0 0 8px rgba(0, 255, 192, 0.3) !important;text-shadow: none !important;}#component-chat .message-wrap.user .message-box {align-self: flex-end !important;}#component-chat .message-wrap.bot .message-box {align-self: flex-start !important;}.gr-button-primary {background-color: #00FFC0 !important;color: #1A0033 !important;text-shadow: none !important;box-shadow: 0 0 10px rgba(0, 255, 192, 0.5) !important;transition: all 0.3s ease-in-out !important;}.gr-button-primary:hover {background-color: #00E0A0 !important;box-shadow: 0 0 15px rgba(0, 255, 192, 0.7) !important;}.gr-button-secondary {background-color: #6A0DAD !important;color: #FF00FF !important;text-shadow: none !important;border: 1px solid #FF00FF !important;box-shadow: 0 0 8px rgba(255, 0, 255, 0.5) !important;transition: all 0.3s ease-in-out !important;}.gr-button-secondary:hover {background-color: #7A1DEB !important;box-shadow: 0 0 12px rgba(255, 0, 255, 0.7) !important;}.gr-slider-fill {background-color: #FF00FF !important;}.gr-slider-track {background-color: #300040 !important;}.gr-slider-thumb {background-color: #00FFC0 !important;border: 1px solid #00FFC0 !important;box-shadow: 0 0 8px rgba(0, 255, 192, 0.7) !important;}.tabs-nav button {background-color: #1A0033 !important;color: #FF00FF !important;border-bottom: 2px solid #FF00FF !important;text-shadow: none !important;transition: all 0.2s ease-in-out !important;font-size: 1.1em !important;letter-spacing: 1px !important;}.tabs-nav button.selected {background-color: #000000 !important;color: #00FFC0 !important;border-bottom: 2px solid #00FFC0 !important;text-shadow: 0 0 5px #00FFC0 !important;}.tabs-nav button:hover {color: #00FFC0 !important;text-shadow: 0 0 3px #00FFC0 !important;}.gr-dropdown-item {background-color: #1A0033 !important;color: #00FFC0 !important;font-family: 'Press Start 2P', cursive !important;font-size: 1.0em !important;}.gr-dropdown-item.selected {background-color: #6A0DAD !important;color: #FF00FF !important;}.gr-dropdown-item:hover {background-color: #400060 !important;}.gr-upload-text {color: #00FFC0 !important;text-shadow: 0 0 3px #00FFC0 !important;5 unmodified linestext-shadow: none !important;box-shadow: 0 0 8px rgba(255, 0, 255, 0.3) !important;}.gr-file-input .primary-bg {background-color: #00FFC0 !important;color: #1A0033 !important;}#status_display {color: #00FFC0 !important;text-shadow: 0 0 5px #00FFC0 !important;font-weight: bold !important;font-size: 1.1em !important;padding: 10px !important;background-color: #0A0015 !important;border: 1px solid #6A0DAD !important;border-radius: 5px !important;margin-bottom: 15px !important;}a {color: #FF00FF !important;text-decoration: underline !important;text-shadow: none !important;}a:hover {color: #00FFC0 !important;}.gradio-app .prose h1, .gradio-app .prose h2, .gradio-app .prose h3,.gradio-app .prose h4, .gradio-app .prose h5, .gradio-app .prose h6 {color: #FF00FF !important;text-shadow: 0 0 5px #FF00FF !important;font-family: 'Press Start 2P', cursive !important;letter-spacing: 1px !important;}::-webkit-scrollbar {width: 12px !important;background-color: #150020 !important;}::-webkit-scrollbar-thumb {background-color: #FF00FF !important;border-radius: 6px !important;border: 3px solid #6A0DAD !important;}::-webkit-scrollbar-thumb:hover {background-color: #00FFC0 !important;}* {font-size: 18px !important;line-height: 1.6 !important;}.gr-label {font-size: 1.2em !important;}.gr-text-input {font-size: 1.1em !important;}.message-body {font-size: 1.1em !important;}.gradio-container, .gradio-container * {font-family: 'Press Start 2P', cursive !important;}1 unmodified linefont-family: 'Press Start 2P', cursive !important;}.gr-button {padding: 12px 18px !important;}.dark-mode-toggle {display: none !important;}.gr-prose p {font-size: 1em !important;}"""# --- JAVASCRIPT FOR DARK MODE & SCROLL ---JAVASCRIPT_CODE = """function forceDarkMode() {const htmlElement = document.documentElement;if (!htmlElement.classList.contains('dark')) {htmlElement.classList.add('dark');}}document.addEventListener('DOMContentLoaded', forceDarkMode);const observer = new MutationObserver(forceDarkMode);observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });document.addEventListener('DOMContentLoaded', () => {const chat = document.querySelector('gradio-app').shadowRoot.querySelector('#component-chat .scroll-hide');if (chat) {4 unmodified lines});"""jade_synthwave_theme = gr.themes.Base(primary_hue=gr.themes.Color("hsl(180, 100%, 50%)", "hsl(180, 100%, 40%)", "hsl(180, 100%, 60%)","hsl(180, 100%, 70%)", "hsl(180, 100%, 80%)", "hsl(180, 100%, 90%)","hsl(180, 100%, 95%)", "hsl(180, 100%, 97%)", "hsl(180, 100%, 98%)","hsl(180, 100%, 99%)", "hsl(180, 100%, 100%)"),secondary_hue=gr.themes.Color("hsl(280, 100%, 50%)", "hsl(280, 100%, 40%)", "hsl(280, 100%, 60%)","hsl(280, 100%, 70%)", "hsl(280, 100%, 80%)", "hsl(280, 100%, 90%)","hsl(280, 100%, 95%)", "hsl(280, 100%, 97%)", "hsl(280, 100%, 98%)","hsl(280, 100%, 99%)", "hsl(280, 100%, 100%)"),neutral_hue=gr.themes.Color("hsl(240, 20%, 10%)", "hsl(240, 20%, 15%)", "hsl(240, 20%, 20%)","hsl(240, 20%, 25%)", "hsl(240, 20%, 30%)", "hsl(240, 20%, 35%)","hsl(240, 20%, 40%)", "hsl(240, 20%, 45%)", "hsl(240, 20%, 50%)","hsl(240, 20%, 55%)", "hsl(240, 20%, 60%)"))3 unmodified linestheme=jade_synthwave_theme,analytics_enabled=False,) as demo:gr.HTML(f"""<style>{SYNTHWAVE_CSS}24 unmodified linesheight=500,show_copy_button=True,layout="bubble",avatar_images=(None, "https://www.gradio.app/assets/img/logo.png"))with gr.Row():109 unmodified linesoutputs=[chat, usr_in, status_display, file_upload])clear_btn.click(clear_chat, outputs=[chat, usr_in, status_display, file_upload, ex_drop])ex_btn.click(lambda q: q or "", inputs=ex_drop, outputs=usr_in)3 unmodified linesdemo.queue(max_size=32, default_concurrency_limit=int(os.getenv("JADEGPT_CONCURRENCY", "2")))if __name__ == "__main__":demo.launch()
app.py+115-210