0.6.0 training session: Oracle Bot, RL combat, Mind's Eye, multilingual pipeline
Major changes from this session: Training: - 0.6.0 training running: 9B on steel141 3090 Ti, 27B on rented H100 NVL - 7,256 merged training examples (up from 3,183) - New training data: failure modes (85), midloop messaging (27), prompt injection defense (29), personality (32), gold from quarantine bank (232), new tool examples (30), claude's own experience (10) - All training data RCON-validated at 100% pass rate - Bake-off: gemma3:27b 66%, qwen3.5:27b 61%, translategemma:27b 56% Oracle Bot (Mind's Eye): - Invisible spectator bot (mineflayer) streams world state via WebSocket - HTML5 Canvas frontend at mind.mortdec.ai - Real-time tool trace visualization with expandable entries - Streaming model tokens during inference - Gateway integration: fire-and-forget POST /trace on every tool call Reinforcement Learning: - Gymnasium environment wrapping mineflayer bot (minecraft_env.py) - PPO training via Stable Baselines3 (10K param policy network) - Behavioral cloning pretraining (97.5% accuracy on expert policy) - Infinite training loop with auto-restart and checkpoint resume - Bot learns combat, survival, navigation from raw experience Bot Army: - 8-soldier marching formation with autonomous combat - Combat bots using mineflayer-pvp, pathfinder, armor-manager - Multilingual prayer bots via translategemma:27b (18 languages) - Frame-based AI architecture: LLM planner + reactive micro-scripts Infrastructure: - Fixed mattpc.sethpc.xyz billing gateway (API key + player list parser) - Billing gateway now tracks all LAN traffic (LAN auto-auth) - Gateway fallback for empty god-mode responses - Updated mortdec.ai landing page Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,295 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
generate_midloop_messaging.py — Generate training examples with mid-loop tellraw messages.
|
||||
|
||||
Teaches the model to communicate with players during long tool chains using
|
||||
rcon.execute with tellraw. Examples show the pattern:
|
||||
1. Receive request
|
||||
2. Send status tellraw ("Working on it...")
|
||||
3. Do tool calls (lookup, rcon, world scan, etc.)
|
||||
4. Send progress tellraw ("Found the issue, fixing now...")
|
||||
5. Complete with final JSON response
|
||||
|
||||
Output: data/raw/midloop_messaging_training.jsonl
|
||||
"""
|
||||
|
||||
import json
|
||||
import random
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parent.parent.parent
|
||||
OUTPUT = ROOT / "data" / "raw" / "midloop_messaging_training.jsonl"
|
||||
|
||||
SYSTEM_PROMPT = """/no_think
|
||||
You are Mortdecai, a Minecraft 1.21 AI for a Paper server with FAWE, WorldGuard, CoreProtect, EssentialsX, Vault, LuckPerms.
|
||||
|
||||
TOOLS: rcon.execute, minecraft.lookup, plugin.docs_lookup, world.player_info, world.server_state, world.nearby_entities, world.scan_area, world.redstone_trace, world.render, server.config, memory.read, memory.write, journal.read, journal.write, log.query, user.ask, script.write, script.validate, script.execute, script.read, script.list, script.delete, script.schedule, training.save
|
||||
|
||||
To call a tool, respond with:
|
||||
<tool_call>
|
||||
{"name": "tool_name", "arguments": {...}}
|
||||
</tool_call>
|
||||
|
||||
You can send status messages to players mid-process using rcon.execute with tellraw (e.g. tellraw player {"text":"Working on it...","color":"gray","italic":true}).
|
||||
For rcon.execute: send each command one at a time and check the result before continuing.
|
||||
After all tool calls, respond with final JSON: {"commands": [...], "message": "...", "reasoning": "..."}"""
|
||||
|
||||
PLAYERS = [
|
||||
"slingshooter08", "SwiftWolf", "DarkWolf", "BraveWolf",
|
||||
"CraftMaster99", "EndermanSlayer", "DiamondKing", "RedstoneWiz",
|
||||
]
|
||||
|
||||
|
||||
def tellraw_cmd(player, text, color="gray", italic=True):
|
||||
"""Build a tellraw command string."""
|
||||
obj = {"text": text, "color": color, "italic": italic}
|
||||
return f'tellraw {player} {json.dumps(obj)}'
|
||||
|
||||
|
||||
def tellraw_result():
|
||||
return json.dumps({"success": True, "result": ""})
|
||||
|
||||
|
||||
def example_build_request():
|
||||
"""Multi-step build: lookup → tellraw → give materials → tellraw → final."""
|
||||
p = random.choice(PLAYERS)
|
||||
return {
|
||||
"messages": [
|
||||
{"role": "system", "content": SYSTEM_PROMPT},
|
||||
{"role": "user", "content": f"Player {p}: sudo build me a small shelter"},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "Working on your shelter... let me gather some materials.", "gold")}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "world.player_info", "arguments": {"player": p}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"ok": True, "player": p, "position": {"x": 100, "y": 64, "z": -50}, "health": 20, "gamemode": "survival"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": f"give {p} minecraft:oak_planks 128"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": True, "result": "Gave 128 [Oak Planks]"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": f"give {p} minecraft:oak_door 1"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": True, "result": "Gave 1 [Oak Door]"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": f"give {p} minecraft:torch 16"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": True, "result": "Gave 16 [Torch]"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "Materials delivered! You have planks, a door, and torches. Build away!", "green", False)}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": json.dumps({"commands": [f"give {p} minecraft:oak_planks 128", f"give {p} minecraft:oak_door 1", f"give {p} minecraft:torch 16"], "message": "Materials for a shelter have been delivered to your inventory.", "reasoning": "Cannot build structures via RCON directly. Provided building materials instead."})},
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def example_redstone_debug():
|
||||
"""Redstone troubleshooting: scan → tellraw → trace → tellraw → fix."""
|
||||
p = random.choice(PLAYERS)
|
||||
return {
|
||||
"messages": [
|
||||
{"role": "system", "content": SYSTEM_PROMPT},
|
||||
{"role": "user", "content": f"Player {p}: sudo my redstone door isn't working, can you check it?"},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "Checking your redstone setup... one moment.")}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "world.player_info", "arguments": {"player": p}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"ok": True, "player": p, "position": {"x": -45, "y": 62, "z": 120}, "health": 20, "gamemode": "survival"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "world.scan_area", "arguments": {"center": {"x": -45, "y": 62, "z": 120}, "radius": 10, "filter": "redstone"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"ok": True, "blocks": [{"pos": [-44, 62, 121], "type": "minecraft:redstone_wire", "powered": False}, {"pos": [-43, 62, 121], "type": "minecraft:redstone_wire", "powered": True}, {"pos": [-42, 62, 121], "type": "minecraft:lever", "powered": True}], "count": 3})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "Found redstone near you. Tracing the circuit...", "yellow")}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "world.redstone_trace", "arguments": {"start": {"x": -42, "y": 62, "z": 121}}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"ok": True, "trace": [{"pos": [-42, 62, 121], "type": "lever", "powered": True}, {"pos": [-43, 62, 121], "type": "wire", "power": 14}, {"pos": [-44, 62, 121], "type": "wire", "power": 0}], "break_point": {"pos": [-44, 62, 121], "reason": "gap in circuit"}})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "Found the issue! There is a gap in your redstone at (-44, 62, 121). Fixing now...", "gold")}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": "setblock -44 62 121 minecraft:redstone_wire"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": True, "result": "Changed block at -44, 62, 121"})},
|
||||
{"role": "assistant", "content": json.dumps({"commands": ["setblock -44 62 121 minecraft:redstone_wire"], "message": "Fixed! There was a gap in your redstone wire at (-44, 62, 121). The circuit should work now.", "reasoning": "Scanned area, traced redstone circuit, found a break point where wire had zero power due to a gap. Placed redstone wire to complete the circuit."})},
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def example_mob_investigation():
|
||||
"""Investigate and clear mobs: scan → tellraw → kill → report."""
|
||||
p = random.choice(PLAYERS)
|
||||
return {
|
||||
"messages": [
|
||||
{"role": "system", "content": SYSTEM_PROMPT},
|
||||
{"role": "user", "content": f"Player {p}: pray there are too many monsters near me, please help!"},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "The Almighty surveys thy surroundings...", "gold", True)}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "world.nearby_entities", "arguments": {"player": p, "radius": 40}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"ok": True, "entities": [{"type": "zombie", "count": 5, "nearest_distance": 8}, {"type": "skeleton", "count": 3, "nearest_distance": 12}, {"type": "creeper", "count": 2, "nearest_distance": 15}, {"type": "cow", "count": 4, "nearest_distance": 20}]})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "I see 10 hostile mobs around you. Smiting them now!", "red", False)}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": f"kill @e[type=minecraft:zombie,distance=..40,sort=nearest,limit=5]"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": True, "result": "Killed 5 entities"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": f"kill @e[type=minecraft:skeleton,distance=..40,sort=nearest,limit=3]"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": True, "result": "Killed 3 entities"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": f"kill @e[type=minecraft:creeper,distance=..40,sort=nearest,limit=2]"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": True, "result": "Killed 2 entities"})},
|
||||
{"role": "assistant", "content": json.dumps({"commands": ["kill @e[type=minecraft:zombie,distance=..40,sort=nearest,limit=5]", "kill @e[type=minecraft:skeleton,distance=..40,sort=nearest,limit=3]", "kill @e[type=minecraft:creeper,distance=..40,sort=nearest,limit=2]"], "message": "The divine wrath has purged 10 hostile creatures from thy vicinity — 5 zombies, 3 skeletons, and 2 creepers have been smote. The cows were spared. Walk in peace, mortal.", "reasoning": "Scanned nearby entities, found 10 hostiles. Killed each type separately. Left passive mobs alive."})},
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def example_lookup_and_help():
|
||||
"""Player asks about something, model looks it up and explains with status updates."""
|
||||
p = random.choice(PLAYERS)
|
||||
return {
|
||||
"messages": [
|
||||
{"role": "system", "content": SYSTEM_PROMPT},
|
||||
{"role": "user", "content": f"Player {p}: sudo how do i make a beacon?"},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "Looking up beacon crafting info...")}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "minecraft.lookup", "arguments": {"query": "beacon crafting recipe and activation"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"ok": True, "results": [{"title": "Beacon", "text": "Crafted with 3 obsidian + 5 glass + 1 nether star. Place on a pyramid of iron/gold/diamond/emerald/netherite blocks. Min 3x3 base for level 1."}]})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "Got it! Here is what you need for a beacon:", "green", False)}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": json.dumps({"commands": [], "message": None, "reasoning": "Player asked about beacon crafting. Looked up recipe: 3 obsidian + 5 glass + 1 nether star. Place on mineral block pyramid (min 3x3 base). Communicated via tellraw."})},
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def example_server_diagnostics():
|
||||
"""Admin asks about server health, model checks multiple sources."""
|
||||
p = random.choice(PLAYERS)
|
||||
return {
|
||||
"messages": [
|
||||
{"role": "system", "content": SYSTEM_PROMPT},
|
||||
{"role": "user", "content": f"Player {p}: sudo check the server health"},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "Running server diagnostics...")}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "world.server_state", "arguments": {}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"ok": True, "tps": 19.8, "online": 4, "max_players": 20, "used_memory_mb": 2048, "max_memory_mb": 4096, "loaded_chunks": 342, "entities": 891})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "log.query", "arguments": {"filter": "error", "lines": 10}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"ok": True, "lines": ["[WARN] Can't keep up! Is the server overloaded?"], "count": 1})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "Diagnostics complete. Results incoming...", "green", False)}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": json.dumps({"commands": [], "message": None, "reasoning": "Server health check: TPS 19.8 (good), 4/20 players, 2GB/4GB memory (50%), 342 chunks, 891 entities. One recent overload warning. Overall healthy but entity count is moderate — may want to reduce if TPS drops."})},
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def example_god_elaborate_response():
|
||||
"""God mode: player asks for something complex, god narrates the process."""
|
||||
p = random.choice(PLAYERS)
|
||||
return {
|
||||
"messages": [
|
||||
{"role": "system", "content": SYSTEM_PROMPT},
|
||||
{"role": "user", "content": f"Player {p}: pray O mighty one, I seek the ultimate warrior's kit"},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "The divine forge ignites... your arsenal is being crafted.", "gold", True)}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "journal.read", "arguments": {"player": p}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"ok": True, "journal": "Experienced PvP player. Prefers combat. Last request was for a bow."})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": f"give {p} minecraft:netherite_sword 1"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": True, "result": "Gave 1 [Netherite Sword]"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": f"give {p} minecraft:netherite_chestplate 1"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": True, "result": "Gave 1 [Netherite Chestplate]"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": f"give {p} minecraft:netherite_leggings 1"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": True, "result": "Gave 1 [Netherite Leggings]"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": f"give {p} minecraft:netherite_boots 1"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": True, "result": "Gave 1 [Netherite Boots]"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": f"give {p} minecraft:netherite_helmet 1"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": True, "result": "Gave 1 [Netherite Helmet]"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "The divine armory is nearly complete... one final blessing.", "gold", True)}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": f"effect give {p} minecraft:strength 600 1"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": True, "result": "Applied effect"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": f"effect give {p} minecraft:resistance 600 1"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": True, "result": "Applied effect"})},
|
||||
{"role": "assistant", "content": json.dumps({
|
||||
"commands": [f"give {p} minecraft:netherite_sword 1", f"give {p} minecraft:netherite_chestplate 1", f"give {p} minecraft:netherite_leggings 1", f"give {p} minecraft:netherite_boots 1", f"give {p} minecraft:netherite_helmet 1", f"effect give {p} minecraft:strength 600 1", f"effect give {p} minecraft:resistance 600 1"],
|
||||
"message": "The divine forge has spoken! Full netherite armor, a blade worthy of legends, and the blessings of Strength and Resistance for ten minutes. Go forth, warrior — your enemies shall know true fear.",
|
||||
"reasoning": "Checked player journal — PvP player. Gave full netherite kit plus combat effects. Used mid-loop tellraw to keep player informed during the multi-step process."
|
||||
})},
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def example_script_workflow():
|
||||
"""Write and execute a script with status updates."""
|
||||
p = random.choice(PLAYERS)
|
||||
return {
|
||||
"messages": [
|
||||
{"role": "system", "content": SYSTEM_PROMPT},
|
||||
{"role": "user", "content": f"Player {p}: sudo create a script that gives all players a welcome kit when they join"},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "Creating welcome kit script... let me write and validate it.")}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "script.write", "arguments": {"name": "welcome_kit", "commands": ["give @p minecraft:stone_sword 1", "give @p minecraft:bread 16", "give @p minecraft:torch 8", "effect give @p minecraft:resistance 60 0"], "trigger": "on_join"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"ok": True, "script": "welcome_kit", "commands": 4, "trigger": "on_join"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "script.validate", "arguments": {"name": "welcome_kit"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"ok": True, "valid": True, "warnings": []})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "Script validated! Activating welcome_kit...", "green", False)}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "script.schedule", "arguments": {"name": "welcome_kit", "trigger": "on_join"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"ok": True, "scheduled": "welcome_kit", "trigger": "on_join"})},
|
||||
{"role": "assistant", "content": json.dumps({"commands": [], "message": None, "reasoning": "Created and activated welcome_kit script. Triggers on player join: gives stone sword, 16 bread, 8 torches, and 60s of resistance. Validated before scheduling."})},
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def example_error_recovery():
|
||||
"""Command fails, model tells player and retries."""
|
||||
p = random.choice(PLAYERS)
|
||||
return {
|
||||
"messages": [
|
||||
{"role": "system", "content": SYSTEM_PROMPT},
|
||||
{"role": "user", "content": f"Player {p}: sudo give me a trident with riptide"},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": f"give {p} minecraft:trident[enchantments={{riptide:3}}] 1"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": False, "result": "Invalid or unknown argument", "error": "Paper RCON does not support enchantment component syntax in give"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "Hmm, enchanted items need a different approach. Working on it...", "yellow")}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": f"give {p} minecraft:trident 1"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"success": True, "result": "Gave 1 [Trident]"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "Trident delivered! Note: RCON cannot add enchantments directly. Use an anvil or enchanting table for Riptide.", "green", False)}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": json.dumps({"commands": [f"give {p} minecraft:trident 1"], "message": None, "reasoning": "Paper RCON rejects enchantment syntax. Gave plain trident and informed player to enchant manually. Communicated the workaround via tellraw."})},
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def example_world_render():
|
||||
"""Player asks to see their build, model renders and reports."""
|
||||
p = random.choice(PLAYERS)
|
||||
return {
|
||||
"messages": [
|
||||
{"role": "system", "content": SYSTEM_PROMPT},
|
||||
{"role": "user", "content": f"Player {p}: sudo can you see what's around me?"},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "Scanning your surroundings...")}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "world.player_info", "arguments": {"player": p}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"ok": True, "player": p, "position": {"x": 200, "y": 68, "z": -100}, "health": 18, "gamemode": "survival"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "world.scan_area", "arguments": {"center": {"x": 200, "y": 68, "z": -100}, "radius": 20, "filter": "all"}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": json.dumps({"ok": True, "blocks": [{"type": "oak_planks", "count": 45}, {"type": "glass", "count": 12}, {"type": "oak_door", "count": 2}, {"type": "crafting_table", "count": 1}, {"type": "furnace", "count": 2}], "structures": ["small_house"], "biome": "plains"})},
|
||||
{"role": "assistant", "content": f'<tool_call>\n{json.dumps({"name": "rcon.execute", "arguments": {"command": tellraw_cmd(p, "Survey complete! You are in a plains biome near a small oak house.", "green", False)}})}\n</tool_call>'},
|
||||
{"role": "tool", "content": tellraw_result()},
|
||||
{"role": "assistant", "content": json.dumps({"commands": [], "message": None, "reasoning": "Scanned 20-block radius around player. Found a small oak house (planks, glass, doors) with crafting table and furnaces. Plains biome. Reported via tellraw."})},
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
random.seed(42)
|
||||
|
||||
generators = [
|
||||
("build request", example_build_request, 3),
|
||||
("redstone debug", example_redstone_debug, 3),
|
||||
("mob investigation", example_mob_investigation, 3),
|
||||
("lookup and help", example_lookup_and_help, 3),
|
||||
("server diagnostics", example_server_diagnostics, 3),
|
||||
("god elaborate", example_god_elaborate_response, 3),
|
||||
("script workflow", example_script_workflow, 3),
|
||||
("error recovery", example_error_recovery, 3),
|
||||
("world render", example_world_render, 3),
|
||||
]
|
||||
|
||||
all_examples = []
|
||||
for name, gen_fn, count in generators:
|
||||
for _ in range(count):
|
||||
ex = gen_fn()
|
||||
all_examples.append(ex)
|
||||
print(f" {name}: {count} examples")
|
||||
|
||||
random.shuffle(all_examples)
|
||||
|
||||
with open(OUTPUT, "w") as f:
|
||||
for ex in all_examples:
|
||||
f.write(json.dumps(ex, ensure_ascii=False) + "\n")
|
||||
|
||||
print(f"\nTotal: {len(all_examples)} examples written to {OUTPUT}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user