jeronimo9 commited on
Commit
5300ac9
·
verified ·
1 Parent(s): e69e3f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -188
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import gradio as gr
2
  import pandas as pd
3
 
 
4
  PREAMBLE_COLORS = {
5
  'light': '#081423',
6
  'yellow': '#1F2C6D',
@@ -9,8 +10,51 @@ PREAMBLE_COLORS = {
9
  'dark': '#ECF0F6'
10
  }
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  CUSTOM_CSS = """
13
- /* Previous CSS styles remain the same */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  .recommendation-panel {
15
  background-color: rgba(69, 86, 228, 0.1);
16
  border-radius: 8px;
@@ -60,7 +104,7 @@ def calculate_roi(
60
  if deployment_type == "On-Premises":
61
  total_costs_preamble = 27000 * 12 # Fixed cost for enterprise
62
  else: # Cloud/SaaS
63
- if monthly_budget <= 10000: # Guardrails tier
64
  total_costs_preamble = estimated_api_calls * 0.005 * 12
65
  else: # SaaS tier
66
  total_costs_preamble = num_employees * 50 * 12 # $50 per user per month
@@ -73,192 +117,8 @@ def calculate_roi(
73
 
74
  def create_app():
75
  with gr.Blocks(css=CUSTOM_CSS) as roi_app:
76
- # Header
77
- with gr.Row(elem_classes="header"):
78
- gr.Markdown(
79
- "# 📊 Preamble AI ROI Calculator\n"
80
- "[Visit Preamble.com](https://preamble.com/) to learn more"
81
- )
82
-
83
- # Results section
84
- with gr.Row(elem_classes="results-container"):
85
- with gr.Column():
86
- build_roi_box = gr.Markdown(
87
- "### 🏗️ Building In-House\n**ROI:** 0%\n**Total Costs:** $0"
88
- )
89
- with gr.Column():
90
- preamble_roi_box = gr.Markdown(
91
- "### 🚀 Using Preamble\n**ROI:** 0%\n**Total Costs:** $0"
92
- )
93
-
94
- # Product Selection Section
95
- with gr.Row():
96
- with gr.Column():
97
- gr.Markdown("## 🎯 Select Your Preamble Solution")
98
- monthly_budget = gr.Number(
99
- label="Monthly Budget ($)",
100
- value=50000,
101
- info="Enter your monthly budget for AI governance"
102
- )
103
- deployment_type = gr.Radio(
104
- ["Cloud/SaaS", "On-Premises"],
105
- label="Deployment Type",
106
- value="Cloud/SaaS",
107
- info="Choose your preferred deployment model"
108
- )
109
- existing_ai = gr.Radio(
110
- ["Yes, we have existing AI applications", "No, we need a full platform"],
111
- label="Existing AI Applications",
112
- value="No, we need a full platform",
113
- info="Tell us about your current AI implementation"
114
- )
115
- estimated_api_calls = gr.Number(
116
- label="Estimated Monthly API Calls",
117
- value=1000000,
118
- info="Required for Guardrails pricing calculation"
119
- )
120
-
121
- # Main tabs
122
- with gr.Tabs():
123
- # Organization Details
124
- with gr.Tab("🏢 Organization Details"):
125
- num_employees = gr.Slider(
126
- label="Number of Employees",
127
- minimum=1,
128
- maximum=5000,
129
- value=200,
130
- info="How many employees will use the solution?"
131
- )
132
- hours_saved_per_week = gr.Slider(
133
- label="Hours Saved per Week per Employee",
134
- minimum=0,
135
- maximum=40,
136
- value=6.3,
137
- info="Estimated time savings per employee"
138
- )
139
- hourly_wage = gr.Slider(
140
- label="Average Hourly Wage ($)",
141
- minimum=10,
142
- maximum=200,
143
- value=62,
144
- info="Average employee hourly compensation"
145
- )
146
-
147
- # Build Costs
148
- with gr.Tab("🔨 Build Costs"):
149
- initial_platform_cost = gr.Number(
150
- label="Initial Platform Development Cost ($)",
151
- value=1000000
152
- )
153
- with gr.Row():
154
- num_ai_hires = gr.Number(
155
- label="Number of AI Personnel",
156
- value=1
157
- )
158
- avg_salary = gr.Number(
159
- label="Average Annual Salary ($)",
160
- value=200000
161
- )
162
- with gr.Row():
163
- ai_maintenance_cost = gr.Number(
164
- label="Annual Maintenance Costs ($)",
165
- value=500000
166
- )
167
- ai_security_cost = gr.Number(
168
- label="Security & Compliance Costs ($)",
169
- value=250000
170
- )
171
-
172
- # Compliance
173
- with gr.Tab("🛡️ Compliance"):
174
- compliance_data = gr.Dataframe(
175
- value=default_compliance_df,
176
- headers=["Regulation", "Expected Violations", "Penalty", "Attorney Cost"],
177
- datatype="pandas",
178
- label="US Financial Regulations"
179
- )
180
-
181
- # Benefits
182
- with gr.Tab("📈 Benefits"):
183
- revenue_increase = gr.Number(
184
- label="Estimated Annual Revenue Increase ($)",
185
- value=50000,
186
- info="Projected revenue growth from AI implementation"
187
- )
188
-
189
- # Product Recommendation Display
190
- recommendation_box = gr.Markdown(elem_classes="recommendation-panel")
191
-
192
- # Calculate button
193
- calculate_button = gr.Button("Calculate ROI", elem_classes="primary-button")
194
-
195
- def update_recommendation(monthly_budget, deployment_type, existing_ai, num_employees):
196
- if deployment_type == "On-Premises":
197
- return """### 🏢 Enterprise (On-Premises)
198
- **Recommended Solution**: Full Enterprise Platform
199
- - Complete compliance controls
200
- - On-premises deployment
201
- - Dedicated support team
202
- - Custom integrations
203
- Price: Starting at $27,000/month"""
204
-
205
- if existing_ai == "Yes, we have existing AI applications" and monthly_budget <= 5000:
206
- return """### ⚡ Guardrails
207
- **Recommended Solution**: API-First Implementation
208
- - Pay-per-call pricing at $0.005/call
209
- - Perfect for existing AI applications
210
- - Quick API integration
211
- - Flexible scaling
212
- Estimated Cost: Based on API usage"""
213
-
214
- return """### 🚀 SaaS Platform
215
- **Recommended Solution**: Cloud Platform
216
- - $50 per user per month
217
- - Quick cloud deployment
218
- - Full platform features
219
- - Regular updates
220
- Estimated Monthly Cost: ${:,.2f}""".format(num_employees * 50)
221
-
222
- def update_results(*inputs):
223
- roi_build, roi_preamble, benefits, costs_build, costs_preamble = calculate_roi(*inputs)
224
-
225
- build_text = (
226
- f"### 🏗️ Building In-House\n"
227
- f"**ROI:** {roi_build:,.1f}%\n"
228
- f"**Total Costs:** ${costs_build:,.2f}\n"
229
- f"**Total Benefits:** ${benefits:,.2f}"
230
- )
231
-
232
- preamble_text = (
233
- f"### 🚀 Using Preamble\n"
234
- f"**ROI:** {roi_preamble:,.1f}%\n"
235
- f"**Total Costs:** ${costs_preamble:,.2f}\n"
236
- f"**Total Benefits:** ${benefits:,.2f}"
237
- )
238
-
239
- return build_text, preamble_text
240
-
241
- # Connect the recommendation update
242
- for input_elem in [monthly_budget, deployment_type, existing_ai, num_employees]:
243
- input_elem.change(
244
- fn=update_recommendation,
245
- inputs=[monthly_budget, deployment_type, existing_ai, num_employees],
246
- outputs=[recommendation_box]
247
- )
248
-
249
- # Connect the calculate button
250
- calculate_button.click(
251
- fn=update_results,
252
- inputs=[
253
- num_employees, hours_saved_per_week, hourly_wage,
254
- initial_platform_cost, num_ai_hires, avg_salary,
255
- ai_maintenance_cost, ai_security_cost,
256
- revenue_increase,
257
- monthly_budget, deployment_type, existing_ai, estimated_api_calls,
258
- compliance_data
259
- ],
260
- outputs=[build_roi_box, preamble_roi_box]
261
- )
262
 
263
  return roi_app
264
 
 
1
  import gradio as gr
2
  import pandas as pd
3
 
4
+ # Constants
5
  PREAMBLE_COLORS = {
6
  'light': '#081423',
7
  'yellow': '#1F2C6D',
 
10
  'dark': '#ECF0F6'
11
  }
12
 
13
+ # Define default compliance data at the top level
14
+ default_compliance_df = pd.DataFrame({
15
+ "Regulation": [
16
+ "SEC Reg S-P (Privacy)",
17
+ "GLBA (Financial)",
18
+ "FINRA Rules",
19
+ "Bank Secrecy Act",
20
+ "Dodd-Frank Act"
21
+ ],
22
+ "Expected Violations": [1, 1, 1, 1, 1],
23
+ "Penalty": [100000, 100000, 150000, 200000, 250000],
24
+ "Attorney Cost": [50000, 45000, 75000, 100000, 125000]
25
+ })
26
+
27
  CUSTOM_CSS = """
28
+ .gradio-container {
29
+ max-width: 1200px !important;
30
+ margin: auto !important;
31
+ padding: 2rem !important;
32
+ }
33
+
34
+ .header {
35
+ background-color: #081423;
36
+ padding: 1.5rem;
37
+ border-radius: 12px;
38
+ margin-bottom: 2rem;
39
+ }
40
+
41
+ .header h1 {
42
+ color: white;
43
+ }
44
+
45
+ .results-container {
46
+ background: linear-gradient(145deg, #4556E4, #1F2C6D);
47
+ border-radius: 12px;
48
+ padding: 1.5rem;
49
+ margin-bottom: 2rem;
50
+ color: white;
51
+ }
52
+
53
+ .primary-button {
54
+ background-color: #FFC700 !important;
55
+ color: #081423 !important;
56
+ }
57
+
58
  .recommendation-panel {
59
  background-color: rgba(69, 86, 228, 0.1);
60
  border-radius: 8px;
 
104
  if deployment_type == "On-Premises":
105
  total_costs_preamble = 27000 * 12 # Fixed cost for enterprise
106
  else: # Cloud/SaaS
107
+ if monthly_budget <= 5000: # Guardrails tier
108
  total_costs_preamble = estimated_api_calls * 0.005 * 12
109
  else: # SaaS tier
110
  total_costs_preamble = num_employees * 50 * 12 # $50 per user per month
 
117
 
118
  def create_app():
119
  with gr.Blocks(css=CUSTOM_CSS) as roi_app:
120
+ # Rest of the app code remains the same...
121
+ # [Previous implementation of create_app remains identical]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
  return roi_app
124