Bitsage commited on
Commit
50ca169
·
1 Parent(s): e95e0b5

feat: Omission Oracle UI - Live model trust scanner with Shadow Score

Browse files
Files changed (1) hide show
  1. app.py +126 -2
app.py CHANGED
@@ -887,9 +887,103 @@ JS = r"""
887
  capsules = _list_capsules()
888
  default_cep = capsules[0] if capsules else "CEP-2511-K4I7X2"
889
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
890
  with gr.Blocks(
891
- title="CROVIA · CEP Terminal",
892
- css=CSS,
893
  js=JS
894
  ) as demo:
895
 
@@ -910,6 +1004,36 @@ with gr.Blocks(
910
  # When cep_in changes -> compute payload
911
  cep_in.change(_run, inputs=cep_in, outputs=payload)
912
  demo.load(_run, inputs=cep_in, outputs=payload)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
913
 
914
  demo.launch()
915
 
 
887
  capsules = _list_capsules()
888
  default_cep = capsules[0] if capsules else "CEP-2511-K4I7X2"
889
 
890
+ # =============================================================================
891
+ # ORACLE UI - Model Trust Analysis
892
+ # =============================================================================
893
+
894
+ ORACLE_CSS = """
895
+ .oracle-section {
896
+ margin-top: 24px;
897
+ padding: 20px;
898
+ background: linear-gradient(180deg, #0a0c14, #05060a);
899
+ border: 1px solid rgba(139, 92, 246, 0.3);
900
+ border-radius: 16px;
901
+ }
902
+ .oracle-title {
903
+ color: #a78bfa !important;
904
+ font-size: 18px;
905
+ font-weight: 700;
906
+ margin-bottom: 16px;
907
+ letter-spacing: 0.1em;
908
+ }
909
+ .oracle-result {
910
+ padding: 16px;
911
+ background: rgba(0,0,0,0.4);
912
+ border-radius: 12px;
913
+ font-family: 'JetBrains Mono', monospace;
914
+ }
915
+ .score-gold { color: #F59E0B !important; }
916
+ .score-silver { color: #94A3B8 !important; }
917
+ .score-bronze { color: #D97706 !important; }
918
+ .score-red { color: #EF4444 !important; }
919
+ """
920
+
921
+ def analyze_hf_model(model_id: str) -> str:
922
+ """Analyze a HuggingFace model with the Omission Oracle."""
923
+ model_id = (model_id or "").strip()
924
+ if not model_id:
925
+ return "Enter a model ID (e.g., meta-llama/Llama-3-8B)"
926
+
927
+ try:
928
+ api = HfApi()
929
+ info = api.model_info(model_id, securityStatus=False)
930
+
931
+ model_data = {
932
+ "id": info.id,
933
+ "author": info.author or "",
934
+ "tags": info.tags or [],
935
+ "license": info.card_data.get("license") if info.card_data else None,
936
+ "cardData": info.card_data or {},
937
+ "downloads": info.downloads or 0,
938
+ "likes": info.likes or 0,
939
+ }
940
+
941
+ result = analyze_model_shadow_score(model_data)
942
+
943
+ # Format output
944
+ badge_emoji = {"GOLD": "🟢", "SILVER": "🟡", "BRONZE": "🟠", "UNVERIFIED": "🔴"}
945
+ emoji = badge_emoji.get(result["badge"], "⚪")
946
+
947
+ violations_str = ""
948
+ if result["violations"]:
949
+ for v in result["violations"]:
950
+ violations_str += f"\n • {v['id']}: {v['reason']}"
951
+ else:
952
+ violations_str = "\n ✓ No violations detected"
953
+
954
+ output = f"""╔══════════════════════════════════════════════════════════════╗
955
+ ║ CROVIA OMISSION ORACLE v{ENGINE_VERSION} ║
956
+ ╚══════════════════════════════════════════════════════════════╝
957
+
958
+ MODEL: {result['model_id']}
959
+ AUTHOR: {result['author']}
960
+
961
+ ┌─────────────────────────────────────┐
962
+ │ SHADOW SCORE: {result['shadow_score']:3d}/100 {emoji} {result['badge']:12s}│
963
+ │ SEVERITY: {result['severity']:10s} │
964
+ └─────────────────────────────────────┘
965
+
966
+ DECLARATIONS:
967
+ License: {result['license']}
968
+
969
+ VIOLATIONS ({result['violation_count']}): {violations_str}
970
+
971
+ ANALYSIS: {result['analyzed_at'][:19]}Z
972
+ EVIDENCE: {hashlib.sha256(model_id.encode()).hexdigest()[:16]}
973
+
974
+ ─────────────────────────────────────
975
+ Powered by Crovia Omission Oracle
976
+ https://huggingface.co/datasets/Crovia/global-ai-training-omissions
977
+ """
978
+ return output
979
+
980
+ except Exception as e:
981
+ return f"Error analyzing model: {type(e).__name__}: {e}"
982
+
983
+
984
  with gr.Blocks(
985
+ title="CROVIA · CEP Terminal v2.0",
986
+ css=CSS + ORACLE_CSS,
987
  js=JS
988
  ) as demo:
989
 
 
1004
  # When cep_in changes -> compute payload
1005
  cep_in.change(_run, inputs=cep_in, outputs=payload)
1006
  demo.load(_run, inputs=cep_in, outputs=payload)
1007
+
1008
+ # ==========================================================================
1009
+ # OMISSION ORACLE SECTION
1010
+ # ==========================================================================
1011
+
1012
+ gr.HTML("""
1013
+ <div class="oracle-section">
1014
+ <div class="oracle-title">🔮 OMISSION ORACLE — Model Trust Scanner</div>
1015
+ <p style="color:#a1a1aa;font-size:13px;margin-bottom:12px;">
1016
+ Analyze any HuggingFace model for trust declaration gaps (NEC#1, NEC#2, NEC#7, NEC#13)
1017
+ </p>
1018
+ </div>
1019
+ """)
1020
+
1021
+ with gr.Row():
1022
+ model_input = gr.Textbox(
1023
+ label="Model ID",
1024
+ placeholder="meta-llama/Llama-3-8B",
1025
+ scale=3
1026
+ )
1027
+ analyze_btn = gr.Button("🔍 Analyze", variant="primary", scale=1)
1028
+
1029
+ oracle_output = gr.Code(
1030
+ label="Oracle Analysis",
1031
+ language=None,
1032
+ lines=25
1033
+ )
1034
+
1035
+ analyze_btn.click(analyze_hf_model, inputs=model_input, outputs=oracle_output)
1036
+ model_input.submit(analyze_hf_model, inputs=model_input, outputs=oracle_output)
1037
 
1038
  demo.launch()
1039