jeronimo9 commited on
Commit
fb75cfa
Β·
verified Β·
1 Parent(s): dd70864

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +134 -244
app.py CHANGED
@@ -1,48 +1,35 @@
1
  import gradio as gr
2
  import pandas as pd
3
 
4
- # Constants
5
  PREAMBLE_COLORS = {
6
- 'light': '#081423',
7
- 'yellow': '#1F2C6D',
8
- 'blue': '#4556E4',
9
- 'navy': '#FFC700',
10
- 'dark': '#ECF0F6'
11
  }
12
 
13
- # Define default compliance data
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;
@@ -50,97 +37,72 @@ CUSTOM_CSS = """
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;
61
  padding: 1rem;
62
- margin-top: 1rem;
 
63
  }
64
- """
65
 
66
- def calculate_roi(
67
- num_employees, hours_saved_per_week, hourly_wage,
68
- initial_platform_cost, num_ai_hires, avg_salary,
69
- ai_maintenance_cost, ai_security_cost,
70
- revenue_increase,
71
- monthly_budget, deployment_type, existing_ai, estimated_api_calls,
72
- compliance_data
73
- ):
74
- # Annual labor savings
75
- total_hours_saved = num_employees * hours_saved_per_week * 52
76
- labor_cost_savings = total_hours_saved * hourly_wage
77
 
78
- # Calculate compliance savings
79
- compliance_savings = 0
80
- if compliance_data is not None:
81
- try:
82
- if isinstance(compliance_data, pd.DataFrame):
83
- df = compliance_data
84
- else:
85
- df = pd.DataFrame(compliance_data)
86
- for index, row in df.iterrows():
87
- try:
88
- violations = float(row["Expected Violations"])
89
- penalty = float(row["Penalty"])
90
- attorney = float(row["Attorney Cost"])
91
- compliance_savings += violations * (penalty + attorney)
92
- except Exception:
93
- continue
94
- except Exception:
95
- compliance_savings = 0
96
 
97
- # Total benefits
98
- total_benefits = labor_cost_savings + revenue_increase + compliance_savings
 
 
 
99
 
100
- # Calculate costs for building in-house
101
- total_costs_build = initial_platform_cost + (num_ai_hires * avg_salary) + ai_maintenance_cost + ai_security_cost
 
102
 
103
- # Calculate Preamble costs based on selected options
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
111
 
112
- # ROI calculations
113
- roi_build = ((total_benefits - total_costs_build) / total_costs_build) * 100 if total_costs_build else 0
114
- roi_preamble = ((total_benefits - total_costs_preamble) / total_costs_preamble) * 100 if total_costs_preamble else 0
 
 
 
 
115
 
116
- return roi_build, roi_preamble, total_benefits, total_costs_build, total_costs_preamble
 
 
 
 
 
 
 
 
 
117
 
118
- def update_recommendation(monthly_budget, deployment_type, existing_ai, num_employees):
119
- if deployment_type == "On-Premises":
120
- return """### 🏒 Enterprise (On-Premises)
121
- **Recommended Solution**: Full Enterprise Platform
122
- - Complete compliance controls
123
- - On-premises deployment
124
- - Dedicated support team
125
- - Custom integrations
126
- Price: Starting at $27,000/month"""
127
-
128
- if existing_ai == "Yes, we have existing AI applications" and monthly_budget <= 5000:
129
- return """### ⚑ Guardrails
130
- **Recommended Solution**: API-First Implementation
131
- - Pay-per-call pricing at $0.005/call
132
- - Perfect for existing AI applications
133
- - Quick API integration
134
- - Flexible scaling
135
- Estimated Cost: Based on API usage"""
136
-
137
- return """### πŸš€ SaaS Platform
138
- **Recommended Solution**: Cloud Platform
139
- - $50 per user per month
140
- - Quick cloud deployment
141
- - Full platform features
142
- - Regular updates
143
- Estimated Monthly Cost: ${:,.2f}""".format(num_employees * 50)
144
 
145
  def create_app():
146
  with gr.Blocks(css=CUSTOM_CSS, theme=gr.themes.Soft(primary_hue="orange")) as roi_app:
@@ -151,160 +113,88 @@ def create_app():
151
  "[Visit Preamble.com](https://preamble.com) to learn more"
152
  )
153
 
