Update hf_demo.py
Browse files- 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 |
-
|
| 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
|
| 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 |
-
|
| 680 |
-
|
|
|
|
|
|
|
| 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 |
-
|
| 926 |
-
|
| 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
|
| 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.
|
| 996 |
-
|
| 997 |
-
|
| 998 |
-
<
|
| 999 |
-
|
| 1000 |
-
|
| 1001 |
-
|
| 1002 |
-
|
| 1003 |
-
|
| 1004 |
-
|
| 1005 |
-
|
| 1006 |
-
|
| 1007 |
-
|
| 1008 |
-
|
| 1009 |
-
|
| 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 |
-
|
| 1020 |
-
|
| 1021 |
-
|
| 1022 |
-
|
| 1023 |
-
|
| 1024 |
-
|
| 1025 |
-
|
| 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 |
-
|
| 1041 |
๐ง {settings.LEAD_EMAIL}
|
| 1042 |
</a>
|
| 1043 |
-
<a href="{settings.CALENDLY_URL}" target="_blank"
|
|
|
|
| 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 |
-
|
| 1104 |
-
|
| 1105 |
-
|
| 1106 |
-
|
| 1107 |
-
|
|
|
|
|
|
|
|
|
|
| 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 |
)
|