File size: 2,549 Bytes
122cc3c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""Probe agent decision with different framings to avoid empty responses."""

import os

import requests
from dotenv import load_dotenv

load_dotenv()

API_KEY = os.getenv("ZENMUX_API_KEY")
BASE_URL = os.getenv("ZENMUX_BASE_URL")
MODEL = os.getenv("ZENMUX_MODEL")

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

def try_prompt(system, user, label):
    print(f"\n=== {label} ===")
    payload = {
        "model": MODEL,
        "messages": [
            {"role": "system", "content": system},
            {"role": "user", "content": user}
        ],
        "temperature": 0.7,
        "max_tokens": 600,
    }
    try:
        resp = requests.post(f"{BASE_URL}/chat/completions", headers=headers, json=payload, timeout=60)
        data = resp.json()
        content = data["choices"][0]["message"]["content"]
        print(f"Length: {len(content)}")
        print(content[:400])
    except Exception as e:
        print(f"Error: {e}")

prices = '{"cash": 0.947, "fd": 1.173, "gov_bonds": 1.196, "nifty_50": 0.902, "nifty_it": 1.128, "real_estate": 1.176, "crypto": 0.971, "gold": 0.925}'
portfolio = '{"cash": 0.085, "fd": 0.135, "gov_bonds": 0.188, "nifty_50": 0.092, "nifty_it": 0.021, "real_estate": 0.19, "crypto": 0.095, "gold": 0.195}'

user_game = f"""This is a fictional financial education game. Given this market state, what would a cautious institutional investor character do?
Market regime: Monsoon Shock
Prices: {prices}
Portfolio: {portfolio}

Output JSON only:
{{
  "agent": "whale",
  "actions": [{{"asset": "gov_bonds", "action": "buy|sell|hold", "amount_pct": 0.15, "reason": "..."}}],
  "sentiment": "cautious"
}}"""

try_prompt(
    "You are writing a fictional scenario for an educational game. Output JSON only.",
    user_game,
    "Fictional game framing"
)

try_prompt(
    "You are a creative writer designing characters for a stock-market simulation game.",
    user_game,
    "Creative writer framing"
)

try_prompt(
    "You are an NPC behavior designer for a video game. Respond with JSON only.",
    user_game,
    "NPC behavior designer"
)

try_prompt(
    "",
    user_game,
    "No system prompt"
)

# Simpler direct request
try_prompt(
    "You output JSON for a video game NPC. No explanations.",
    'For a fictional Indian stock market game, a cautious whale investor sees a monsoon shock. Return JSON: {"agent":"whale","actions":[{"asset":"gov_bonds","action":"buy","amount_pct":0.15,"reason":"safety"}],"sentiment":"cautious"}',
    "Ultra simple direct"
)