154
- # Results section
155
- with gr.Row(elem_classes="results-container"):
156
  with gr.Column():
157
- build_roi_box = gr.Markdown(
158
- "### πŸ—οΈ Building In-House\n**ROI:** 0%\n**Total Costs:** $0"
159
- )
160
- with gr.Column():
161
- preamble_roi_box = gr.Markdown(
162
- "### πŸš€ Using Preamble\n**ROI:** 0%\n**Total Costs:** $0"
163
- )
164
-
165
- # Product Selection Section
166
- with gr.Row():
167
- with gr.Column():
168
- gr.Markdown("## 🎯 Select Your Preamble Solution")
169
- monthly_budget = gr.Number(
170
- label="Monthly Budget ($)",
171
- value=5000,
172
- info="Enter your monthly budget for AI governance"
173
- )
174
- deployment_type = gr.Radio(
175
- ["Cloud/SaaS", "On-Premises"],
176
- label="Deployment Type",
177
- value="Cloud/SaaS",
178
- info="Choose your preferred deployment model"
179
- )
180
- existing_ai = gr.Radio(
181
- ["Yes, we have existing AI applications", "No, we need a full platform"],
182
- label="Existing AI Applications",
183
- value="No, we need a full platform",
184
- info="Tell us about your current AI implementation"
185
- )
186
- estimated_api_calls = gr.Number(
187
- label="Estimated Monthly API Calls",
188
- value=10000,
189
- info="Required for Guardrails pricing calculation"
190
- )
191
-
192
- # Main tabs
193
- with gr.Tabs():
194
- # Organization Details
195
- with gr.Tab("🏒 Organization Details"):
196
- num_employees = gr.Slider(
197
- label="Number of Employees",
198
- minimum=1,
199
- maximum=1000,
200
- value=215,
201
- info="How many employees will use the solution?"
202
- )
203
- hours_saved_per_week = gr.Slider(
204
- label="Hours Saved per Week per Employee",
205
- minimum=0,
206
- maximum=40,
207
- value=6.3,
208
- info="Estimated time savings per employee"
209
- )
210
- hourly_wage = gr.Slider(
211
- label="Average Hourly Wage ($)",
212
- minimum=10,
213
- maximum=200,
214
- value=62,
215
- info="Average employee hourly compensation"
216
- )
217
-
218
- # Build Costs
219
- with gr.Tab("πŸ”¨ Build Costs"):
220
- initial_platform_cost = gr.Number(
221
- label="Initial Platform Development Cost ($)",
222
- value=100000
223
- )
224
- with gr.Row():
225
- num_ai_hires = gr.Number(
226
- label="Number of AI Personnel",
227
- value=1
228
  )
229
- avg_salary = gr.Number(
230
- label="Average Annual Salary ($)",
231
- value=150000
 
232
  )
233
- with gr.Row():
234
- ai_maintenance_cost = gr.Number(
235
- label="Annual Maintenance Costs ($)",
236
- value=20000
 
 
237
  )
238
- ai_security_cost = gr.Number(
239
- label="Security & Compliance Costs ($)",
240
- value=10000
 
241
  )
242
-
243
- # Compliance
244
- with gr.Tab("πŸ›‘οΈ Compliance"):
245
- compliance_data = gr.Dataframe(
246
- value=default_compliance_df,
247
- headers=["Regulation", "Expected Violations", "Penalty", "Attorney Cost"],
248
- datatype="pandas",
249
- label="US Financial Regulations"
250
  )
251
 
252
- # Benefits
253
- with gr.Tab("πŸ“ˆ Benefits"):
254
- revenue_increase = gr.Number(
255
- label="Estimated Annual Revenue Increase ($)",
256
- value=50000,
257
- info="Projected revenue growth from AI implementation"
 
 
 
 
 
258
  )
259
 
260
- # Product Recommendation Display
261
- recommendation_box = gr.Markdown(elem_classes="recommendation-panel")
262
-
263
- # Calculate button
264
- calculate_button = gr.Button("Calculate ROI", elem_classes="primary-button")
265
-
266
- def update_results(*inputs):
267
- roi_build, roi_preamble, benefits, costs_build, costs_preamble = calculate_roi(*inputs)
268
-
269
- build_text = (
270
- f"### πŸ—οΈ Building In-House\n"
271
- f"**ROI:** {roi_build:,.1f}%\n"
272
- f"**Total Costs:** ${costs_build:,.2f}\n"
273
- f"**Total Benefits:** ${benefits:,.2f}"
274
- )
275
 
