Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,6 @@ with open(".stats.yml", 'r') as f:
|
|
| 7 |
stats = yaml.safe_load(f)
|
| 8 |
OPENAPI_URL = stats.get('openapi_spec_url')
|
| 9 |
|
| 10 |
-
# We use the global 'prism' command installed via the Dockerfile
|
| 11 |
subprocess.Popen(["prism", "mock", OPENAPI_URL, "-p", "4010", "-h", "0.0.0.0"])
|
| 12 |
time.sleep(5)
|
| 13 |
|
|
@@ -21,54 +20,52 @@ def format_res(data):
|
|
| 21 |
except:
|
| 22 |
return str(data)
|
| 23 |
|
| 24 |
-
# 3. Master Logic
|
| 25 |
def master_controller(category, action, p1, p2):
|
| 26 |
try:
|
| 27 |
-
# --- SYSTEM
|
| 28 |
if category == "System":
|
| 29 |
-
if "Status"
|
| 30 |
-
if "Audit"
|
| 31 |
-
if "Biometric Compare"
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
if "
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
client.system.notifications.send_push(body=p1 or "Hello", title="Alert", user_id=p2 or "user_1")
|
| 39 |
-
return "✅ Push Notification Sent to Queue"
|
| 40 |
|
| 41 |
# --- USERS ---
|
| 42 |
if category == "Users":
|
| 43 |
-
if "Me"
|
| 44 |
-
if "Preferences"
|
| 45 |
-
if "Devices"
|
| 46 |
|
| 47 |
# --- ACCOUNTS ---
|
| 48 |
if category == "Accounts":
|
| 49 |
-
if "List All"
|
| 50 |
-
if "Details"
|
| 51 |
|
| 52 |
# --- AI ORACLE ---
|
| 53 |
if category == "AI Oracle":
|
| 54 |
-
if "Market
|
| 55 |
-
if "
|
| 56 |
|
| 57 |
# --- WEB3 ---
|
| 58 |
if category == "Web3":
|
| 59 |
-
if "Wallets"
|
| 60 |
-
if "Network"
|
| 61 |
|
| 62 |
# --- PAYMENTS ---
|
| 63 |
if category == "Payments":
|
| 64 |
-
if "FX Rates"
|
| 65 |
-
if "List
|
| 66 |
|
| 67 |
-
return f"
|
| 68 |
except Exception as e:
|
| 69 |
return f"❌ SDK Error: {str(e)}"
|
| 70 |
|
| 71 |
-
# 4.
|
| 72 |
MENU = {
|
| 73 |
"System": ["Get Status", "Get Audit Logs", "Biometric Compare", "Notify Templates", "Send Push"],
|
| 74 |
"Users": ["Get Me", "Get Preferences", "List Devices"],
|
|
@@ -78,10 +75,8 @@ MENU = {
|
|
| 78 |
"Payments": ["Get FX Rates", "List All Payments"]
|
| 79 |
}
|
| 80 |
|
| 81 |
-
# 5. UI with Fixed Theme
|
| 82 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 83 |
gr.Markdown("# 🏦 Jocall3 AI Banking: Enterprise Explorer")
|
| 84 |
-
gr.Markdown("Directly calling the SDK against the Prism Mocking layer.")
|
| 85 |
|
| 86 |
with gr.Row():
|
| 87 |
with gr.Column(scale=1):
|
|
@@ -101,4 +96,4 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 101 |
run_btn.click(master_controller, inputs=[category_radio, action_dropdown, p1, p2], outputs=output_code)
|
| 102 |
|
| 103 |
if __name__ == "__main__":
|
| 104 |
-
demo.launch(
|
|
|
|
| 7 |
stats = yaml.safe_load(f)
|
| 8 |
OPENAPI_URL = stats.get('openapi_spec_url')
|
| 9 |
|
|
|
|
| 10 |
subprocess.Popen(["prism", "mock", OPENAPI_URL, "-p", "4010", "-h", "0.0.0.0"])
|
| 11 |
time.sleep(5)
|
| 12 |
|
|
|
|
| 20 |
except:
|
| 21 |
return str(data)
|
| 22 |
|
| 23 |
+
# 3. Master Logic - mapped exactly to the MENU labels
|
| 24 |
def master_controller(category, action, p1, p2):
|
| 25 |
try:
|
| 26 |
+
# --- SYSTEM ---
|
| 27 |
if category == "System":
|
| 28 |
+
if action == "Get Status": return format_res(client.system.get_status())
|
| 29 |
+
if action == "Get Audit Logs": return format_res(client.system.get_audit_logs(limit=5))
|
| 30 |
+
if action == "Biometric Compare":
|
| 31 |
+
client.system.verification.compare_biometric(sample_a=p1 or "s1", sample_b=p2 or "s2")
|
| 32 |
+
return json.dumps({"status": "Success", "message": "Biometric match verified by AI"}, indent=2)
|
| 33 |
+
if action == "Notify Templates": return format_res(client.system.notifications.list_templates())
|
| 34 |
+
if action == "Send Push":
|
| 35 |
+
client.system.notifications.send_push(body=p1 or "Alert", title="Bank Notification", user_id=p2 or "u1")
|
| 36 |
+
return json.dumps({"status": "Queued", "recipient": p2}, indent=2)
|
|
|
|
|
|
|
| 37 |
|
| 38 |
# --- USERS ---
|
| 39 |
if category == "Users":
|
| 40 |
+
if action == "Get Me": return format_res(client.users.me.retrieve())
|
| 41 |
+
if action == "Get Preferences": return format_res(client.users.me.preferences.retrieve())
|
| 42 |
+
if action == "List Devices": return format_res(client.users.me.devices.list())
|
| 43 |
|
| 44 |
# --- ACCOUNTS ---
|
| 45 |
if category == "Accounts":
|
| 46 |
+
if action == "List All": return format_res(client.accounts.retrieve_me())
|
| 47 |
+
if action == "Get Details": return format_res(client.accounts.retrieve_details(p1 or "acc_123"))
|
| 48 |
|
| 49 |
# --- AI ORACLE ---
|
| 50 |
if category == "AI Oracle":
|
| 51 |
+
if action == "Market Crash Prediction": return format_res(client.ai.oracle.predictions.retrieve_market_crash_probability())
|
| 52 |
+
if action == "Run Simulation": return format_res(client.ai.oracle.simulate.create(prompt=p1 or "Global Recession"))
|
| 53 |
|
| 54 |
# --- WEB3 ---
|
| 55 |
if category == "Web3":
|
| 56 |
+
if action == "List Wallets": return format_res(client.web3.wallets.list())
|
| 57 |
+
if action == "Network Status": return format_res(client.web3.network.get_status())
|
| 58 |
|
| 59 |
# --- PAYMENTS ---
|
| 60 |
if category == "Payments":
|
| 61 |
+
if action == "Get FX Rates": return format_res(client.payments.fx.get_rates(pair=p1 or "EURUSD"))
|
| 62 |
+
if action == "List All Payments": return format_res(client.payments.list())
|
| 63 |
|
| 64 |
+
return f"Error: Action '{action}' not found in router logic."
|
| 65 |
except Exception as e:
|
| 66 |
return f"❌ SDK Error: {str(e)}"
|
| 67 |
|
| 68 |
+
# 4. The Menu (Keep these labels consistent with the logic above)
|
| 69 |
MENU = {
|
| 70 |
"System": ["Get Status", "Get Audit Logs", "Biometric Compare", "Notify Templates", "Send Push"],
|
| 71 |
"Users": ["Get Me", "Get Preferences", "List Devices"],
|
|
|
|
| 75 |
"Payments": ["Get FX Rates", "List All Payments"]
|
| 76 |
}
|
| 77 |
|
|
|
|
| 78 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 79 |
gr.Markdown("# 🏦 Jocall3 AI Banking: Enterprise Explorer")
|
|
|
|
| 80 |
|
| 81 |
with gr.Row():
|
| 82 |
with gr.Column(scale=1):
|
|
|
|
| 96 |
run_btn.click(master_controller, inputs=[category_radio, action_dropdown, p1, p2], outputs=output_code)
|
| 97 |
|
| 98 |
if __name__ == "__main__":
|
| 99 |
+
demo.launch()
|