Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import hashlib
|
| 3 |
+
import matplotlib.pyplot as plt
|
| 4 |
+
import numpy as np
|
| 5 |
+
from datetime import datetime
|
| 6 |
+
|
| 7 |
+
# π PIFORGE PREMIUM BRANDING
|
| 8 |
+
PIFORGE_CSS = """
|
| 9 |
+
.piforge-premium-header {
|
| 10 |
+
background: linear-gradient(135deg, #FF6B6B 0%, #FFE66D 50%, #1A535C 100%);
|
| 11 |
+
padding: 30px;
|
| 12 |
+
border-radius: 20px;
|
| 13 |
+
color: white;
|
| 14 |
+
text-align: center;
|
| 15 |
+
margin-bottom: 30px;
|
| 16 |
+
border: 4px solid #4ECDC4;
|
| 17 |
+
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
|
| 18 |
+
}
|
| 19 |
+
.piforge-official-badge {
|
| 20 |
+
background: linear-gradient(45deg, #FF6B6B, #FFE66D);
|
| 21 |
+
color: #1A535C;
|
| 22 |
+
padding: 8px 16px;
|
| 23 |
+
border-radius: 20px;
|
| 24 |
+
font-size: 16px;
|
| 25 |
+
font-weight: bold;
|
| 26 |
+
}
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
class PiForgeQualiaOracle:
|
| 30 |
+
def get_qualia_score(self, impact_text: str) -> int:
|
| 31 |
+
if not impact_text: return 500
|
| 32 |
+
text_lower = impact_text.lower()
|
| 33 |
+
score = 500
|
| 34 |
+
positive_terms = {
|
| 35 |
+
"community": 80, "help": 70, "education": 75, "inclusion": 90,
|
| 36 |
+
"transparent": 85, "fair": 80, "accessible": 75, "free": 60,
|
| 37 |
+
"open": 70, "decentralized": 65, "privacy": 75, "empower": 85
|
| 38 |
+
}
|
| 39 |
+
for term, boost in positive_terms.items():
|
| 40 |
+
if term in text_lower: score += boost
|
| 41 |
+
score += min(200, len(impact_text) // 2)
|
| 42 |
+
return min(1000, max(0, score))
|
| 43 |
+
|
| 44 |
+
qualia_oracle = PiForgeQualiaOracle()
|
| 45 |
+
|
| 46 |
+
def velvet_verdict(a, b):
|
| 47 |
+
a, b = int(a), int(b)
|
| 48 |
+
if a == 0 or b == 0: return 0
|
| 49 |
+
return (2 * a * b) // (a + b)
|
| 50 |
+
|
| 51 |
+
def simple_ethics_check(project_name, description, impact):
|
| 52 |
+
if not description:
|
| 53 |
+
return 0, "π Please describe your project", "Waiting for your vision..."
|
| 54 |
+
|
| 55 |
+
qualia_score = qualia_oracle.get_qualia_score(impact + " " + description)
|
| 56 |
+
efficiency_score = min(800, len(description) * 2 + 400)
|
| 57 |
+
resonance = velvet_verdict(efficiency_score, qualia_score)
|
| 58 |
+
|
| 59 |
+
if resonance >= 850:
|
| 60 |
+
verdict = "π― EXCELLENT - Strong Pi ecosystem alignment!"
|
| 61 |
+
confidence = f"PiForge Score: {resonance}/1000 - Ready for immediate development!"
|
| 62 |
+
elif resonance >= 700:
|
| 63 |
+
verdict = "β
VERY GOOD - Positive impact potential"
|
| 64 |
+
confidence = f"PiForge Score: {resonance}/1000 - Solid ethical foundation"
|
| 65 |
+
elif resonance >= 550:
|
| 66 |
+
verdict = "π‘ GOOD - Some refinement opportunities"
|
| 67 |
+
confidence = f"PiForge Score: {resonance}/1000 - Consider community feedback"
|
| 68 |
+
elif resonance >= 400:
|
| 69 |
+
verdict = "π FAIR - Needs ethical refinement"
|
| 70 |
+
confidence = f"PiForge Score: {resonance}/1000 - Focus on user benefits"
|
| 71 |
+
else:
|
| 72 |
+
verdict = "π NEEDS WORK - Rethink core approach"
|
| 73 |
+
confidence = f"PiForge Score: {resonance}/1000 - Prioritize community value"
|
| 74 |
+
|
| 75 |
+
return resonance, verdict, confidence
|
| 76 |
+
|
| 77 |
+
with gr.Blocks(theme=gr.themes.Soft(primary_hue="violet"), title="PiForge: Sovereign Canticle Forge", css=PIFORGE_CSS) as demo:
|
| 78 |
+
|
| 79 |
+
with gr.Row(elem_classes="piforge-premium-header"):
|
| 80 |
+
gr.Markdown("""
|
| 81 |
+
# π¨ Ο PiForge v1.1
|
| 82 |
+
### **Sovereign Canticle Forge** - Official Ethical AI Audit System
|
| 83 |
+
*Build Apps, Boost Mining, Be Limitless!* <span class='piforge-official-badge'>π OFFICIAL RELEASE</span>
|
| 84 |
+
""")
|
| 85 |
+
|
| 86 |
+
with gr.Tab("π Simple Mode"):
|
| 87 |
+
gr.Markdown("### π€ PiForge Quick Ethics Check")
|
| 88 |
+
gr.Markdown("*Get instant ethical alignment scoring for your Pi projects*")
|
| 89 |
+
|
| 90 |
+
with gr.Row():
|
| 91 |
+
with gr.Column():
|
| 92 |
+
simple_project = gr.Textbox(label="Project Name", placeholder="My Community Marketplace")
|
| 93 |
+
simple_description = gr.Textbox(label="Project Description", placeholder="What does your project do?", lines=3)
|
| 94 |
+
simple_impact = gr.Textbox(label="Intended Impact", placeholder="Who benefits?", lines=2)
|
| 95 |
+
simple_btn = gr.Button("π Check Ethical Alignment", variant="primary")
|
| 96 |
+
|
| 97 |
+
with gr.Column():
|
| 98 |
+
simple_score = gr.Number(label="PiForge Alignment Score", value=0)
|
| 99 |
+
simple_verdict = gr.Textbox(label="Recommendation", lines=2)
|
| 100 |
+
simple_analysis = gr.Textbox(label="Detailed Analysis", lines=3)
|
| 101 |
+
|
| 102 |
+
simple_btn.click(simple_ethics_check, inputs=[simple_project, simple_description, simple_impact], outputs=[simple_score, simple_verdict, simple_analysis])
|
| 103 |
+
|
| 104 |
+
if __name__ == "__main__":
|
| 105 |
+
demo.launch()
|