276
- preamble_text = (
277
- f"### πŸš€ Using Preamble\n"
278
- f"**ROI:** {roi_preamble:,.1f}%\n"
279
- f"**Total Costs:** ${costs_preamble:,.2f}\n"
280
- f"**Total Benefits:** ${benefits:,.2f}"
281
- )
 
 
282
 
283
- return build_text, preamble_text
284
-
285
- # Connect the recommendation update
286
- for input_elem in [monthly_budget, deployment_type, existing_ai, num_employees]:
287
- input_elem.change(
288
- fn=update_recommendation,
289
- inputs=[monthly_budget, deployment_type, existing_ai, num_employees],
290
- outputs=[recommendation_box]
291
- )
292
 
293
- # Connect the calculate button
294
- calculate_button.click(
295
- fn=update_results,
296
- inputs=[
297
- num_employees, hours_saved_per_week, hourly_wage,
298
- initial_platform_cost, num_ai_hires, avg_salary,
299
- ai_maintenance_cost, ai_security_cost,
300
- revenue_increase,
301
- monthly_budget, deployment_type, existing_ai, estimated_api_calls,
302
- compliance_data
303
- ],
304
- outputs=[build_roi_box, preamble_roi_box]
305
- )
306
 
307
- return roi_app
308
 
309
  # Create and launch the app
310
  app = create_app()
 
1
  import gradio as gr
2
  import pandas as pd
3
 
4
+ # Preamble brand colors from the image
5
  PREAMBLE_COLORS = {
6
+ 'white': '#081423', # Light background
7
+ 'yellow': '#FFC700', # Yellow accent
8
+ 'blue': '#4556E4', # Primary blue
9
+ 'navy': '#1F2C6D', # Navy blue
10
+ 'black': '#ECF0F6' # Dark background
11
  }
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  CUSTOM_CSS = """
14
  .gradio-container {
15
  max-width: 1200px !important;
16
  margin: auto !important;
17
  padding: 2rem !important;
18
+ background-color: #081423 !important;
19
+ color: #FFFFFF !important;
20
  }
21
 
22
+ /* Header styling */
23
  .header {
24
+ background-color: #1F2C6D;
25
  padding: 1.5rem;
26
  border-radius: 12px;
27
  margin-bottom: 2rem;
 
 
 
28
  color: white;
29
  }
30
 
31
+ /* Product selector styling */
32
+ .product-selector {
33
  background: linear-gradient(145deg, #4556E4, #1F2C6D);
34
  border-radius: 12px;
35
  padding: 1.5rem;
 
37
  color: white;
38
  }
39
 
40
+ /* Results styling */
41
+ .results-container {
42
+ background: #ECF0F6;
43
+ border-radius: 12px;
44
+ padding: 1.5rem;
45
+ margin-bottom: 2rem;
46
  }
47
 
48
+ .result-card {
49
+ background-color: #FFFFFF;
50
  border-radius: 8px;
51
  padding: 1rem;
52
+ margin: 0.5rem;
53
+ color: #081423;
54
  }
 
55
 
56
+ /* Button styling */
57
+ .primary-button {
58
+ background-color: #FFC700 !important;
59
+ color: #081423 !important;
60
+ font-weight: bold !important;
61
+ padding: 0.75rem 1.5rem !important;
62
+ border-radius: 8px !important;
63
+ transition: all 0.2s !important;
64
+ }
 
 
65
 
66
+ .primary-button:hover {
67
+ transform: translateY(-2px);
68
+ box-shadow: 0 4px 12px rgba(255, 199, 0, 0.3);
69
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
+ /* Tab styling */
72
+ .tab-nav {
73
+ background-color: #1F2C6D !important;
74
+ border-radius: 8px !important;
75
+ }
76
 
77
+ .tab-nav button {
78
+ color: white !important;
79
+ }
80
 
81
+ .tab-nav button.selected {
82
+ background-color: #4556E4 !important;
83
+ color: white !important;
84
+ }
 
 
 
 
85
 
86
+ /* Input styling */
87
+ .input-row {
88
+ background-color: rgba(69, 86, 228, 0.1);
89
+ border-radius: 8px;
90
+ padding: 1rem;
91
+ margin-bottom: 1rem;
92
+ }
93
 
94
+ /* Recommendation panel */
95
+ .recommendation-panel {
96
+ background-color: #FFC700;
97
+ color: #081423;
98
+ border-radius: 8px;
99
+ padding: 1rem;
100
+ margin-top: 1rem;
101
+ font-weight: bold;
102
+ }
103
+ """
104
 
