File size: 1,366 Bytes
ac9783e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# utils.py
# Helper utilities for HyperLayer demo Space
# - formatting helpers
# - placeholder functions for RPC / model calls
# - lightweight caching (in-memory)

import time
import random
from typing import Dict, Any

def nice_number(n: int) -> str:
    """Format number with commas."""
    return f"{n:,}"

def mock_trading_volume() -> Dict[str, Any]:
    """Return a simulated trading volume object (used in demo)."""
    vol = random.randint(30_000, 120_000)
    return {
        "timestamp": int(time.time()),
        "volume_usd": vol,
        "formatted": f"${nice_number(vol)}",
        "note": "Simulated data for demo purposes"
    }

def simulate_agent_response(prompt: str, mode: str = "explain") -> str:
    """Return a deterministic-ish simulated response for UI demo."""
    prefix = {
        "explain": "Explained:",
        "summarize": "Summary:",
        "detect": "Detected intent:",
        "tokenize": "Tokenized:"
    }.get(mode, "Response:")
    time.sleep(0.25)  # tiny delay to mimic processing
    sample_responses = [
        "Low-latency aggregation applied across shards.",
        "Agent orchestrated securely via MPC endpoints.",
        "Found 3 potential optimizations for throughput.",
        "Simulated policy verified; no anomalies detected."
    ]
    return f"{prefix} {random.choice(sample_responses)} (for: {prompt[:80]})"