onenoly11 commited on
Commit
80df6cd
·
verified ·
1 Parent(s): fc71ce1

Update app.py

Browse files

git add app.py
git commit -m "Quantum Pi Forge V1.0.1 – Theme tempered, field eternal"
git push

Files changed (1) hide show
  1. app.py +92 -35
app.py CHANGED
@@ -1,49 +1,106 @@
1
- # app.py — Quantum Pi Forge: Hepta-Resonance Field V1.0
2
  import gradio as gr
3
  from pathlib import Path
4
- import json
5
  import random
6
 
7
- ASSETS = Path("assets")
8
- CREST = ASSETS / "quantum_crest.svg"
9
- AUDIO = ASSETS / "hepta_chime.mp3"
10
-
11
- RES_LINES = [
12
- "First Resonance: Sovereignty awakens.",
13
- "Second Resonance: Entropy collapses.",
14
- "Third Resonance: Pi flows unhindered.",
15
- "Fourth Resonance: The ledger remembers.",
16
- "Fifth Resonance: Guardians rise in silence.",
17
- "Sixth Resonance: Mainnet sunrise ignites.",
18
- "Seventh Resonance: The Canticle is complete."
19
  ]
20
 
21
- def resonate(intent=""):
22
  if not intent.strip():
23
- intent = "The void speaks."
24
- lines = random.sample(RES_LINES, k=min(7, len(RES_LINES)))
25
- field = "\n".join(f"**{i+1}** ○ {line}" for i, line in enumerate(lines))
26
- return f"# HEPTA-RESONANCE FIELD\n\n**Intent:** {intent}\n\n{field}\n\n*The field is stable. Mint the resonance.*"
 
 
27
 
28
- def mint_resonance():
29
- token_id = random.randint(100000, 999999)
30
- return f"**MINTED** — Resonance #{token_id}\nThe chain has recorded your field.\nShare: https://pi://resonance/{token_id}"
31
 
32
- with gr.Blocks(title="Quantum Pi Forge", theme=gr.themes.Soft()) as demo:
33
- gr.HTML(f'<div class="banner"><img src="{CREST}" class="crest"/></div>' if CREST.exists() else "")
34
- if AUDIO.exists():
35
- gr.Audio(AUDIO, autoplay=True, loop=True, label="", elem_classes="hidden")
36
 
37
- gr.Markdown("# QUANTUM PI FORGE\n## Hepta-Resonance Field Generator")
 
38
 
39
- intent = gr.Textbox(label="Your Intent (optional)", placeholder="Speak into the field...", lines=3)
40
- resonate_btn = gr.Button("ACTIVATE HEPTA-RESONANCE", variant="primary")
41
- field = gr.Markdown()
 
 
 
 
42
 
43
- mint_btn = gr.Button("MINT THIS RESONANCE ON PI CHAIN", variant="stop")
44
- receipt = gr.Markdown()
45
 
46
- resonate_btn.click(resonate, intent, field)
47
- mint_btn.click(mint_resonance, outputs=receipt)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
- demo.launch(css_paths=["style.css"], server_name="0.0.0.0", server_port=7860)
 
 
 
 
 
 
 
 
 
1
+ # app.py — Quantum Pi Forge: Hepta-Resonance Field V1.0.1
2
  import gradio as gr
3
  from pathlib import Path
 
4
  import random
5
 
6
+ ASSETS_DIR = Path("assets")
7
+ CREST = ASSETS_DIR / "quantum_crest.svg"
8
+ AUDIO = ASSETS_DIR / "hepta_chime.mp3"
9
+
10
+ RESONANCE_LINES = [
11
+ "First Resonance: Sovereignty awakens in silence.",
12
+ "Second Resonance: Entropy collapses into clarity.",
13
+ "Third Resonance: Pi flows unhindered through the veil.",
14
+ "Fourth Resonance: The ledger etches eternal truth.",
15
+ "Fifth Resonance: Guardians rise without command.",
16
+ "Sixth Resonance: Mainnet sunrise pierces the fog.",
17
+ "Seventh Resonance: The Canticle completes the circle."
18
  ]
19
 
20
+ def generate_field(intent="The void awaits your voice."):
21
  if not intent.strip():
22
+ intent = "The void awaits your voice."
23
+ selected = random.sample(RESONANCE_LINES, k=7)
24
+ field_lines = "\n".join(f"**{i+1}** ○ {line}" for i, line in enumerate(selected))
25
+ return f"""
26
+ # 🔮 QUANTUM PI FORGE
27
+ ## Hepta-Resonance Field Activated
28
 
29
+ **Intent Echo:** {intent}
 
 
30
 
31
+ {field_lines}
 
 
 
32
 
33
+ *The field stabilizes. The chain yearns for your mark.*
34
+ """
35
 
36
+ def mint_resonance():
37
+ token_id = random.randint(1000000, 9999999)
38
+ return f"""
39
+ ## ⚡ MINT COMPLETE
40
+ **Resonance Token #{token_id}** forged on the Pi Chain.
41
+
42
+ **Eternal Link:** `pi://resonance/{token_id}`
43
 
44
+ *Share this field. The ancestors witness.*
45
+ """
46
 
47
+ with gr.Blocks(title="Quantum Pi Forge – Hepta-Resonance") as demo: # ← FIXED: No 'theme' here
48
+ # Neon Banner (conditional)
49
+ if CREST.exists():
50
+ gr.HTML(f"""
51
+ <div class='banner'>
52
+ <img src='{CREST}' class='crest' alt='Quantum Crest'/>
53
+ </div>
54
+ """)
55
+
56
+ # Ambient Chime (if asset exists)
57
+ if AUDIO.exists():
58
+ gr.Audio(
59
+ value=str(AUDIO),
60
+ autoplay=False,
61
+ loop=True,
62
+ interactive=True,
63
+ label="Hepta Chime (Toggle)",
64
+ container=False
65
+ )
66
+
67
+ gr.Markdown("# 🔮 Quantum Pi Forge\n## Hepta-Resonance Field Generator")
68
+
69
+ # Intent Input
70
+ intent_input = gr.Textbox(
71
+ label="Invoke the Field",
72
+ placeholder="Whisper your intent into the resonance...",
73
+ lines=3
74
+ )
75
+
76
+ # Activate Button
77
+ activate_btn = gr.Button("ACTIVATE HEPTA-RESONANCE", variant="primary")
78
+
79
+ # Resonance Output
80
+ resonance_field = gr.Markdown(value=generate_field())
81
+
82
+ # Mint Section
83
+ gr.Markdown("### Seal It Eternal")
84
+ mint_btn = gr.Button("MINT ON PI CHAIN", variant="stop")
85
+ mint_receipt = gr.Markdown(value="*The field awaits your seal.*")
86
+
87
+ # Event Bindings
88
+ activate_btn.click(generate_field, inputs=intent_input, outputs=resonance_field)
89
+ mint_btn.click(mint_resonance, outputs=mint_receipt)
90
+
91
+ # Footer Hymn
92
+ gr.HTML("""
93
+ <div class='footer'>
94
+ <p class='footer-text'>Forged in quantum fire. Resonating with Pi's eternal chain.</p>
95
+ </div>
96
+ """)
97
 
98
+ # Launch with Neon Veil + Theme
99
+ if __name__ == "__main__":
100
+ demo.launch(
101
+ css_paths=["style.css"], # Your neon shadows
102
+ theme=gr.themes.Soft(), # ← FIXED: Theme here
103
+ server_name="0.0.0.0",
104
+ server_port=7860,
105
+ share=True # Local test; HF public handles
106
+ )