jeronimo9 commited on
Commit
c495880
·
verified ·
1 Parent(s): 3ca015f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +233 -124
app.py CHANGED
@@ -1,13 +1,13 @@
1
  import gradio as gr
2
  import pandas as pd
3
 
4
- # Preamble brand colors from the brand guide
5
  BRAND_COLORS = {
6
- 'light_gray': '#081423',
7
- 'yellow': '#1F2C6D',
8
- 'blue': '#4556E4',
9
- 'navy': '#FFC700',
10
- 'dark_gray': '#ECF0F6'
11
  }
12
 
13
  # Default compliance data
@@ -30,51 +30,114 @@ CUSTOM_CSS = """
30
  margin: auto !important;
31
  padding: 2rem !important;
32
  background-color: #081423 !important;
 
 
 
 
 
 
 
 
 
 
 
33
  color: #ECF0F6 !important;
 
 
 
34
  }
35
 
36
- .header {
37
- background-color: #4556E4;
38
- padding: 1.5rem;
39
- border-radius: 12px;
40
- margin-bottom: 2rem;
 
 
 
41
  }
42
 
43
- .product-selector {
44
- background: #1F2C6D;
45
- border-radius: 12px;
46
- padding: 1.5rem;
47
- margin-bottom: 2rem;
48
  }
49
 
50
- .results-container {
51
- background: #4556E4;
52
- border-radius: 12px;
53
- padding: 1.5rem;
54
- margin-bottom: 2rem;
 
 
 
 
 
 
 
55
  }
56
 
57
- .primary-button {
 
58
  background-color: #FFC700 !important;
 
 
 
 
 
 
59
  color: #081423 !important;
60
- font-weight: bold !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
 
63
  .result-card {
64
- background-color: #ECF0F6;
65
- color: #081423;
66
- border-radius: 8px;
67
- padding: 1rem;
68
- margin: 0.5rem;
69
  }
70
 
71
- .recommendation-panel {
72
- background-color: #FFC700;
73
- color: #081423;
74
- border-radius: 8px;
75
- padding: 1rem;
76
- margin-top: 1rem;
77
- font-weight: bold;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  }
79
  """
80
 
@@ -88,36 +151,48 @@ def recommend_preamble_solution(deployment_type, existing_ai, monthly_budget):
88
  - If has existing AI -> Recommend Guardrails first
89
  """
90
  if deployment_type == "On-Premises":
91
- return ("Enterprise", """### 🏢 Enterprise License
92
- **Perfect for organizations that need:**
93
- - On-premises deployment
94
- - Complete compliance controls
95
- - Dedicated support team
96
- - Custom integrations
97
- Starting at $27,000/month""")
 
 
 
98
 
99
  if existing_ai == "No, we need a full platform":
100
  if monthly_budget > 5000:
101
- return ("SaaS", """### 🚀 SaaS Platform
102
- **Perfect for teams getting started with AI:**
103
- - Full platform features
104
- - Quick cloud deployment
105
- - Regular updates
106
- - $50 per user/month""")
 
 
 
107
  else:
108
- return ("Guardrails", """### ⚡ Guardrails
109
- **Start with our foundational offering:**
110
- - Basic AI safety controls
111
- - API-first implementation
112
- - $0.005 per API call
113
- - Usage-based pricing""")
 
 
 
114
 
115
- return ("Guardrails", """### ⚡ Guardrails Recommended
116
- **Perfect for existing AI applications:**
117
- - Quick integration with your AI
118
- - API-first implementation
119
- - $0.005 per API call
120
- - Usage-based pricing""")
 
 
 
121
 
122
  def calculate_roi(inputs):
123
  [num_employees, hours_saved_per_week, hourly_wage,
@@ -127,7 +202,7 @@ def calculate_roi(inputs):
127
  monthly_budget, deployment_type, existing_ai, estimated_api_calls,
128
  compliance_data] = inputs
129
 
130
- # Calculate savings and costs
131
  total_hours_saved = num_employees * hours_saved_per_week * 52
132
  labor_cost_savings = total_hours_saved * hourly_wage
133
 
@@ -142,13 +217,13 @@ def calculate_roi(inputs):
142
 
143
  # In-house costs
144
  total_costs_build = (
145
- initial_platform_cost +
146
- (num_ai_hires * avg_salary) +
147
- ai_maintenance_cost +
148
  ai_security_cost
149
  )
150
 
151
- # Preamble costs
152
  solution_type, _ = recommend_preamble_solution(deployment_type, existing_ai, monthly_budget)
153
  if solution_type == "Enterprise":
154
  total_costs_preamble = 27000 * 12
@@ -164,74 +239,105 @@ def calculate_roi(inputs):
164
  return roi_build, roi_preamble, total_benefits, total_costs_build, total_costs_preamble
165
 
166
  def create_app():
167
- with gr.Blocks(css=CUSTOM_CSS, theme=gr.themes.Soft(primary_hue="blue")) as roi_app:
168
- # Header
169
- with gr.Row(elem_classes="header"):
170
- gr.Markdown(
171
- "# 📊 Preamble AI ROI Calculator\n"
172
- "[Visit Preamble.com](https://preamble.com) to learn more"
 
 
 
 
 
173
  )
174
-
175
- # Product Selection
176
- with gr.Row(elem_classes="product-selector"):
177
- with gr.Column():
178
- gr.Markdown("## Find Your Ideal Preamble Solution")
179
- deployment_type = gr.Radio(
180
- ["Cloud/SaaS", "On-Premises"],
181
- label="Deployment Preference",
182
- value="Cloud/SaaS"
183
- )
184
- existing_ai = gr.Radio(
185
- ["Yes, we have existing AI applications", "No, we need a full platform"],
186
- label="AI Implementation Status",
187
- value="No, we need a full platform"
188
- )
189
- monthly_budget = gr.Number(
190
- label="Monthly Budget ($)",
191
- value=5000
192
- )
193
- estimated_api_calls = gr.Number(
194
- label="Estimated Monthly API Calls",
195
- value=10000,
196
- visible=False
197
- )
198
- recommendation_box = gr.Markdown(elem_classes="recommendation-panel")
199
 
200
- # Results section
201
- with gr.Row(elem_classes="results-container"):
202
- with gr.Column():
203
- build_roi_box = gr.Markdown(
204
- "### Building In-House\n**ROI:** --%\n**Total Costs:** $0",
205
- elem_classes="result-card"
206
- )
207
- with gr.Column():
208
- preamble_roi_box = gr.Markdown(
209
- "### Using Preamble\n**ROI:** --%\n**Total Costs:** $0",
210
- elem_classes="result-card"
211
- )
 
 
 
 
 
 
 
 
 
 
 
212
 
213
- # Calculator Inputs
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  with gr.Tabs():
215
  with gr.Tab("Organization Details"):
216
  num_employees = gr.Slider(
217
  label="Number of Employees",
218
- minimum=1, maximum=1000, value=215
 
 
 
219
  )
220
  hours_saved_per_week = gr.Slider(
221
  label="Hours Saved per Week per Employee",
222
- minimum=0, maximum=40, value=6.3
 
 
 
223
  )
224
  hourly_wage = gr.Slider(
225
  label="Average Hourly Wage ($)",
226
- minimum=10, maximum=200, value=62
 
 
 
227
  )
228
 
229
  with gr.Tab("Build Costs"):
230
- initial_platform_cost = gr.Number(label="Initial Development Cost ($)", value=100000)
231
- num_ai_hires = gr.Number(label="Number of AI Hires", value=1)
232
- avg_salary = gr.Number(label="Average Annual Salary ($)", value=150000)
233
- ai_maintenance_cost = gr.Number(label="Annual Maintenance ($)", value=20000)
234
- ai_security_cost = gr.Number(label="Security & Compliance ($)", value=10000)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
 
236
  with gr.Tab("Compliance"):
237
  compliance_data = gr.Dataframe(
@@ -243,10 +349,15 @@ def create_app():
243
  with gr.Tab("Benefits"):
244
  revenue_increase = gr.Number(
245
  label="Estimated Annual Revenue Increase ($)",
246
- value=50000
 
247
  )
248
 
249
- calculate_button = gr.Button("Calculate ROI", elem_classes="primary-button")
 
 
 
 
250
 
251
  def update_results(*inputs):
252
  roi_build, roi_preamble, benefits, costs_build, costs_preamble = calculate_roi(inputs)
@@ -268,15 +379,14 @@ def create_app():
268
  return build_text, preamble_text
269
 
270
  def update_api_calls_visibility(existing_ai, deployment_type):
271
- # Show API calls input only for Guardrails candidates
272
  should_show = (
273
- deployment_type != "On-Premises" and
274
- (existing_ai == "Yes, we have existing AI applications" or
275
  monthly_budget <= 5000)
276
  )
277
  return gr.update(visible=should_show)
278
 
279
- # Update recommendation when inputs change
280
  for input_elem in [deployment_type, existing_ai, monthly_budget]:
281
  input_elem.change(
282
  fn=lambda d, e, b: recommend_preamble_solution(d, e, b)[1],
@@ -284,7 +394,6 @@ def create_app():
284
  outputs=[recommendation_box]
285
  )
286
 
287
- # Update API calls visibility
288
  if input_elem in [deployment_type, existing_ai]:
289
  input_elem.change(
290
  fn=update_api_calls_visibility,
 
1
  import gradio as gr
2
  import pandas as pd
3
 
4
+ # Corrected Preamble brand colors
5
  BRAND_COLORS = {
6
+ 'dark_navy': '#081423', # Dark background
7
+ 'navy': '#1F2C6D', # Section backgrounds
8
+ 'light_blue': '#4556E4', # Interactive elements
9
+ 'yellow': '#FFC700', # Highlights and CTAs
10
+ 'light_gray': '#ECF0F6' # Text and borders
11
  }
12
 
13
  # Default compliance data
 
30
  margin: auto !important;
31
  padding: 2rem !important;
32
  background-color: #081423 !important;
33
+ }
34
+
35
+ /* Product selector styling */
36
+ .product-selector {
37
+ background-color: #1F2C6D !important;
38
+ border-radius: 16px !important;
39
+ padding: 2rem !important;
40
+ margin-bottom: 2rem !important;
41
+ }
42
+
43
+ .product-selector h2 {
44
  color: #ECF0F6 !important;
45
+ font-size: 1.5rem !important;
46
+ margin-bottom: 1.5rem !important;
47
+ font-weight: 600 !important;
48
  }
49
 
50
+ /* Radio button styling */
51
+ .radio-group label {
52
+ background-color: #081423 !important;
53
+ border-radius: 8px !important;
54
+ padding: 0.75rem 1.25rem !important;
55
+ margin-right: 0.5rem !important;
56
+ color: #ECF0F6 !important;
57
+ transition: all 0.2s !important;
58
  }
59
 
60
+ .radio-group label.selected {
61
+ background-color: #4556E4 !important;
62
+ color: white !important;
 
 
63
  }
64
 
65
+ /* Input field styling */
66
+ .input-field {
67
+ background-color: #081423 !important;
68
+ border-radius: 8px !important;
69
+ padding: 1rem !important;
70
+ margin-bottom: 1rem !important;
71
+ }
72
+
73
+ .input-field label {
74
+ color: #4556E4 !important;
75
+ font-weight: 500 !important;
76
+ margin-bottom: 0.5rem !important;
77
  }
78
 
79
+ /* Recommendation panel */
80
+ .recommendation-panel {
81
  background-color: #FFC700 !important;
82
+ border-radius: 12px !important;
83
+ padding: 1.5rem !important;
84
+ margin-top: 1.5rem !important;
85
+ }
86
+
87
+ .recommendation-panel h3 {
88
  color: #081423 !important;
89
+ font-size: 1.25rem !important;
90
+ font-weight: 600 !important;
91
+ margin-bottom: 1rem !important;
92
+ }
93
+
94
+ .recommendation-panel ul {
95
+ color: #081423 !important;
96
+ list-style-type: none !important;
97
+ padding-left: 0 !important;
98
+ }
99
+
100
+ .recommendation-panel li {
101
+ margin-bottom: 0.5rem !important;
102
+ }
103
+
104
+ /* Results section */
105
+ .results-container {
106
+ background-color: #4556E4 !important;
107
+ border-radius: 16px !important;
108
+ padding: 2rem !important;
109
+ margin-top: 2rem !important;
110
  }
111
 
112
  .result-card {
113
+ background-color: #ECF0F6 !important;
114
+ border-radius: 12px !important;
115
+ padding: 1.5rem !important;
116
+ color: #081423 !important;
 
117
  }
118
 
119
+ /* Tab styling */
120
+ .tab-nav {
121
+ background-color: #1F2C6D !important;
122
+ border-radius: 8px 8px 0 0 !important;
123
+ padding: 0.5rem !important;
124
+ }
125
+
126
+ .tab-nav button {
127
+ color: #ECF0F6 !important;
128
+ padding: 0.75rem 1.25rem !important;
129
+ border-radius: 6px !important;
130
+ }
131
+
132
+ .tab-nav button.selected {
133
+ background-color: #4556E4 !important;
134
+ }
135
+
136
+ /* Input label styling */
137
+ .input-label {
138
+ color: #4556E4 !important;
139
+ font-weight: 500 !important;
140
+ margin-bottom: 0.25rem !important;
141
  }
142
  """
143
 
 
151
  - If has existing AI -> Recommend Guardrails first
152
  """
153
  if deployment_type == "On-Premises":
154
+ return (
155
+ "Enterprise",
156
+ """### 🏢 Enterprise License
157
+ **Perfect for organizations that need:**
158
+ - On-premises deployment
159
+ - Complete compliance controls
160
+ - Dedicated support team
161
+ - Custom integrations
162
+ Starting at $27,000/month"""
163
+ )
164
 
165
  if existing_ai == "No, we need a full platform":
166
  if monthly_budget > 5000:
167
+ return (
168
+ "SaaS",
169
+ """### 🚀 SaaS Platform
170
+ **Perfect for teams getting started with AI:**
171
+ - Full platform features
172
+ - Quick cloud deployment
173
+ - Regular updates
174
+ - $50 per user/month"""
175
+ )
176
  else:
177
+ return (
178
+ "Guardrails",
179
+ """### Guardrails
180
+ **Start with our foundational offering:**
181
+ - Basic AI safety controls
182
+ - API-first implementation
183
+ - $0.005 per API call
184
+ - Usage-based pricing"""
185
+ )
186
 
187
+ return (
188
+ "Guardrails",
189
+ """### Guardrails Recommended
190
+ **Perfect for existing AI applications:**
191
+ - Quick integration with your AI
192
+ - API-first implementation
193
+ - $0.005 per API call
194
+ - Usage-based pricing"""
195
+ )
196
 
197
  def calculate_roi(inputs):
198
  [num_employees, hours_saved_per_week, hourly_wage,
 
202
  monthly_budget, deployment_type, existing_ai, estimated_api_calls,
203
  compliance_data] = inputs
204
 
205
+ # Annual labor savings
206
  total_hours_saved = num_employees * hours_saved_per_week * 52
207
  labor_cost_savings = total_hours_saved * hourly_wage
208
 
 
217
 
218
  # In-house costs
219
  total_costs_build = (
220
+ initial_platform_cost +
221
+ (num_ai_hires * avg_salary) +
222
+ ai_maintenance_cost +
223
  ai_security_cost
224
  )
225
 
226
+ # Preamble costs based on recommendation
227
  solution_type, _ = recommend_preamble_solution(deployment_type, existing_ai, monthly_budget)
228
  if solution_type == "Enterprise":
229
  total_costs_preamble = 27000 * 12
 
239
  return roi_build, roi_preamble, total_benefits, total_costs_build, total_costs_preamble
240
 
241
  def create_app():
242
+ with gr.Blocks(css=CUSTOM_CSS, theme=gr.themes.Default()) as roi_app:
243
+ # Product Selection Section
244
+ with gr.Box(elem_classes="product-selector"):
245
+ gr.Markdown("# Find Your Ideal Preamble Solution")
246
+
247
+ gr.Markdown("### Deployment Preference", elem_classes="input-label")
248
+ deployment_type = gr.Radio(
249
+ ["Cloud/SaaS", "On-Premises"],
250
+ label="",
251
+ value="Cloud/SaaS",
252
+ elem_classes="radio-group"
253
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
 
255
+ gr.Markdown("### AI Implementation Status", elem_classes="input-label")
256
+ existing_ai = gr.Radio(
257
+ ["Yes, we have existing AI applications", "No, we need a full platform"],
258
+ label="",
259
+ value="Yes, we have existing AI applications",
260
+ elem_classes="radio-group"
261
+ )
262
+
263
+ with gr.Row():
264
+ with gr.Column():
265
+ monthly_budget = gr.Number(
266
+ label="Monthly Budget ($)",
267
+ value=5000,
268
+ elem_classes="input-field"
269
+ )
270
+ with gr.Column():
271
+ estimated_api_calls = gr.Number(
272
+ label="Estimated Monthly API Calls",
273
+ value=10000,
274
+ elem_classes="input-field"
275
+ )
276
+
277
+ recommendation_box = gr.Markdown(elem_classes="recommendation-panel")
278
 
279
+ # Results section
280
+ with gr.Box(elem_classes="results-container"):
281
+ with gr.Row():
282
+ with gr.Column():
283
+ build_roi_box = gr.Markdown(
284
+ "### 🏗️ Building In-House\n**ROI:** --%\n**Total Costs:** $0",
285
+ elem_classes="result-card"
286
+ )
287
+ with gr.Column():
288
+ preamble_roi_box = gr.Markdown(
289
+ "### 🚀 Using Preamble\n**ROI:** --%\n**Total Costs:** $0",
290
+ elem_classes="result-card"
291
+ )
292
+
293
+ # ROI Calculator tabs
294
  with gr.Tabs():
295
  with gr.Tab("Organization Details"):
296
  num_employees = gr.Slider(
297
  label="Number of Employees",
298
+ minimum=1,
299
+ maximum=1000,
300
+ value=215,
301
+ info="How many employees will use the solution?"
302
  )
303
  hours_saved_per_week = gr.Slider(
304
  label="Hours Saved per Week per Employee",
305
+ minimum=0,
306
+ maximum=40,
307
+ value=6.3,
308
+ info="Estimated time savings per employee"
309
  )
310
  hourly_wage = gr.Slider(
311
  label="Average Hourly Wage ($)",
312
+ minimum=10,
313
+ maximum=200,
314
+ value=62,
315
+ info="Average employee hourly compensation"
316
  )
317
 
318
  with gr.Tab("Build Costs"):
319
+ initial_platform_cost = gr.Number(
320
+ label="Initial Development Cost ($)",
321
+ value=100000
322
+ )
323
+ with gr.Row():
324
+ num_ai_hires = gr.Number(
325
+ label="Number of AI Personnel",
326
+ value=1
327
+ )
328
+ avg_salary = gr.Number(
329
+ label="Average Annual Salary ($)",
330
+ value=150000
331
+ )
332
+ with gr.Row():
333
+ ai_maintenance_cost = gr.Number(
334
+ label="Annual Maintenance ($)",
335
+ value=20000
336
+ )
337
+ ai_security_cost = gr.Number(
338
+ label="Security & Compliance ($)",
339
+ value=10000
340
+ )
341
 
342
  with gr.Tab("Compliance"):
343
  compliance_data = gr.Dataframe(
 
349
  with gr.Tab("Benefits"):
350
  revenue_increase = gr.Number(
351
  label="Estimated Annual Revenue Increase ($)",
352
+ value=50000,
353
+ info="Projected revenue growth from AI implementation"
354
  )
355
 
356
+ calculate_button = gr.Button(
357
+ "Calculate ROI",
358
+ variant="primary",
359
+ elem_classes="primary-button"
360
+ )
361
 
362
  def update_results(*inputs):
363
  roi_build, roi_preamble, benefits, costs_build, costs_preamble = calculate_roi(inputs)
 
379
  return build_text, preamble_text
380
 
381
  def update_api_calls_visibility(existing_ai, deployment_type):
 
382
  should_show = (
383
+ deployment_type != "On-Premises" and
384
+ (existing_ai == "Yes, we have existing AI applications" or
385
  monthly_budget <= 5000)
386
  )
387
  return gr.update(visible=should_show)
388
 
389
+ # Connect the recommendation update
390
  for input_elem in [deployment_type, existing_ai, monthly_budget]:
391
  input_elem.change(
392
  fn=lambda d, e, b: recommend_preamble_solution(d, e, b)[1],
 
394
  outputs=[recommendation_box]
395
  )
396
 
 
397
  if input_elem in [deployment_type, existing_ai]:
398
  input_elem.change(
399
  fn=update_api_calls_visibility,