petter2025 commited on
Commit
7597040
ยท
verified ยท
1 Parent(s): c0c9e7f

Update hf_demo.py

Browse files
Files changed (1) hide show
  1. hf_demo.py +61 -99
hf_demo.py CHANGED
@@ -1,6 +1,6 @@
1
  """
2
  ARF OSS v3.3.9 - Enterprise Lead Generation Engine
3
- Single file for Hugging Face Spaces with real ARF OSS components
4
  """
5
 
6
  import os
@@ -19,10 +19,10 @@ from dataclasses import dataclass, asdict
19
  from enum import Enum
20
 
21
  import gradio as gr
22
- from fastapi import FastAPI, HTTPException, Depends, Header
23
  from fastapi.middleware.cors import CORSMiddleware
24
  from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
25
- from pydantic import BaseModel, Field, validator
26
  from gradio import mount_gradio_app
27
 
28
  # ============== CONFIGURATION ==============
@@ -676,8 +676,10 @@ class ActionRequest(BaseModel):
676
  user_role: str = "devops"
677
  session_id: Optional[str] = None
678
 
679
- @validator('proposedAction')
680
- def validate_action(cls, v):
 
 
681
  if len(v.strip()) == 0:
682
  raise ValueError('Action cannot be empty')
683
  return v
@@ -922,51 +924,12 @@ async def health_check():
922
  def create_lead_gen_ui():
923
  """Professional lead generation interface"""
924
 
925
- with gr.Blocks(
926
- title="ARF OSS - Enterprise Reliability Intelligence",
927
- theme=gr.themes.Soft(primary_hue="blue", secondary_hue="indigo"),
928
- css="""
929
- .gradio-container { max-width: 1200px !important; margin: auto !important; }
930
- .lead-card {
931
- padding: 2rem;
932
- border-radius: 1rem;
933
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
934
- color: white;
935
- text-align: center;
936
- }
937
- .feature-grid {
938
- display: grid;
939
- grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
940
- gap: 1rem;
941
- margin: 2rem 0;
942
- }
943
- .feature-item {
944
- padding: 1.5rem;
945
- border-radius: 0.5rem;
946
- background: #f8f9fa;
947
- border-left: 4px solid #667eea;
948
- }
949
- .cta-button {
950
- background: white;
951
- color: #667eea;
952
- padding: 1rem 2rem;
953
- border-radius: 2rem;
954
- font-weight: bold;
955
- text-decoration: none;
956
- display: inline-block;
957
- margin: 0.5rem;
958
- transition: transform 0.2s;
959
- }
960
- .cta-button:hover {
961
- transform: translateY(-2px);
962
- box-shadow: 0 10px 20px rgba(0,0,0,0.2);
963
- }
964
- """
965
- ) as ui:
966
 
967
  # Header
968
  gr.HTML(f"""
969
- <div class="lead-card">
970
  <h1 style="font-size: 3em; margin-bottom: 0.5rem;">๐Ÿค– ARF OSS v3.3.9</h1>
971
  <h2 style="font-size: 1.5em; font-weight: 300; margin-bottom: 2rem;">
972
  Real Bayesian Reliability Intelligence
@@ -992,39 +955,48 @@ def create_lead_gen_ui():
992
  """)
993
 
994
  # Features Grid
995
- gr.HTML("""
996
- <div class="feature-grid">
997
- <div class="feature-item">
998
- <h4>๐Ÿงฎ True Bayesian Inference</h4>
999
- <p>Beta-Binomial conjugate priors with evidence updates</p>
1000
- </div>
1001
- <div class="feature-item">
1002
- <h4>๐Ÿ›ก๏ธ Deterministic Policies</h4>
1003
- <p>5 mechanical gates with live configuration</p>
1004
- </div>
1005
- <div class="feature-item">
1006
- <h4>๐Ÿ’พ Persistent RAG Memory</h4>
1007
- <p>SQLite + vector embeddings for incident recall</p>
1008
- </div>
1009
- <div class="feature-item">
1010
- <h4>๐Ÿ“Š Lead Intelligence</h4>
1011
- <p>Automatic enterprise signal detection</p>
1012
- </div>
1013
- </div>
1014
- """)
1015
 
1016
- # Live Demo Stats
1017
  with gr.Row():
1018
  with gr.Column():
