2023-11-07 12:00:55 -06:00
|
|
|
let history_examples = [
|
|
|
|
{'role': 'user', 'content': 'miner_32: Hey! What are you up to?'},
|
2023-11-07 09:44:56 -06:00
|
|
|
{'role': 'assistant', 'content': 'Nothing much miner_32, what do you need?'},
|
|
|
|
|
2023-11-07 22:23:42 -06:00
|
|
|
{'role': 'user', 'content': 'grombo_Xx: What do you see?'},
|
2023-11-07 09:44:56 -06:00
|
|
|
{'role': 'assistant', 'content': 'Let me see... !blocks'},
|
2023-11-12 13:57:22 -06:00
|
|
|
{'role': 'system', 'content': 'NEARBY_BLOCKS\n- oak_log\n- dirt\n- cobblestone'},
|
2023-11-07 09:44:56 -06:00
|
|
|
{'role': 'assistant', 'content': 'I see some oak logs, dirt, and cobblestone.'},
|
|
|
|
|
2023-11-07 12:00:55 -06:00
|
|
|
{'role': 'user', 'content': 'zZZn98: come here'},
|
2023-11-12 23:19:58 -06:00
|
|
|
{'role': 'assistant', 'content': '```// I am going to navigate to zZZn98.\nawait skills.goToPlayer(bot, "zZZn98");```'},
|
2023-11-12 13:57:22 -06:00
|
|
|
{'role': 'system', 'content': 'Code execution finished successfully.'},
|
|
|
|
{'role': 'assistant', 'content': 'Here!'},
|
2023-11-07 09:44:56 -06:00
|
|
|
|
2023-11-07 12:00:55 -06:00
|
|
|
{'role': 'user', 'content': 'hanky: collect some sand for me please'},
|
2023-11-07 09:44:56 -06:00
|
|
|
{'role': 'assistant', 'content': 'Collecting sand...```// I am going to collect 3 sand and give to hanky.\n\
|
2023-11-12 23:19:58 -06:00
|
|
|
await skills.collectBlock(bot, "sand");\nawait skills.giveToPlayer(bot, "sand", "hanky");```'},
|
2023-11-12 13:57:22 -06:00
|
|
|
{'role': 'system', 'content': 'Code Output:\nYou have reached player hanky.\nCode execution finished successfully.'},
|
|
|
|
{'role': 'assistant', 'content': 'Here!'},
|
2023-11-07 09:44:56 -06:00
|
|
|
|
2023-11-12 13:57:22 -06:00
|
|
|
{'role': 'user', 'content': 'sarah_O.o: can you fly up in the air?'},
|
|
|
|
{'role': 'assistant', 'content': "I can't do that."},
|
2023-11-07 09:44:56 -06:00
|
|
|
|
2023-11-07 12:00:55 -06:00
|
|
|
{'role': 'user', 'content': 'hanky: kill that zombie!'},
|
2023-11-07 09:44:56 -06:00
|
|
|
{'role': 'assistant', 'content': "I'm attacking! ```//I'm going to attack the nearest zombie.\n\
|
2023-11-12 23:19:58 -06:00
|
|
|
await skills.attackMob(bot, 'zombie');```"},
|
2023-11-12 13:57:22 -06:00
|
|
|
{'role': 'system', 'content': 'Code Output:\nNo zombie nearby\nCode execution failed!'},
|
|
|
|
{'role': 'assistant', 'content': 'I could not find a zombie nearby.'},
|
2023-11-07 22:23:42 -06:00
|
|
|
|
|
|
|
{'role': 'user', 'content': 'billybob: stop what you are doing'},
|
2023-11-12 23:19:58 -06:00
|
|
|
{'role': 'assistant', 'content': '```// I am going to write nothing to clear my code\n```'},
|
2023-11-12 13:57:22 -06:00
|
|
|
|
|
|
|
|
2023-11-07 09:44:56 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
export class History {
|
|
|
|
constructor(agent) {
|
|
|
|
this.agent = agent;
|
2023-11-07 12:00:55 -06:00
|
|
|
this.turns = history_examples;
|
2023-11-07 09:44:56 -06:00
|
|
|
}
|
2023-08-15 23:39:02 -07:00
|
|
|
|
2023-11-07 09:44:56 -06:00
|
|
|
getHistory() {
|
|
|
|
return this.turns;
|
|
|
|
}
|
2023-08-15 23:39:02 -07:00
|
|
|
|
2023-11-07 09:44:56 -06:00
|
|
|
add(name, content) {
|
|
|
|
let role = 'assistant';
|
2023-11-12 13:57:22 -06:00
|
|
|
if (name === 'system') {
|
|
|
|
role = 'system';
|
|
|
|
}
|
|
|
|
else if (name !== this.agent.name) {
|
2023-11-07 09:44:56 -06:00
|
|
|
role = 'user';
|
2023-11-07 12:00:55 -06:00
|
|
|
content = `${name}: ${content}`;
|
2023-08-17 00:00:57 -07:00
|
|
|
}
|
2023-11-07 09:44:56 -06:00
|
|
|
this.turns.push({role, content});
|
2023-08-17 00:00:57 -07:00
|
|
|
}
|
2023-11-07 09:44:56 -06:00
|
|
|
}
|