105
+ # [Previous code for compliance_df and calculate_roi remains the same]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
 
107
  def create_app():
108
  with gr.Blocks(css=CUSTOM_CSS, theme=gr.themes.Soft(primary_hue="orange")) as roi_app:
 
113
  "[Visit Preamble.com](https://preamble.com) to learn more"
114
  )
115
 
116
+ # Product Selection Section - Moved to top
117
+ with gr.Row(elem_classes="product-selector"):
118
  with gr.Column():
119
+ gr.Markdown("## 🎯 Find Your Ideal Preamble Solution")
120
+ with gr.Row(elem_classes="input-row"):
121
+ deployment_type = gr.Radio(
122
+ ["Cloud/SaaS", "On-Premises"],
123
+ label="How would you like to deploy?",
124
+ value="Cloud/SaaS"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  )
126
+ existing_ai = gr.Radio(
127
+ ["Yes, we have existing AI applications", "No, we need a full platform"],
128
+ label="Do you have existing AI applications?",
129
+ value="No, we need a full platform"
130
  )
131
+
132
+ with gr.Row(elem_classes="input-row"):
133
+ monthly_budget = gr.Number(
134
+ label="Monthly Budget ($)",
135
+ value=5000,
136
+ info="What's your monthly budget for AI governance?"
137
  )
138
+ estimated_api_calls = gr.Number(
139
+ label="Estimated Monthly API Calls",
140
+ value=10000,
141
+ info="Required for Guardrails pricing"
142
  )
143
+
144
+ recommendation_box = gr.Markdown(
145
+ "Complete the information above to get your personalized solution recommendation",
146
+ elem_classes="recommendation-panel"
 
 
 
 
147
  )
148
 
149
+ # Results section
150
+ with gr.Row(elem_classes="results-container"):
151
+ with gr.Column():
152
+ build_roi_box = gr.Markdown(
153
+ "### πŸ—οΈ Building In-House\n**ROI:** 0%\n**Total Costs:** $0",
154
+ elem_classes="result-card"
155
+ )
156
+ with gr.Column():
157
+ preamble_roi_box = gr.Markdown(
158
+ "### πŸš€ Using Preamble\n**ROI:** 0%\n**Total Costs:** $0",
159
+ elem_classes="result-card"
160
  )
161
 
162
+ # ROI Calculator Section
163
+ gr.Markdown("## πŸ“ˆ Calculate Your ROI")
164
+
165
+ # [Rest of the tabs and calculator remain the same]
166
+
167
+ # Update functions
168
+ def update_recommendation(monthly_budget, deployment_type, existing_ai, num_employees):
169
+ if deployment_type == "On-Premises":
170
+ return """### 🏒 Enterprise (On-Premises)
171
+ **Perfect for:** Large enterprises with complex compliance needs
172
+ - Full platform deployment
173
+ - Complete compliance controls
174
+ - Dedicated support team
175
+ - Custom integrations
176
+ Starting at $27,000/month"""
177
 
178
+ if existing_ai == "Yes, we have existing AI applications" and monthly_budget <= 5000:
179
+ return """### ⚑ Guardrails
180
+ **Perfect for:** Teams with existing AI applications
181
+ - API-first implementation
182
+ - $0.005 per API call
183
+ - Quick integration
184
+ - Usage-based pricing
185
+ Estimated monthly cost: ${:,.2f}""".format(estimated_api_calls * 0.005)
186
 
187
+ return """### πŸš€ SaaS Platform
188
+ **Perfect for:** Teams getting started with AI
189
+ - Full platform features
190
+ - Quick cloud deployment
191
+ - Regular updates
192
+ - Simple per-user pricing
193
+ $50 per user/month (estimated: ${:,.2f}/month)""".format(num_employees * 50)
 
 
194
 
195
+ # [Rest of the event handlers remain the same]
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
+ return roi_app
198
 
199
  # Create and launch the app
200
  app = create_app()