mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-03-28 14:56:24 +01:00
commit
afe43c000e
5 changed files with 45 additions and 30 deletions
|
@ -38,10 +38,9 @@
|
|||
],
|
||||
|
||||
[
|
||||
{"role": "system", "content": "work together with the other bot"},
|
||||
{"role": "assistant", "content": "!startConversation(\"terrance\", \"Hey gpt! Let's work together on this.\"))"},
|
||||
{"role": "user", "content": "terrance: (FROM OTHER BOT)Sounds good, what should we do first?"},
|
||||
{"role": "assistant", "content": "I'll start by collecting some resources. !collectBlocks('stone', 10)"}
|
||||
{"role": "system", "content": "work together with the other bot to build a house"},
|
||||
{"role": "assistant", "content": "!startConversation(\"terrance\", \"Hey gpt! Let's work together to build a house. Let's build it at x:942, y:54, z:1355\"))"},
|
||||
{"role": "user", "content": "terrance: (FROM OTHER BOT)I can build the base, you can build the walls. !newAction(\"Build a 10x10 wall of a house at x:942, y:54, z:1355\")"}
|
||||
],
|
||||
|
||||
[
|
||||
|
|
|
@ -266,13 +266,12 @@ export const actionsList = [
|
|||
'num': { type: 'int', description: 'The number of times to smelt the item.', domain: [1, Number.MAX_SAFE_INTEGER] }
|
||||
},
|
||||
perform: runAsAction(async (agent, item_name, num) => {
|
||||
let response = await skills.smeltItem(agent.bot, item_name, num);
|
||||
if (response.indexOf('Successfully') !== -1) {
|
||||
// there is a bug where the bot's inventory is not updated after smelting
|
||||
// only updates after a restart
|
||||
agent.cleanKill(response + ' Safely restarting to update inventory.');
|
||||
let success = await skills.smeltItem(agent.bot, item_name, num);
|
||||
if (success) {
|
||||
setTimeout(() => {
|
||||
agent.cleanKill('Safely restarting to update inventory.');
|
||||
}, 500);
|
||||
}
|
||||
return response;
|
||||
})
|
||||
},
|
||||
{
|
||||
|
@ -386,12 +385,12 @@ export const actionsList = [
|
|||
'message': { type: 'string', description: 'The message to send.' },
|
||||
},
|
||||
perform: async function (agent, player_name, message) {
|
||||
if (convoManager.inConversation() && !convoManager.inConversation(player_name))
|
||||
return 'You are already in conversation with other bot.';
|
||||
if (!convoManager.isOtherAgent(player_name))
|
||||
return player_name + ' is not a bot, cannot start conversation.';
|
||||
if (convoManager.inConversation(player_name))
|
||||
agent.history.add('system', 'You are already in conversation with ' + player_name + ' Don\'t use this command to talk to them.');
|
||||
if (convoManager.inConversation() && !convoManager.inConversation(player_name))
|
||||
convoManager.forceEndCurrentConversation();
|
||||
else if (convoManager.inConversation(player_name))
|
||||
agent.history.add('system', 'You are already in conversation with ' + player_name + '. Don\'t use this command to talk to them.');
|
||||
convoManager.startConversation(player_name, message);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -172,19 +172,21 @@ class ConversationManager {
|
|||
async recieveFromBot(sender, recieved) {
|
||||
const convo = this._getConvo(sender);
|
||||
|
||||
if (convo.ignore_until_start && !recieved.start)
|
||||
return;
|
||||
|
||||
// check if any convo is active besides the sender
|
||||
if (Object.values(this.convos).some(c => c.active && c.name !== sender)) {
|
||||
if (this.inConversation() && !this.inConversation(sender)) {
|
||||
this.sendToBot(sender, `I'm talking to someone else, try again later. !endConversation("${sender}")`, false, false);
|
||||
this.endConversation(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (recieved.start) {
|
||||
convo.reset();
|
||||
this.startConversationFromOtherBot(sender);
|
||||
}
|
||||
if (convo.ignore_until_start)
|
||||
return;
|
||||
|
||||
|
||||
this._clearMonitorTimeouts();
|
||||
convo.queue(recieved);
|
||||
|
||||
|
@ -230,10 +232,12 @@ class ConversationManager {
|
|||
endConversation(sender) {
|
||||
if (this.convos[sender]) {
|
||||
this.convos[sender].end();
|
||||
this._stopMonitor();
|
||||
this.activeConversation = null;
|
||||
if (self_prompter_paused && !this.inConversation()) {
|
||||
_resumeSelfPrompter();
|
||||
if (this.activeConversation.name === sender) {
|
||||
this._stopMonitor();
|
||||
this.activeConversation = null;
|
||||
if (self_prompter_paused && !this.inConversation()) {
|
||||
_resumeSelfPrompter();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -246,7 +250,15 @@ class ConversationManager {
|
|||
_resumeSelfPrompter();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
forceEndCurrentConversation() {
|
||||
if (this.activeConversation) {
|
||||
let sender = this.activeConversation.name;
|
||||
this.sendToBot(sender, '!endConversation("' + sender + '")', false, false);
|
||||
this.endConversation(sender);
|
||||
}
|
||||
}
|
||||
|
||||
scheduleSelfPrompter() {
|
||||
self_prompter_paused = true;
|
||||
}
|
||||
|
@ -332,8 +344,8 @@ function _handleFullInMessage(sender, recieved) {
|
|||
let message = _tagMessage(recieved.message);
|
||||
if (recieved.end) {
|
||||
convoManager.endConversation(sender);
|
||||
sender = 'system'; // bot will respond to system instead of the other bot
|
||||
message = `Conversation with ${sender} ended with message: "${message}"`;
|
||||
sender = 'system'; // bot will respond to system instead of the other bot
|
||||
}
|
||||
else if (recieved.start)
|
||||
agent.shut_up = false;
|
||||
|
@ -348,6 +360,8 @@ function _tagMessage(message) {
|
|||
|
||||
async function _resumeSelfPrompter() {
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
self_prompter_paused = false;
|
||||
agent.self_prompter.start();
|
||||
if (self_prompter_paused && !convoManager.inConversation()) {
|
||||
self_prompter_paused = false;
|
||||
agent.self_prompter.start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -230,6 +230,9 @@ export class Prompter {
|
|||
let current_msg_time = this.most_recent_msg_time;
|
||||
for (let i = 0; i < 3; i++) { // try 3 times to avoid hallucinations
|
||||
await this.checkCooldown();
|
||||
if (current_msg_time !== this.most_recent_msg_time) {
|
||||
return '';
|
||||
}
|
||||
let prompt = this.profile.conversing;
|
||||
prompt = await this.replaceStrings(prompt, messages, this.convo_examples);
|
||||
let generation = await this.chat_model.sendRequest(messages, prompt);
|
||||
|
|
|
@ -85,9 +85,9 @@
|
|||
`}
|
||||
</div>
|
||||
</div>
|
||||
<button class="stop-btn" onclick="killAllAgents()">Stop All</button>
|
||||
<button class="stop-btn" onclick="shutdown()">Shutdown</button>
|
||||
`).join('') :
|
||||
`).join('') +
|
||||
`<button class="stop-btn" onclick="killAllAgents()">Stop All</button>
|
||||
<button class="stop-btn" onclick="shutdown()">Shutdown</button>` :
|
||||
'<div class="agent">No agents connected</div>';
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue