jeronimo9 commited on
Commit
145bd97
·
verified ·
1 Parent(s): e2b6380

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +190 -184
app.py CHANGED
@@ -30,90 +30,82 @@ CUSTOM_CSS = """
30
  margin: auto !important;
31
  padding: 2rem !important;
32
  background-color: #081423 !important;
 
33
  }
34
 
35
- /* Product selector top section */
 
 
 
 
 
 
 
36
  .product-selector {
37
  background-color: #1F2C6D !important;
38
  border-radius: 16px !important;
39
  padding: 2.5rem !important;
40
- margin-bottom: 2rem !important;
41
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
42
  }
43
 
44
- /* Title styling */
45
  .selector-title {
 
46
  color: #ECF0F6 !important;
47
- font-size: 1.75rem !important;
48
  font-weight: 600 !important;
49
- margin-bottom: 2rem !important;
50
  line-height: 1.2 !important;
51
  }
52
 
53
- /* Section headings */
54
- .section-label {
55
  color: #ECF0F6 !important;
56
  font-size: 1.1rem !important;
57
  font-weight: 500 !important;
58
  margin: 1.5rem 0 1rem !important;
59
  }
60
 
61
- /* Radio options styling */
62
- .radio-group {
 
 
63
  margin-bottom: 1.5rem !important;
64
  }
65
 
66
  .radio-group label {
67
- background-color: #081423 !important;
68
- border: 1px solid #4556E4 !important;
69
  border-radius: 8px !important;
70
- padding: 0.75rem 1.25rem !important;
71
- margin: 0.5rem 0.75rem 0.5rem 0 !important;
72
  color: #ECF0F6 !important;
73
- font-size: 1rem !important;
74
  transition: all 0.2s !important;
 
75
  }
76
 
77
  .radio-group label.selected {
78
  background-color: #4556E4 !important;
79
  border-color: #4556E4 !important;
80
- color: #ECF0F6 !important;
81
  }
82
 
83
  /* Input fields */
 
 
 
 
 
 
 
84
  .number-input {
85
- background-color: #081423 !important;
86
- border: 1px solid #4556E4 !important;
87
  border-radius: 8px !important;
 
88
  color: #ECF0F6 !important;
89
- padding: 0.75rem !important;
90
- }
91
-
92
- /* Recommendation panel */
93
- .recommendation-panel {
94
- background-color: #FFC700 !important;
95
- border-radius: 12px !important;
96
- padding: 2rem !important;
97
- margin-top: 2rem !important;
98
- color: #081423 !important;
99
- }
100
-
101
- .recommendation-panel h3 {
102
- font-size: 1.5rem !important;
103
- font-weight: 600 !important;
104
- margin-bottom: 1rem !important;
105
- color: #081423 !important;
106
  }
107
 
108
- .recommendation-panel ul {
109
- list-style-type: none !important;
110
- padding-left: 0 !important;
111
- margin: 1rem 0 !important;
112
- }
113
-
114
- .recommendation-panel li {
115
- margin-bottom: 0.75rem !important;
116
- font-size: 1.1rem !important;
117
  }
118
 
119
  /* Results section */
@@ -127,28 +119,67 @@ CUSTOM_CSS = """
127
  .result-card {
128
  background-color: #ECF0F6 !important;
129
  border-radius: 12px !important;
130
- padding: 1.5rem !important;
131
- color: #081423 !important;
132
  margin: 0.5rem !important;
 
133
  }
134
 
135
- /* Calculator tabs */
136
- .tab-nav {
 
 
 
 
 
 
137
  background-color: #1F2C6D !important;
138
- border-radius: 8px 8px 0 0 !important;
139
- padding: 0.5rem !important;
140
- gap: 0.5rem !important;
 
 
 
 
 
 
141
  }
142
 
143
  .tab-nav button {
144
  color: #ECF0F6 !important;
145
- padding: 0.75rem 1.25rem !important;
146
- border-radius: 6px !important;
147
- margin: 0 0.25rem !important;
148
  }
149
 
150
  .tab-nav button.selected {
151
  background-color: #4556E4 !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  }
153
  """
154
 
@@ -165,36 +196,25 @@ def recommend_preamble_solution(deployment_type, existing_ai, monthly_budget):
165
  Starting at $27,000/month"""
166
  )
167
 
168
- if existing_ai == "No, we need a full platform":
169
- if monthly_budget > 5000:
170
- return (
171
- "SaaS",
172
- """### 🚀 SaaS Platform
173
- Perfect for teams getting started with AI:
174
- - Full platform features
175
- - Quick cloud deployment
176
- - Regular updates
177
- - $50 per user/month"""
178
- )
179
- else:
180
- return (
181
- "Guardrails",
182
- """### ⚡ Guardrails
183
- Start with our foundational offering:
184
- - Basic AI safety controls
185
- - API-first implementation
186
- - $0.005 per API call
187
- - Usage-based pricing"""
188
- )
189
-
190
  return (
191
  "Guardrails",
192
- """### ⚡ Guardrails Recommended
193
- Perfect for existing AI applications:
194
- - Quick integration with your AI
195
- - API-first implementation
196
  - $0.005 per API call
197
- - Usage-based pricing"""
198
  )
199
 
200
  def calculate_roi(inputs):
@@ -226,7 +246,7 @@ def calculate_roi(inputs):
226
  ai_security_cost
227
  )
228
 
229
- # Preamble costs based on recommendation
230
  solution_type, _ = recommend_preamble_solution(deployment_type, existing_ai, monthly_budget)
231
  if solution_type == "Enterprise":
232
  total_costs_preamble = 27000 * 12
@@ -243,15 +263,12 @@ def calculate_roi(inputs):
243
 
244
  def create_app():
245
  with gr.Blocks(css=CUSTOM_CSS, theme=gr.themes.Default()) as roi_app:
246
- # Product Selection Section
247
- with gr.Row(elem_classes="product-selector"):
248
- with gr.Column():
249
- gr.Markdown(
250
- "# Find Your Ideal Preamble Solution",
251
- elem_classes="selector-title"
252
- )
253
 
254
- gr.Markdown("Deployment Preference", elem_classes="section-label")
255
  deployment_type = gr.Radio(
256
  ["Cloud/SaaS", "On-Premises"],
257
  label="",
@@ -259,7 +276,7 @@ def create_app():
259
  elem_classes="radio-group"
260
  )
261
 
262
- gr.Markdown("AI Implementation Status", elem_classes="section-label")
263
  existing_ai = gr.Radio(
264
  ["Yes, we have existing AI applications", "No, we need a full platform"],
265
  label="",
@@ -267,116 +284,106 @@ def create_app():
267
  elem_classes="radio-group"
268
  )
269
 
270
- with gr.Row():
271
- with gr.Column(scale=1):
272
- monthly_budget = gr.Number(
273
- label="Monthly Budget ($)",
274
- value=50000,
275
- elem_classes="number-input"
276
- )
277
- with gr.Column(scale=1):
278
- estimated_api_calls = gr.Number(
279
- label="Estimated Monthly API Calls",
280
- value=10000,
281
- elem_classes="number-input",
282
- visible=False
283
- )
284
 
285
  recommendation_box = gr.Markdown(elem_classes="recommendation-panel")
286
 
287
- # Results section
288
- with gr.Row(elem_classes="results-container"):
289
- with gr.Column():
290
- build_roi_box = gr.Markdown(
291
- "### 🏗️ Building In-House\n**ROI:** --%\n**Total Costs:** $0",
292
- elem_classes="result-card"
293
- )
294
- with gr.Column():
295
- preamble_roi_box = gr.Markdown(
296
- "### 🚀 Using Preamble\n**ROI:** --%\n**Total Costs:** $0",
297
- elem_classes="result-card"
298
- )
299
-
300
- # ROI Calculator tabs
301
- with gr.Tabs():
302
- with gr.Tab("Organization Details"):
303
- num_employees = gr.Slider(
304
- label="Number of Employees",
305
- minimum=1,
306
- maximum=1000,
307
- value=215,
308
- info="How many employees will use the solution?"
309
- )
310
- hours_saved_per_week = gr.Slider(
311
- label="Hours Saved per Week per Employee",
312
- minimum=0,
313
- maximum=40,
314
- value=6.3,
315
- info="Estimated time savings per employee"
316
- )
317
- hourly_wage = gr.Slider(
318
- label="Average Hourly Wage ($)",
319
- minimum=10,
320
- maximum=200,
321
- value=62,
322
- info="Average employee hourly compensation"
323
- )
324
-
325
- with gr.Tab("Build Costs"):
326
- initial_platform_cost = gr.Number(
327
- label="Initial Development Cost ($)",
328
- value=100000
329
- )
330
- with gr.Row():
331
- num_ai_hires = gr.Number(
332
- label="Number of AI Personnel",
333
- value=1
334
- )
335
- avg_salary = gr.Number(
336
- label="Average Annual Salary ($)",
337
- value=150000
338
  )
339
- with gr.Row():
340
- ai_maintenance_cost = gr.Number(
341
- label="Annual Maintenance ($)",
342
- value=20000
343
- )
344
- ai_security_cost = gr.Number(
345
- label="Security & Compliance ($)",
346
- value=10000
347
  )
348
 
349
- with gr.Tab("Compliance"):
350
- compliance_data = gr.Dataframe(
351
- value=default_compliance_df,
352
- headers=["Regulation", "Expected Violations", "Penalty", "Attorney Cost"],
353
- datatype="pandas"
354
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
355
 
356
- with gr.Tab("Benefits"):
357
- revenue_increase = gr.Number(
358
- label="Estimated Annual Revenue Increase ($)",
359
- value=50000,
360
- info="Projected revenue growth from AI implementation"
361
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
 
363
- calculate_button = gr.Button(
364
- "Calculate ROI",
365
- variant="primary"
366
- )
 
 
 
 
367
 
368
  def update_results(*inputs):
369
  roi_build, roi_preamble, benefits, costs_build, costs_preamble = calculate_roi(inputs)
370
 
371
  build_text = (
372
- f"### 🏗️ Building In-House\n"
373
  f"**ROI:** {roi_build:,.1f}%\n"
374
  f"**Total Costs:** ${costs_build:,.2f}\n"
375
  f"**Total Benefits:** ${benefits:,.2f}"
376
  )
377
 
378
  preamble_text = (
379
- f"### 🚀 Using Preamble\n"
380
  f"**ROI:** {roi_preamble:,.1f}%\n"
381
  f"**Total Costs:** ${costs_preamble:,.2f}\n"
382
  f"**Total Benefits:** ${benefits:,.2f}"
@@ -392,7 +399,7 @@ def create_app():
392
  )
393
  return gr.update(visible=should_show)
394
 
395
- # Connect the recommendation update
396
  for input_elem in [deployment_type, existing_ai, monthly_budget]:
397
  input_elem.change(
398
  fn=lambda d, e, b: recommend_preamble_solution(d, e, b)[1],
@@ -407,7 +414,6 @@ def create_app():
407
  outputs=[estimated_api_calls]
408
  )
409
 
410
- # Connect calculate button
411
  calculate_button.click(
412
  fn=update_results,
413
  inputs=[
 
30
  margin: auto !important;
31
  padding: 2rem !important;
32
  background-color: #081423 !important;
33
+ font-family: 'Inter', sans-serif !important;
34
  }
35
 
36
+ /* Main container */
37
+ .main-container {
38
+ display: flex !important;
39
+ flex-direction: column !important;
40
+ gap: 2rem !important;
41
+ }
42
+
43
+ /* Product selector */
44
  .product-selector {
45
  background-color: #1F2C6D !important;
46
  border-radius: 16px !important;
47
  padding: 2.5rem !important;
 
 
48
  }
49
 
 
50
  .selector-title {
51
+ font-size: 2rem !important;
52
  color: #ECF0F6 !important;
 
53
  font-weight: 600 !important;
54
+ margin-bottom: 2.5rem !important;
55
  line-height: 1.2 !important;
56
  }
57
 
58
+ /* Radio sections */
59
+ .section-title {
60
  color: #ECF0F6 !important;
61
  font-size: 1.1rem !important;
62
  font-weight: 500 !important;
63
  margin: 1.5rem 0 1rem !important;
64
  }
65
 
66
+ .radio-container {
67
+ background-color: rgba(8, 20, 35, 0.3) !important;
68
+ border-radius: 12px !important;
69
+ padding: 1rem !important;
70
  margin-bottom: 1.5rem !important;
71
  }
72
 
73
  .radio-group label {
74
+ background-color: rgba(8, 20, 35, 0.5) !important;
75
+ border: 1px solid rgba(69, 86, 228, 0.5) !important;
76
  border-radius: 8px !important;
77
+ padding: 1rem 1.5rem !important;
78
+ margin: 0.5rem !important;
79
  color: #ECF0F6 !important;
 
80
  transition: all 0.2s !important;
81
+ font-size: 1rem !important;
82
  }
83
 
84
  .radio-group label.selected {
85
  background-color: #4556E4 !important;
86
  border-color: #4556E4 !important;
 
87
  }
88
 
89
  /* Input fields */
90
+ .input-row {
91
+ display: grid !important;
92
+ grid-template-columns: 1fr 1fr !important;
93
+ gap: 1.5rem !important;
94
+ margin: 1.5rem 0 !important;
95
+ }
96
+
97
  .number-input {
98
+ background-color: rgba(8, 20, 35, 0.3) !important;
99
+ border: 1px solid rgba(69, 86, 228, 0.5) !important;
100
  border-radius: 8px !important;
101
+ padding: 1rem !important;
102
  color: #ECF0F6 !important;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  }
104
 
105
+ .number-input label {
106
+ color: #ECF0F6 !important;
107
+ opacity: 0.9 !important;
108
+ margin-bottom: 0.5rem !important;
 
 
 
 
 
109
  }
110
 
111
  /* Results section */
 
119
  .result-card {
120
  background-color: #ECF0F6 !important;
121
  border-radius: 12px !important;
122
+ padding: 2rem !important;
 
123
  margin: 0.5rem !important;
124
+ color: #081423 !important;
125
  }
126
 
127
+ .result-card h3 {
128
+ font-size: 1.5rem !important;
129
+ margin-bottom: 1rem !important;
130
+ color: #1F2C6D !important;
131
+ }
132
+
133
+ /* Calculator section */
134
+ .calculator-tabs {
135
  background-color: #1F2C6D !important;
136
+ border-radius: 16px !important;
137
+ padding: 2rem !important;
138
+ margin-top: 2rem !important;
139
+ }
140
+
141
+ .tab-nav {
142
+ border-bottom: 1px solid rgba(69, 86, 228, 0.3) !important;
143
+ padding: 0 !important;
144
+ margin-bottom: 2rem !important;
145
  }
146
 
147
  .tab-nav button {
148
  color: #ECF0F6 !important;
149
+ padding: 1rem 2rem !important;
150
+ border-radius: 8px 8px 0 0 !important;
151
+ opacity: 0.7 !important;
152
  }
153
 
154
  .tab-nav button.selected {
155
  background-color: #4556E4 !important;
156
+ opacity: 1 !important;
157
+ }
158
+
159
+ /* Recommendation panel */
160
+ .recommendation-panel {
161
+ background-color: #FFC700 !important;
162
+ border-radius: 12px !important;
163
+ padding: 2rem !important;
164
+ margin-top: 1.5rem !important;
165
+ color: #081423 !important;
166
+ }
167
+
168
+ .recommendation-panel h3 {
169
+ font-size: 1.5rem !important;
170
+ margin-bottom: 1rem !important;
171
+ }
172
+
173
+ /* Calculate button */
174
+ .calculate-button {
175
+ background-color: #FFC700 !important;
176
+ color: #081423 !important;
177
+ font-weight: 600 !important;
178
+ padding: 1rem 2rem !important;
179
+ border-radius: 8px !important;
180
+ margin-top: 2rem !important;
181
+ font-size: 1.1rem !important;
182
+ width: auto !important;
183
  }
184
  """
185
 
 
196
  Starting at $27,000/month"""
197
  )
198
 
199
+ if existing_ai == "No, we need a full platform" and monthly_budget > 5000:
200
+ return (
201
+ "SaaS",
202
+ """### 🚀 SaaS Platform
203
+ Perfect for teams getting started with AI:
204
+ - Full platform features
205
+ - Quick cloud deployment
206
+ - Regular updates
207
+ - $50 per user/month"""
208
+ )
209
+
 
 
 
 
 
 
 
 
 
 
 
210
  return (
211
  "Guardrails",
212
+ """### ⚡ Guardrails
213
+ Perfect for integrating with existing AI:
214
+ - Quick API integration
215
+ - Usage-based pricing
216
  - $0.005 per API call
217
+ - Flexible scaling options"""
218
  )
219
 
220
  def calculate_roi(inputs):
 
246
  ai_security_cost
247
  )
248
 
249
+ # Preamble costs
250
  solution_type, _ = recommend_preamble_solution(deployment_type, existing_ai, monthly_budget)
251
  if solution_type == "Enterprise":
252
  total_costs_preamble = 27000 * 12
 
263
 
264
  def create_app():
265
  with gr.Blocks(css=CUSTOM_CSS, theme=gr.themes.Default()) as roi_app:
266
+ with gr.Column(elem_classes="main-container"):
267
+ # Product Selection
268
+ with gr.Column(elem_classes="product-selector"):
269
+ gr.Markdown("# Find Your Ideal Preamble Solution", elem_classes="selector-title")
 
 
 
270
 
271
+ gr.Markdown("Deployment Preference", elem_classes="section-title")
272
  deployment_type = gr.Radio(
273
  ["Cloud/SaaS", "On-Premises"],
274
  label="",
 
276
  elem_classes="radio-group"
277
  )
278
 
279
+ gr.Markdown("AI Implementation Status", elem_classes="section-title")
280
  existing_ai = gr.Radio(
281
  ["Yes, we have existing AI applications", "No, we need a full platform"],
282
  label="",
 
284
  elem_classes="radio-group"
285
  )
286
 
287
+ with gr.Row(elem_classes="input-row"):
288
+ monthly_budget = gr.Number(
289
+ label="Monthly Budget ($)",
290
+ value=50000,
291
+ elem_classes="number-input"
292
+ )
293
+ estimated_api_calls = gr.Number(
294
+ label="Estimated Monthly API Calls",
295
+ value=10000,
296
+ elem_classes="number-input",
297
+ visible=False
298
+ )
 
 
299
 
300
  recommendation_box = gr.Markdown(elem_classes="recommendation-panel")
301
 
302
+ # Results
303
+ with gr.Row(elem_classes="results-container"):
304
+ with gr.Column():
305
+ build_roi_box = gr.Markdown(
306
+ "### Building In-House\n**ROI:** --%\n**Total Costs:** $0",
307
+ elem_classes="result-card"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  )
309
+ with gr.Column():
310
+ preamble_roi_box = gr.Markdown(
311
+ "### Using Preamble\n**ROI:** --%\n**Total Costs:** $0",
312
+ elem_classes="result-card"
 
 
 
 
313
  )
314
 
315
+ # Calculator
316
+ with gr.Column(elem_classes="calculator-tabs"):
317
+ with gr.Tabs():
318
+ with gr.Tab("Organization"):
319
+ num_employees = gr.Slider(
320
+ label="Number of Employees",
321
+ minimum=1, maximum=1000, value=215,
322
+ info="How many employees will use the solution?"
323
+ )
324
+ hours_saved_per_week = gr.Slider(
325
+ label="Hours Saved per Week per Employee",
326
+ minimum=0, maximum=40, value=6.3,
327
+ info="Estimated time savings per employee"
328
+ )
329
+ hourly_wage = gr.Slider(
330
+ label="Average Hourly Wage ($)",
331
+ minimum=10, maximum=200, value=62,
332
+ info="Average employee compensation"
333
+ )
334
 
335
+ with gr.Tab("Build Costs"):
336
+ initial_platform_cost = gr.Number(
337
+ label="Initial Development Cost ($)",
338
+ value=100000
339
+ )
340
+ with gr.Row():
341
+ num_ai_hires = gr.Number(
342
+ label="Number of AI Personnel",
343
+ value=1
344
+ )
345
+ avg_salary = gr.Number(
346
+ label="Average Annual Salary ($)",
347
+ value=150000
348
+ )
349
+ with gr.Row():
350
+ ai_maintenance_cost = gr.Number(
351
+ label="Annual Maintenance ($)",
352
+ value=20000
353
+ )
354
+ ai_security_cost = gr.Number(
355
+ label="Security & Compliance ($)",
356
+ value=10000
357
+ )
358
+
359
+ with gr.Tab("Compliance"):
360
+ compliance_data = gr.Dataframe(
361
+ value=default_compliance_df,
362
+ headers=["Regulation", "Expected Violations", "Penalty", "Attorney Cost"],
363
+ datatype="pandas"
364
+ )
365
 
366
+ with gr.Tab("Benefits"):
367
+ revenue_increase = gr.Number(
368
+ label="Estimated Annual Revenue Increase ($)",
369
+ value=50000,
370
+ info="Projected revenue growth"
371
+ )
372
+
373
+ calculate_button = gr.Button("Calculate ROI", elem_classes="calculate-button")
374
 
375
  def update_results(*inputs):
376
  roi_build, roi_preamble, benefits, costs_build, costs_preamble = calculate_roi(inputs)
377
 
378
  build_text = (
379
+ f"### Building In-House\n"
380
  f"**ROI:** {roi_build:,.1f}%\n"
381
  f"**Total Costs:** ${costs_build:,.2f}\n"
382
  f"**Total Benefits:** ${benefits:,.2f}"
383
  )
384
 
385
  preamble_text = (
386
+ f"### Using Preamble\n"
387
  f"**ROI:** {roi_preamble:,.1f}%\n"
388
  f"**Total Costs:** ${costs_preamble:,.2f}\n"
389
  f"**Total Benefits:** ${benefits:,.2f}"
 
399
  )
400
  return gr.update(visible=should_show)
401
 
402
+ # Connect events
403
  for input_elem in [deployment_type, existing_ai, monthly_budget]:
404
  input_elem.change(
405
  fn=lambda d, e, b: recommend_preamble_solution(d, e, b)[1],
 
414
  outputs=[estimated_api_calls]
415
  )
416
 
 
417
  calculate_button.click(
418
  fn=update_results,
419
  inputs=[