File size: 1,895 Bytes
5a89405
 
 
946ca42
 
 
5a89405
946ca42
 
 
 
5a89405
946ca42
 
 
 
 
 
 
5a89405
946ca42
 
5a89405
946ca42
 
5a89405
 
946ca42
5a89405
 
946ca42
 
5a89405
 
946ca42
5a89405
946ca42
5a89405
946ca42
5a89405
 
 
946ca42
5a89405
 
946ca42
5a89405
946ca42
5a89405
946ca42
 
5a89405
946ca42
5a89405
 
946ca42
 
5a89405
946ca42
5a89405
946ca42
 
5a89405
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
import subprocess
import time
import yaml
import gradio as gr
from aibanking import Jocall3

# 1. Dynamically get the OpenAPI spec from the cloned .stats.yml
with open(".stats.yml", 'r') as f:
    stats = yaml.safe_load(f)
    OPENAPI_URL = stats.get('openapi_spec_url')

# 2. Start Prism in the background on port 4010
print(f"Starting Prism Mock Server...")
subprocess.Popen([
    "prism", "mock", OPENAPI_URL, 
    "-p", "4010", 
    "-h", "0.0.0.0"
])

# Give Prism time to boot
time.sleep(5)

# 3. Setup the SDK Client
# It handles the 'x-api-key' header automatically
client = Jocall3(
    base_url="http://127.0.0.1:4010",
    api_key="mock-key-123"
)

# 4. App Functions
def check_status():
    try:
        status = client.system.get_status()
        return f"✅ API Status: {status.api_status}\nGemini Uptime: {status.gemini_uptime}"
    except Exception as e:
        return f"❌ SDK Error: {str(e)}"

def create_demo_account():
    try:
        acc = client.accounts.open(
            currency="USD",
            initial_deposit=1000.0,
            product_type="high_yield_vault"
        )
        return f"Account ID: {acc.id}\nBalance: {acc.current_balance}\nBank: {acc.institution_name}"
    except Exception as e:
        return f"❌ Error: {str(e)}"

# 5. UI Layout
with gr.Blocks(theme=gr.themes.Soft()) as demo:
    gr.Markdown("# 🏦 Jocall3 AI Banking SDK Demo")
    gr.Markdown("Running a local **Prism Mock** server against the latest OpenAPI spec.")
    
    with gr.Row():
        btn_status = gr.Button("Check System Health", variant="primary")
        btn_acc = gr.Button("Simulate Open Account")
    
    output = gr.Textbox(label="Response from SDK", lines=5)

    btn_status.click(check_status, outputs=output)
    btn_acc.click(create_demo_account, outputs=output)

if __name__ == "__main__":
    demo.launch(server_name="0.0.0.0", server_port=7860)