1019
- demo_stats = gr.JSON(
1020
- label="๐Ÿ“Š Live Demo Statistics",
1021
- value={
1022
- "active_since": datetime.utcnow().strftime("%Y-%m-%d %H:%M"),
1023
- "bayesian_prior": "Beta(2.0, 5.0)",
1024
- "memory_size": len(memory.get_uncontacted_signals()),
1025
- "enterprise_signals": len(memory.get_uncontacted_signals())
1026
- }
1027
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1028
 
1029
  # CTA Section
1030
  gr.HTML(f"""
@@ -1037,10 +1009,11 @@ def create_lead_gen_ui():
1037
 
1038
  <div style="display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap;">
1039
  <a href="mailto:{settings.LEAD_EMAIL}?subject=ARF%20Enterprise%20Demo%20Request&body=I%20saw%20the%20real%20ARF%20OSS%20demo%20and%20would%20like%20to%20discuss%20Enterprise%20capabilities."
1040
- class="cta-button">
1041
  ๐Ÿ“ง {settings.LEAD_EMAIL}
1042
  </a>
1043
- <a href="{settings.CALENDLY_URL}" target="_blank" class="cta-button" style="background: #FFD700; color: #333;">
 
1044
  ๐Ÿ“… Schedule Technical Demo
1045
  </a>
1046
  </div>
@@ -1057,8 +1030,7 @@ def create_lead_gen_ui():
1057
  <div style="text-align: center; padding: 2rem; color: #666; border-top: 1px solid #eee;">
1058
  <p>
1059
  ๐Ÿ“ง <a href="mailto:{settings.LEAD_EMAIL}" style="color: #667eea;">{settings.LEAD_EMAIL}</a> โ€ข
1060
- ๐Ÿ™ <a href="https://github.com/petterjuan/agentic-reliability-framework" style="color: #667eea;">GitHub</a> โ€ข
1061
- ๐Ÿ’ผ <a href="#" style="color: #667eea;">LinkedIn</a>
1062
  </p>
1063
  <p style="font-size: 0.9rem;">
1064
  ยฉ 2026 ARF - Open Source Intelligence, Enterprise Execution<br>
@@ -1068,19 +1040,6 @@ def create_lead_gen_ui():
1068
  </p>
1069
  </div>
1070
  """)
1071
-
1072
- # Auto-refresh stats every 30 seconds
1073
- demo_stats.change(
1074
- fn=lambda: {
1075
- "active_since": datetime.utcnow().strftime("%Y-%m-%d %H:%M"),
1076
- "bayesian_prior": "Beta(2.0, 5.0)",
1077
- "memory_size": len(memory.get_uncontacted_signals()),
1078
- "enterprise_signals": len(memory.get_uncontacted_signals())
1079
- },
1080
- inputs=[],
1081
- outputs=[demo_stats],
1082
- every=30
1083
- )
1084
 
1085
  return ui
1086
 
@@ -1100,9 +1059,12 @@ if __name__ == "__main__":
1100
  logger.info(f"๐Ÿ”‘ API Key: {settings.API_KEY[:8]}... (set in HF secrets)")
1101
  logger.info("="*60)
1102
 
1103
- uvicorn.run(
1104
- app,
1105
- host="0.0.0.0",
1106
- port=port,
1107
- log_level="info"
 
 
 
1108
  )
 
1
  """
2
  ARF OSS v3.3.9 - Enterprise Lead Generation Engine
3
+ Compatible with Gradio 4.44.1 and Pydantic V2
4
  """
5
 
6
  import os
 
19
  from enum import Enum
20
 
21
  import gradio as gr
22
+ from fastapi import FastAPI, HTTPException, Depends
23
  from fastapi.middleware.cors import CORSMiddleware
24
  from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
25
+ from pydantic import BaseModel, Field, field_validator # Changed from validator
26
  from gradio import mount_gradio_app
27
 
28
  # ============== CONFIGURATION ==============
 
676
  user_role: str = "devops"
677
  session_id: Optional[str] = None
678
 
679
+ # FIXED: Using Pydantic V2 field_validator instead of deprecated validator
680
+ @field_validator('proposedAction')
681
+ @classmethod
682
+ def validate_action(cls, v: str) -> str:
683
  if len(v.strip()) == 0:
684
  raise ValueError('Action cannot be empty')
685
  return v
 
924
  def create_lead_gen_ui():
925
  """Professional lead generation interface"""
926
 
927
+ # FIXED: Moved theme and css to launch() method
928
+ with gr.Blocks(title="ARF OSS - Enterprise Reliability Intelligence") as ui:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
929
 
930
  # Header
931
  gr.HTML(f"""
932
+ <div style="padding: 2rem; border-radius: 1rem; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; text-align: center;">
933
  <h1 style="font-size: 3em; margin-bottom: 0.5rem;">๐Ÿค– ARF OSS v3.3.9</h1>
934
  <h2 style="font-size: 1.5em; font-weight: 300; margin-bottom: 2rem;">
935
  Real Bayesian Reliability Intelligence
 
955
  """)
956
 
957
  # Features Grid
958
+ with gr.Row():
959
+ with gr.Column():
960
+ gr.HTML("""
961
+ <div style="padding: 1.5rem; border-radius: 0.5rem; background: #f8f9fa; border-left: 4px solid #667eea; height: 100%;">
962
+ <h4>๐Ÿงฎ True Bayesian Inference</h4>
963
+ <p>Beta-Binomial conjugate priors with evidence updates</p>
964
+ </div>
965
+ """)
966
+ with gr.Column():
967
+ gr.HTML("""
968
+ <div style="padding: 1.5rem; border-radius: 0.5rem; background: #f8f9fa; border-left: 4px solid #667eea; height: 100%;">
969
+ <h4>๐Ÿ›ก๏ธ Deterministic Policies</h4>
970
+ <p>5 mechanical gates with live configuration</p>
971
+ </div>
972
+ """)
 
 
 
 
 
973
 
 
974
  with gr.Row():
975
  with gr.Column():
976
+ gr.HTML("""
977
+ <div style="padding: 1.5rem; border-radius: 0.5rem; background: #f8f9fa; border-left: 4px solid #667eea; height: 100%;">
978
+ <h4>๐Ÿ’พ Persistent RAG Memory</h4>
979
+ <p>SQLite + vector embeddings for incident recall</p>
980
+ </div>
981
+ """)
982
+ with gr.Column():
983
+ gr.HTML("""
984
+ <div style="padding: 1.5rem; border-radius: 0.5rem; background: #f8f9fa; border-left: 4px solid #667eea; height: 100%;">
985
+ <h4>๐Ÿ“Š Lead Intelligence</h4>
986
+ <p>Automatic enterprise signal detection</p>
987
+ </div>
988
+ """)
989
+
990
+ # Live Demo Stats - FIXED: Removed 'every' parameter for Gradio 4.x
991
+ demo_stats = gr.JSON(
992
+ label="๐Ÿ“Š Live Demo Statistics",
993
+ value={
994
+ "active_since": datetime.utcnow().strftime("%Y-%m-%d %H:%M"),
995
+ "bayesian_prior": "Beta(2.0, 5.0)",
996
+ "memory_size": len(memory.get_uncontacted_signals()),
997
+ "enterprise_signals": len(memory.get_uncontacted_signals())
998
+ }
999
+ )
1000
 
1001
  # CTA Section
1002
  gr.HTML(f"""
 
1009
 
1010
  <div style="display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap;">
1011
  <a href="mailto:{settings.LEAD_EMAIL}?subject=ARF%20Enterprise%20Demo%20Request&body=I%20saw%20the%20real%20ARF%20OSS%20demo%20and%20would%20like%20to%20discuss%20Enterprise%20capabilities."
1012
+ style="background: white; color: #667eea; padding: 1rem 2rem; border-radius: 2rem; font-weight: bold; text-decoration: none; display: inline-block; margin: 0.5rem;">
1013
  ๐Ÿ“ง {settings.LEAD_EMAIL}
1014
  </a>
1015
+ <a href="{settings.CALENDLY_URL}" target="_blank"
1016
+ style="background: #FFD700; color: #333; padding: 1rem 2rem; border-radius: 2rem; font-weight: bold; text-decoration: none; display: inline-block; margin: 0.5rem;">
1017
  ๐Ÿ“… Schedule Technical Demo
1018
  </a>
1019
  </div>
 
1030
  <div style="text-align: center; padding: 2rem; color: #666; border-top: 1px solid #eee;">
1031
  <p>
1032
  ๐Ÿ“ง <a href="mailto:{settings.LEAD_EMAIL}" style="color: #667eea;">{settings.LEAD_EMAIL}</a> โ€ข
1033
+ ๐Ÿ™ <a href="https://github.com/petterjuan/agentic-reliability-framework" style="color: #667eea;">GitHub</a>
 
1034
  </p>
1035
  <p style="font-size: 0.9rem;">
1036
  ยฉ 2026 ARF - Open Source Intelligence, Enterprise Execution<br>
 
1040
  </p>
1041
  </div>
1042
  """)
 
 
 
 
 
 
 
 
 
 
 
 
 
1043
 
1044
  return ui
1045
 
 
1059
  logger.info(f"๐Ÿ”‘ API Key: {settings.API_KEY[:8]}... (set in HF secrets)")
1060
  logger.info("="*60)
1061
 
1062
+ # FIXED: Moved theme and css to launch()
1063
+ gradio_ui.launch(
1064
+ server_name="0.0.0.0",
1065
+ server_port=port,
1066
+ theme=gr.themes.Soft(primary_hue="blue", secondary_hue="indigo"),
1067
+ css="""
1068
+ .gradio-container { max-width: 1200px !important; margin: auto !important; }
1069
+ """
1070
  )