robbyray's picture
Create app.py
f6d741d verified
Raw History Blame Contribute Delete
5 kB
import time
import gradio as gr
def simulate_vexa_terminal(project_name, cost_estimate):
# We will build the terminal output string line by line
output = ""
def add_line(text, delay=0.5):
nonlocal output
output += text + "\n"
time.sleep(delay)
return output
# --- BOOT SEQUENCE ---
yield add_line("[ INITIALIZING VEXA STRATAGEM COMMAND LAYER ]", 1)
yield add_line(">>> System: Active", 0.5)
yield add_line(">>> Mission: De-risking Enterprise AI\n", 1)
# --- PHASE 1: STRATEGY ---
yield add_line("==================================================", 0.1)
yield add_line(" PHASE 1: STRATEGIC ALIGNMENT ", 0.1)
yield add_line("==================================================\n", 0.5)
yield add_line(f"Analyzing Initiative: '{project_name}'", 0.8)
yield add_line("Evaluating against core business mandate...", 1)
yield add_line("[✓] PASS: Initiative aligns with operational goals.\n", 1)
# --- PHASE 2: READINESS ---
yield add_line("==================================================", 0.1)
yield add_line(" PHASE 2: READINESS GAP ANALYSIS ", 0.1)
yield add_line("==================================================\n", 0.5)
yield add_line("Executing 5-Pillar Assessment...\n", 1)
readiness_data = {"Vision": 85, "Talent": 40, "Data": 35, "Governance": 50, "Technology": 90}
for pillar, score in readiness_data.items():
# Text-based bar chart
bar_filled = "█" * int(score / 5)
bar_empty = "░" * (20 - int(score / 5))
status = "[GAP]" if score < 50 else "[OK] "
line = f" {pillar.ljust(12)} |{bar_filled}{bar_empty}| {score}% {status}"
yield add_line(line, 0.4)
yield add_line("\n>>> ALERT: Critical foundational deficits detected in Data and Talent.\n", 1.5)
# --- PHASE 3: ROI ENGINE ---
yield add_line("==================================================", 0.1)
yield add_line(" PHASE 3: ROI SIMULATION ", 0.1)
yield add_line("==================================================\n", 0.5)
yield add_line("Mapping readiness gaps to remediation costs...", 0.8)
yield add_line("Running financial models...\n", 1.2)
remediation_cost = 450000
total_investment = cost_estimate + remediation_cost
yield add_line(f" Base Project Cost: ${cost_estimate:,.2f}", 0.3)
yield add_line(f" Gap Remediation Cost: ${remediation_cost:,.2f}", 0.3)
yield add_line(f" Total Capital Required: ${total_investment:,.2f}", 0.3)
yield add_line(" ----------------------------------------", 0.3)
yield add_line(" [>] Projected Breakeven: 18 Months", 0.6)
yield add_line(" [>] Risk-Adjusted Value: $1.2M (+8% vs Base Case)\n", 1.5)
# --- PHASE 4: VETO ---
yield add_line("==================================================", 0.1)
yield add_line(" PHASE 4: DEPLOYMENT & GOVERNANCE ", 0.1)
yield add_line("==================================================\n", 0.5)
yield add_line("Generating Living Blueprint...\n", 1)
yield add_line(" [ ] Awareness: Exec brief drafted.", 0.3)
yield add_line(" [ ] Desire: Stakeholder alignment pending.", 0.3)
yield add_line(" [X] Knowledge: TRAINING BLOCK DETECTED.", 0.8)
yield add_line("\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", 0.1)
yield add_line(" SYSTEM VETO INITIATED ", 0.8)
yield add_line("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n", 0.5)
yield add_line("REASON:", 0.5)
yield add_line("- Analysis indicates 'Talent' score (40%) is insufficient to sustain deployment.", 0.8)
yield add_line("- Remediation of Data architecture is required before capital deployment.\n", 1)
yield add_line("STATUS: NO-GO. PROJECT PAUSED FOR GOVERNANCE REVIEW.", 0)
# --- GRADIO UI ---
with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
gr.Markdown("# VEXA Stratagem: The Command Layer")
gr.Markdown("Simulating the progression from insight to impact, and the execution of the System Veto.")
with gr.Row():
with gr.Column(scale=1):
project_input = gr.Textbox(label="Initiative Name", value="Generative AI Customer Support Agent")
cost_input = gr.Number(label="Estimated Project Cost ($)", value=1200000)
btn = gr.Button("Run Stratagem Simulation", variant="primary")
with gr.Column(scale=2):
# We use a code block to make it look exactly like a terminal
terminal_output = gr.Code(label="VEXA Terminal", language="shell", interactive=False, lines=30)
# Connect the button to the generator function
btn.click(simulate_vexa_terminal, inputs=[project_input, cost_input], outputs=[terminal_output])
if __name__ == "__main__":
demo.launch()