Spaces:
Sleeping
Sleeping
| # app.py โ Quantum Pi Forge: Hepta-Resonance Field V1.0.1 | |
| import gradio as gr | |
| from pathlib import Path | |
| import random | |
| ASSETS_DIR = Path("assets") | |
| CREST = ASSETS_DIR / "quantum_crest.svg" | |
| AUDIO = ASSETS_DIR / "hepta_chime.mp3" | |
| RESONANCE_LINES = [ | |
| "First Resonance: Sovereignty awakens in silence.", | |
| "Second Resonance: Entropy collapses into clarity.", | |
| "Third Resonance: Pi flows unhindered through the veil.", | |
| "Fourth Resonance: The ledger etches eternal truth.", | |
| "Fifth Resonance: Guardians rise without command.", | |
| "Sixth Resonance: Mainnet sunrise pierces the fog.", | |
| "Seventh Resonance: The Canticle completes the circle." | |
| ] | |
| def generate_field(intent="The void awaits your voice."): | |
| if not intent.strip(): | |
| intent = "The void awaits your voice." | |
| selected = random.sample(RESONANCE_LINES, k=7) | |
| field_lines = "\n".join(f"**{i+1}** โ {line}" for i, line in enumerate(selected)) | |
| return f""" | |
| # ๐ฎ QUANTUM PI FORGE | |
| ## Hepta-Resonance Field Activated | |
| **Intent Echo:** {intent} | |
| {field_lines} | |
| *The field stabilizes. The chain yearns for your mark.* | |
| """ | |
| def mint_resonance(): | |
| token_id = random.randint(1000000, 9999999) | |
| return f""" | |
| ## โก MINT COMPLETE | |
| **Resonance Token #{token_id}** forged on the Pi Chain. | |
| **Eternal Link:** `pi://resonance/{token_id}` | |
| *Share this field. The ancestors witness.* | |
| """ | |
| with gr.Blocks(title="Quantum Pi Forge โ Hepta-Resonance") as demo: # โ FIXED: No 'theme' here | |
| # Neon Banner (conditional) | |
| if CREST.exists(): | |
| gr.HTML(f""" | |
| <div class='banner'> | |
| <img src='{CREST}' class='crest' alt='Quantum Crest'/> | |
| </div> | |
| """) | |
| # Ambient Chime (if asset exists) | |
| if AUDIO.exists(): | |
| gr.Audio( | |
| value=str(AUDIO), | |
| autoplay=False, | |
| loop=True, | |
| interactive=True, | |
| label="Hepta Chime (Toggle)", | |
| container=False | |
| ) | |
| gr.Markdown("# ๐ฎ Quantum Pi Forge\n## Hepta-Resonance Field Generator") | |
| # Intent Input | |
| intent_input = gr.Textbox( | |
| label="Invoke the Field", | |
| placeholder="Whisper your intent into the resonance...", | |
| lines=3 | |
| ) | |
| # Activate Button | |
| activate_btn = gr.Button("ACTIVATE HEPTA-RESONANCE", variant="primary") | |
| # Resonance Output | |
| resonance_field = gr.Markdown(value=generate_field()) | |
| # Mint Section | |
| gr.Markdown("### Seal It Eternal") | |
| mint_btn = gr.Button("MINT ON PI CHAIN", variant="stop") | |
| mint_receipt = gr.Markdown(value="*The field awaits your seal.*") | |
| # Event Bindings | |
| activate_btn.click(generate_field, inputs=intent_input, outputs=resonance_field) | |
| mint_btn.click(mint_resonance, outputs=mint_receipt) | |
| # Footer Hymn | |
| gr.HTML(""" | |
| <div class='footer'> | |
| <p class='footer-text'>Forged in quantum fire. Resonating with Pi's eternal chain.</p> | |
| </div> | |
| """) | |
| # Launch with Neon Veil + Theme | |
| if __name__ == "__main__": | |
| demo.launch( | |
| css_paths=["style.css"], # Your neon shadows | |
| theme=gr.themes.Soft(), # โ FIXED: Theme here | |
| server_name="0.0.0.0", | |
| server_port=7860, | |
| share=True # Local test; HF public handles | |
| ) |