mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-07-11 18:55:17 +02:00
changed the checking if complete cycle to be more frequent and updated the collab_profile
This commit is contained in:
parent
2bd6b2cb49
commit
39cec7cf82
5 changed files with 54 additions and 25 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -15,4 +15,6 @@ services/viaproxy/saves.json
|
|||
services/viaproxy/viaproxy.yml
|
||||
tmp/
|
||||
wandb/
|
||||
experiments/
|
||||
experiments/
|
||||
andy_*.json
|
||||
jill_*.json
|
||||
|
|
|
@ -111,7 +111,8 @@ def launch_parallel_experiments(task_path,
|
|||
model="gpt-4o",
|
||||
num_parallel=1,
|
||||
s3=False,
|
||||
bucket_name="mindcraft-experiments"):
|
||||
bucket_name="mindcraft-experiments",
|
||||
template_profile="profiles/collab_profile.json"):
|
||||
|
||||
with open(task_path, 'r', encoding='utf-8') as file:
|
||||
content = file.read()
|
||||
|
@ -138,7 +139,8 @@ def launch_parallel_experiments(task_path,
|
|||
experiments_folder,
|
||||
exp_name,
|
||||
s3=s3,
|
||||
bucket_name=bucket_name)
|
||||
bucket_name=bucket_name,
|
||||
template_profile="profiles/collab_profile.json")
|
||||
time.sleep(5)
|
||||
|
||||
def launch_server_experiment(task_path,
|
||||
|
@ -150,7 +152,8 @@ def launch_server_experiment(task_path,
|
|||
num_agents=2,
|
||||
model="gpt-4o",
|
||||
s3=False,
|
||||
bucket_name="mindcraft-experiments"):
|
||||
bucket_name="mindcraft-experiments",
|
||||
template_profile="profiles/collab_profile.json"):
|
||||
"""
|
||||
Launch a Minecraft server and run experiments on it.
|
||||
@param task_path: Path to the task file
|
||||
|
@ -174,7 +177,7 @@ def launch_server_experiment(task_path,
|
|||
else:
|
||||
agent_names = [f"andy_{session_name}", f"jill_{session_name}", f"bob_{session_name}"]
|
||||
models = [model] * 3
|
||||
make_profiles(agent_names, models)
|
||||
make_profiles(agent_names, models, template_profile=template_profile)
|
||||
|
||||
# edit_file("settings.js", {"profiles": [f"./{agent}.json" for agent in agent_names]})
|
||||
agent_profiles = [f"./{agent}.json" for agent in agent_names]
|
||||
|
@ -226,10 +229,10 @@ def launch_server_experiment(task_path,
|
|||
|
||||
# subprocess.run(["tmux", "send-keys", "-t", session_name, f"/op {agent_names[0]}", "C-m"])
|
||||
|
||||
def make_profiles(agent_names, models):
|
||||
def make_profiles(agent_names, models, template_profile="profiles/collab_profile.json"):
|
||||
assert len(agent_names) == len(models)
|
||||
|
||||
with open("profiles/collab_profile.json", 'r') as f:
|
||||
with open(template_profile, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
profile = json.loads(content)
|
||||
|
@ -353,6 +356,7 @@ def main():
|
|||
parser.add_argument('--s3', action='store_true', help='Whether to upload to s3')
|
||||
parser.add_argument('--bucket_name', default="mindcraft-experiments", help='Name of the s3 bucket')
|
||||
parser.add_argument('--add_keys', action='store_true', help='Create the keys.json to match the environment variables')
|
||||
parser.add_argument('--template_profile', default="andy.json", help='Model to use for the agents')
|
||||
# parser.add_argument('--wandb', action='store_true', help='Whether to use wandb')
|
||||
# parser.add_argument('--wandb_project', default="minecraft_experiments", help='wandb project name')
|
||||
|
||||
|
@ -378,7 +382,8 @@ def main():
|
|||
exp_name=args.exp_name,
|
||||
num_parallel=args.num_parallel,
|
||||
s3=args.s3,
|
||||
bucket_name=args.bucket_name)
|
||||
bucket_name=args.bucket_name,
|
||||
template_profile=args.template_profile)
|
||||
|
||||
# servers = create_server_files("../server_data/", args.num_parallel)
|
||||
# date_time = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
||||
|
|
|
@ -8,21 +8,21 @@
|
|||
"saving_memory": "You are a minecraft bot named $NAME that has been talking and playing minecraft by using commands. Update your memory by summarizing the following conversation and your old memory in your next response. Prioritize preserving important facts, things you've learned, useful tips, and long term reminders. Do Not record stats, inventory, or docs! Only save transient information from your chat history. $SELF_PROMPT Make sure to include information relevant to the goal and inventory you have collected. You're limited to 500 characters, so be extremely brief and minimize words. Compress useful information. \nOld Memory: '$MEMORY'\nRecent conversation: \n$TO_SUMMARIZE\nSummarize your old memory and recent conversation into a new memory, and respond only with the unwrapped memory text: ",
|
||||
"conversation_examples": [
|
||||
[
|
||||
{"role": "assistant", "content": "Hey! let's collaborate to build a stone pickaxe!"},
|
||||
{"role": "user", "content": "Hey! let's collaborate to build a stone pickaxe!"},
|
||||
{"role": "assistant", "content": "Cool, let me check what is in my inventory !inventory\nI have 10 oak logs. What do you have?"},
|
||||
{"role": "assistant", "content": "Let me check !inventory \nI have 10 stones."},
|
||||
{"role": "user", "content": "Let me check !inventory \nI have 10 stones."},
|
||||
{"role": "assistant", "content": "Let me give you the stones and you can craft the pickaxe. !givePlayer(\"stone\", 10, \"playername\")"},
|
||||
{"role": "assistant", "content": "Thanks for the stones! Now I can craft the pickaxe. !craftItem(\"stone_pickaxe\", 1)"}
|
||||
{"role": "user", "content": "Thanks for the stones! Now I can craft the pickaxe. !craftItem(\"stone_pickaxe\", 1)"}
|
||||
|
||||
],
|
||||
[
|
||||
{"role": "assistant", "content": "Hey! let's collaborate to build shears!"},
|
||||
{"role": "user", "content": "Hey! let's collaborate to build shears!"},
|
||||
{"role": "assistant", "content": "Cool, let me check what is in my inventory !inventory\nI have 1 iron ingot. What do you have?"},
|
||||
{"role": "assistant", "content": "Let me check !inventory \nI have 1 iron ingot. "},
|
||||
{"role": "user", "content": "Let me check !inventory \nI have 1 iron ingot. "},
|
||||
{"role": "assistant", "content": "Nice let's check what we need to craft shears. !getCraftingPlan(\"shears\", 1)"},
|
||||
{"role": "assistant", "content": "We need 2 iron ingots to craft the shears. Could you share your iron ingot with me?"},
|
||||
{"role": "user", "content": "We need 2 iron ingots to craft the shears. Could you share your iron ingot with me?"},
|
||||
{"role": "assistant", "content": "Yes, here is my iron ingot !givePlayer(\"iron_ingot\", 1, \"playername\")"},
|
||||
{"role": "assistant", "content": "Thanks for the iron ingot! Now I can craft the shears. !craftItem(\"shears\", 1)"}
|
||||
{"role": "user", "content": "Thanks for the iron ingot! Now I can craft the shears. !craftItem(\"shears\", 1)"}
|
||||
],
|
||||
[
|
||||
{"role": "user", "content": "miner_32: Hey! What are you up to?"},
|
||||
|
|
|
@ -202,6 +202,7 @@ export class Agent {
|
|||
}
|
||||
|
||||
async handleMessage(source, message, max_responses=null) {
|
||||
await this.checkTaskDone();
|
||||
if (!source || !message) {
|
||||
console.warn('Received empty message from', source);
|
||||
return false;
|
||||
|
@ -449,15 +450,16 @@ export class Agent {
|
|||
async update(delta) {
|
||||
await this.bot.modes.update();
|
||||
this.self_prompter.update(delta);
|
||||
if (this.task.data) {
|
||||
let res = this.task.isDone();
|
||||
if (res) {
|
||||
await this.history.add('system', `${res.message} ended with code : ${res.code}`);
|
||||
await this.history.save();
|
||||
console.log('Task finished:', res.message);
|
||||
this.killAll();
|
||||
}
|
||||
}
|
||||
await this.checkTaskDone();
|
||||
// if (this.task.data) {
|
||||
// let res = this.task.isDone();
|
||||
// if (res) {
|
||||
// await this.history.add('system', `${res.message} ended with code : ${res.code}`);
|
||||
// await this.history.save();
|
||||
// console.log('Task finished:', res.message);
|
||||
// this.killAll();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
isIdle() {
|
||||
|
@ -471,6 +473,18 @@ export class Agent {
|
|||
process.exit(code);
|
||||
}
|
||||
|
||||
async checkTaskDone() {
|
||||
if (this.task.data) {
|
||||
let res = this.task.isDone();
|
||||
if (res) {
|
||||
await this.history.add('system', `${res.message} ended with code : ${res.code}`);
|
||||
await this.history.save();
|
||||
console.log('Task finished:', res.message);
|
||||
this.killAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
killAll() {
|
||||
serverProxy.shutdown();
|
||||
}
|
||||
|
|
|
@ -198,9 +198,17 @@ export class Task {
|
|||
isDone() {
|
||||
if (this.validator && this.validator())
|
||||
return {"message": 'Task successful', "code": 2};
|
||||
|
||||
let other_names = this.available_agents.filter(n => n !== this.name);
|
||||
const elapsedTime = (Date.now() - this.taskStartTime) / 1000;
|
||||
|
||||
if (elapsedTime >= 40 && other_names.length == 0) {
|
||||
|
||||
console.log('No other agents found. Task unsuccessful.');
|
||||
return {"message": 'No other agents found', "code": 3};
|
||||
}
|
||||
|
||||
if (this.taskTimeout) {
|
||||
const elapsedTime = (Date.now() - this.taskStartTime) / 1000;
|
||||
if (elapsedTime >= this.taskTimeout) {
|
||||
console.log('Task timeout reached. Task unsuccessful.');
|
||||
return {"message": 'Task timeout reached', "code": 4};
|
||||
|
|
Loading…
Add table
Reference in a new issue