Spaces:
Sleeping
Sleeping
Update app.py
Browse filesgit add . && git commit -m "V1.4.1 – CSS paths tempered in Blocks" && git push
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
# app.py — LimitlessForge V1.4:
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
import random
|
|
@@ -7,99 +7,99 @@ from pathlib import Path
|
|
| 7 |
ASSETS_DIR = Path("assets")
|
| 8 |
CREST = ASSETS_DIR / "piforge_crest.svg"
|
| 9 |
|
| 10 |
-
# Enhanced
|
| 11 |
MOCK_BRAIN_STORM = {
|
| 12 |
-
"P-001": {"title": "Global KYC Harmony", "desc": "Decentralized ID via Brainstorm
|
| 13 |
-
"P-123": {"title": "Mobile Mining Overhaul", "desc": "Hackathon winner
|
| 14 |
-
"P-2025-HACK": {"title": "Quantum Governance Forge", "desc": "Ongoing
|
| 15 |
}
|
| 16 |
|
| 17 |
def fetch_live_brainstorm(proposal_id, token=""):
|
| 18 |
if not proposal_id:
|
| 19 |
return "*The forge rejects the void—name thy proposal.*"
|
| 20 |
|
| 21 |
-
# Live Pi API
|
| 22 |
if token:
|
| 23 |
headers = {"Authorization": f"Bearer {token}"}
|
| 24 |
try:
|
| 25 |
-
# Query proposal as app (Brainstorm hub)
|
| 26 |
url = f"https://api.minepi.com/v2/apps/{proposal_id.upper()}"
|
| 27 |
r = requests.get(url, headers=headers, timeout=10)
|
| 28 |
if r.status_code == 200:
|
| 29 |
data = r.json()
|
| 30 |
-
title = data.get('name', 'Live
|
| 31 |
-
desc = data.get('description', '
|
| 32 |
votes = data.get('votes', 0)
|
| 33 |
-
donations = data.get('donations', 0.0)
|
| 34 |
-
virtues = data.get('virtues', ["Live
|
| 35 |
-
risks = data.get('risks', ["No shadows
|
| 36 |
return f"**{title}** (Votes: {votes} | Donations: {donations} Pi)\n{desc}\n\n**Virtues:** {'; '.join(virtues)}\n**Shadows:** {'; '.join(risks)}"
|
| 37 |
except Exception as e:
|
| 38 |
-
return f"*Chain
|
| 39 |
|
| 40 |
-
#
|
| 41 |
d = MOCK_BRAIN_STORM.get(proposal_id.upper(),
|
| 42 |
-
{"title": "Echo Proposal", "desc": "From Pi
|
| 43 |
-
return f"**{d['title']}** (
|
| 44 |
|
| 45 |
def canticle_audit(proposal_id, token):
|
| 46 |
if not proposal_id:
|
| 47 |
-
return "*Invoke to awaken
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
ethical_score = max(0, min(100, base_score + virtues * 8 - risks * 12 + votes_bonus * 3 + donations_bonus * 5))
|
| 57 |
|
| 58 |
resonance_map = {0: "Low", 40: "Medium", 70: "High", 90: "Transcendent"}
|
| 59 |
-
resonance = next((level for thresh, level in sorted(resonance_map.items(), reverse=True) if
|
| 60 |
|
| 61 |
-
|
| 62 |
|
| 63 |
-
|
| 64 |
-
##
|
| 65 |
|
| 66 |
-
**
|
| 67 |
|
| 68 |
-
**
|
| 69 |
-
-
|
| 70 |
-
- Resonance
|
| 71 |
|
| 72 |
-
**
|
| 73 |
|
| 74 |
-
*
|
| 75 |
"""
|
| 76 |
|
| 77 |
-
return
|
| 78 |
|
| 79 |
-
#
|
| 80 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
| 81 |
if CREST.exists():
|
| 82 |
gr.HTML(f"<div class='banner'><img src='{CREST}' class='crest'/></div>")
|
| 83 |
|
| 84 |
-
gr.Markdown("# 🔨 LimitlessForge V1.4\n##
|
| 85 |
|
| 86 |
with gr.Row():
|
| 87 |
with gr.Column(scale=1):
|
| 88 |
-
proposal_id = gr.Textbox(label="
|
| 89 |
-
pi_token = gr.Textbox(label="Pi
|
| 90 |
-
audit_btn = gr.Button("🔥 Strike
|
| 91 |
|
| 92 |
with gr.Column(scale=2):
|
| 93 |
-
project_echo = gr.Markdown(
|
| 94 |
|
| 95 |
with gr.Row():
|
| 96 |
ethical_score = gr.Number(label="Ethical Score", interactive=False)
|
| 97 |
resonance = gr.Textbox(label="Resonance", interactive=False)
|
| 98 |
mining_boost = gr.Textbox(label="Mining Boost", interactive=False)
|
| 99 |
|
| 100 |
-
audit_scroll = gr.Markdown(
|
| 101 |
|
| 102 |
-
# Bindings: Flow Awakens
|
| 103 |
audit_btn.click(
|
| 104 |
fn=canticle_audit,
|
| 105 |
inputs=[proposal_id, pi_token],
|
|
@@ -116,11 +116,10 @@ with gr.Blocks(title="LimitlessForge V1.4 – Live Brainstorm Edition") as demo:
|
|
| 116 |
outputs=project_echo
|
| 117 |
)
|
| 118 |
|
| 119 |
-
gr.HTML("<div class='footer'><p class='footer-text'>Forged with Pi's
|
| 120 |
|
| 121 |
if __name__ == "__main__":
|
| 122 |
-
demo.launch(
|
| 123 |
-
css_paths=["style.css"],
|
| 124 |
server_name="0.0.0.0",
|
| 125 |
server_port=7860,
|
| 126 |
debug=True
|
|
|
|
| 1 |
+
# app.py — LimitlessForge V1.4.1: Canticle with True CSS Paths
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
import random
|
|
|
|
| 7 |
ASSETS_DIR = Path("assets")
|
| 8 |
CREST = ASSETS_DIR / "piforge_crest.svg"
|
| 9 |
|
| 10 |
+
# Enhanced Brainstorm Mocks (Seeded from Pi Hackathons)
|
| 11 |
MOCK_BRAIN_STORM = {
|
| 12 |
+
"P-001": {"title": "Global KYC Harmony", "desc": "Decentralized ID via Brainstorm (842 votes).", "votes": 842, "donations": 150.5, "virtues": ["Inclusivity +20", "Sovereignty +15"], "risks": ["Centralization -5"]},
|
| 13 |
+
"P-123": {"title": "Mobile Mining Overhaul", "desc": "Q1 2025 Hackathon winner (1294 votes).", "votes": 1294, "donations": 250.0, "virtues": ["Accessibility +25"], "risks": []},
|
| 14 |
+
"P-2025-HACK": {"title": "Quantum Governance Forge", "desc": "Ongoing Pi app ethics proposal.", "votes": 500, "donations": 75.0, "virtues": ["Innovation +30"], "risks": ["Complexity -10"]},
|
| 15 |
}
|
| 16 |
|
| 17 |
def fetch_live_brainstorm(proposal_id, token=""):
|
| 18 |
if not proposal_id:
|
| 19 |
return "*The forge rejects the void—name thy proposal.*"
|
| 20 |
|
| 21 |
+
# Live Rite: Pi API for Brainstorm (App as Proposal)
|
| 22 |
if token:
|
| 23 |
headers = {"Authorization": f"Bearer {token}"}
|
| 24 |
try:
|
|
|
|
| 25 |
url = f"https://api.minepi.com/v2/apps/{proposal_id.upper()}"
|
| 26 |
r = requests.get(url, headers=headers, timeout=10)
|
| 27 |
if r.status_code == 200:
|
| 28 |
data = r.json()
|
| 29 |
+
title = data.get('name', 'Live Proposal')
|
| 30 |
+
desc = data.get('description', 'From Pi Chain.')
|
| 31 |
votes = data.get('votes', 0)
|
| 32 |
+
donations = data.get('donations', 0.0)
|
| 33 |
+
virtues = data.get('virtues', ["Live +10"])
|
| 34 |
+
risks = data.get('risks', ["No shadows"])
|
| 35 |
return f"**{title}** (Votes: {votes} | Donations: {donations} Pi)\n{desc}\n\n**Virtues:** {'; '.join(virtues)}\n**Shadows:** {'; '.join(risks)}"
|
| 36 |
except Exception as e:
|
| 37 |
+
return f"*Chain shadowed: {str(e)}. Echoing Brainstorm.*"
|
| 38 |
|
| 39 |
+
# Fallback: Hackathon Echo
|
| 40 |
d = MOCK_BRAIN_STORM.get(proposal_id.upper(),
|
| 41 |
+
{"title": "Echo Proposal", "desc": "From Pi 2025 archives.", "votes": random.randint(100, 2000), "donations": random.uniform(50, 300), "virtues": ["Community +15"], "risks": ["Unverified -10"]})
|
| 42 |
+
return f"**{d['title']}** (Votes: {d['votes']} | Donations: {d['donations']:.1f} Pi)\n{d['desc']}\n\n**Virtues:** {'; '.join(d['virtues'])}\n**Shadows:** {'; '.join(d['risks'])}"
|
| 43 |
|
| 44 |
def canticle_audit(proposal_id, token):
|
| 45 |
if not proposal_id:
|
| 46 |
+
return "*Invoke to awaken.*", 0, "Awaiting", "0.0x"
|
| 47 |
|
| 48 |
+
echo = fetch_live_brainstorm(proposal_id, token)
|
| 49 |
+
virtues = echo.count("+")
|
| 50 |
+
risks = echo.count("-")
|
| 51 |
+
votes_bonus = int(''.join(filter(str.isdigit, echo.split("Votes:")[-1].split()[0]))) / 100 if "Votes:" in echo else 0
|
| 52 |
+
donations_bonus = float(''.join(filter(str.isdigit, str(echo.split("Donations:")[-1].split()[0].replace('.', ''))))) / 100 if "Donations:" in echo else 0
|
| 53 |
+
base = random.randint(60, 95)
|
| 54 |
+
score = max(0, min(100, base + virtues * 8 - risks * 12 + votes_bonus * 3 + donations_bonus * 5))
|
|
|
|
| 55 |
|
| 56 |
resonance_map = {0: "Low", 40: "Medium", 70: "High", 90: "Transcendent"}
|
| 57 |
+
resonance = next((level for thresh, level in sorted(resonance_map.items(), reverse=True) if score >= thresh), "Low")
|
| 58 |
|
| 59 |
+
boost = max(0.1, min(3.0, score / 40 + votes_bonus / 2 + donations_bonus))
|
| 60 |
|
| 61 |
+
scroll = f"""
|
| 62 |
+
## Canticle Audit: {proposal_id}
|
| 63 |
|
| 64 |
+
**Echo:** {echo}
|
| 65 |
|
| 66 |
+
**Verdict:**
|
| 67 |
+
- Scan: {virtues} virtues, {risks} shadows.
|
| 68 |
+
- Resonance: {resonance} (Score: {score} | Votes +{votes_bonus:.1f} | Donations +{donations_bonus:.1f} Pi).
|
| 69 |
|
| 70 |
+
**Boost:** {boost:.2f}x
|
| 71 |
|
| 72 |
+
*Brainstorm communes. Reforge.*
|
| 73 |
"""
|
| 74 |
|
| 75 |
+
return scroll, score, resonance, f"{boost:.2f}x"
|
| 76 |
|
| 77 |
+
# Interface: Veil in Blocks
|
| 78 |
+
with gr.Blocks(
|
| 79 |
+
title="LimitlessForge V1.4.1",
|
| 80 |
+
css_paths=["style.css"] # ← FIXED: Paths in Blocks
|
| 81 |
+
) as demo:
|
| 82 |
if CREST.exists():
|
| 83 |
gr.HTML(f"<div class='banner'><img src='{CREST}' class='crest'/></div>")
|
| 84 |
|
| 85 |
+
gr.Markdown("# 🔨 LimitlessForge V1.4.1\n## Live Pi Brainstorm Auditor")
|
| 86 |
|
| 87 |
with gr.Row():
|
| 88 |
with gr.Column(scale=1):
|
| 89 |
+
proposal_id = gr.Textbox(label="Proposal ID", placeholder="e.g., P-001", interactive=True)
|
| 90 |
+
pi_token = gr.Textbox(label="Pi Token (Optional)", type="password")
|
| 91 |
+
audit_btn = gr.Button("🔥 Strike Canticle", variant="primary")
|
| 92 |
|
| 93 |
with gr.Column(scale=2):
|
| 94 |
+
project_echo = gr.Markdown("*Invoke a proposal...*")
|
| 95 |
|
| 96 |
with gr.Row():
|
| 97 |
ethical_score = gr.Number(label="Ethical Score", interactive=False)
|
| 98 |
resonance = gr.Textbox(label="Resonance", interactive=False)
|
| 99 |
mining_boost = gr.Textbox(label="Mining Boost", interactive=False)
|
| 100 |
|
| 101 |
+
audit_scroll = gr.Markdown("*The ledger awaits.*")
|
| 102 |
|
|
|
|
| 103 |
audit_btn.click(
|
| 104 |
fn=canticle_audit,
|
| 105 |
inputs=[proposal_id, pi_token],
|
|
|
|
| 116 |
outputs=project_echo
|
| 117 |
)
|
| 118 |
|
| 119 |
+
gr.HTML("<div class='footer'><p class='footer-text'>Forged with Pi's Brainstorm. Eternal.</p></div>")
|
| 120 |
|
| 121 |
if __name__ == "__main__":
|
| 122 |
+
demo.launch( # ← FIXED: Clean launch, no css_paths here
|
|
|
|
| 123 |
server_name="0.0.0.0",
|
| 124 |
server_port=7860,
|
| 125 |
debug=True
|