mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-06-06 17:25:54 +02:00
dont stack llm requests, remove serialization
This commit is contained in:
parent
cff47d772d
commit
132a535068
3 changed files with 22 additions and 7 deletions
|
@ -96,10 +96,10 @@ class ConversationManager {
|
|||
end,
|
||||
};
|
||||
|
||||
sendBotChatToServer(send_to, JSON.stringify(json));
|
||||
sendBotChatToServer(send_to, json);
|
||||
}
|
||||
|
||||
async recieveFromBot(sender, json) {
|
||||
async recieveFromBot(sender, recieved) {
|
||||
const convo = this._getConvo(sender);
|
||||
|
||||
// check if any convo is active besides the sender
|
||||
|
@ -108,7 +108,6 @@ class ConversationManager {
|
|||
return;
|
||||
}
|
||||
|
||||
const recieved = JSON.parse(json);
|
||||
if (recieved.start) {
|
||||
convo.reset();
|
||||
}
|
||||
|
@ -243,7 +242,7 @@ function _compileInMessages(convo) {
|
|||
}
|
||||
|
||||
function _handleFullInMessage(sender, recieved) {
|
||||
console.log(`responding to **${JSON.stringify(recieved)}**`);
|
||||
console.log(`${agent.name} responding to "${recieved.message}" from ${sender}`);
|
||||
|
||||
const convo = convoManager._getConvo(sender);
|
||||
convo.active = true;
|
||||
|
|
|
@ -34,6 +34,8 @@ export class Prompter {
|
|||
let chat = this.profile.model;
|
||||
this.cooldown = this.profile.cooldown ? this.profile.cooldown : 0;
|
||||
this.last_prompt_time = 0;
|
||||
this.awaiting_convo = false;
|
||||
this.awaiting_coding = false;
|
||||
|
||||
// try to get "max_tokens" parameter, else null
|
||||
let max_tokens = null;
|
||||
|
@ -225,6 +227,11 @@ export class Prompter {
|
|||
}
|
||||
|
||||
async promptConvo(messages) {
|
||||
if (this.awaiting_convo) {
|
||||
console.warn('Already awaiting conversation response, returning no response.');
|
||||
return '';
|
||||
}
|
||||
this.awaiting_convo = true;
|
||||
for (let i = 0; i < 3; i++) { // try 3 times to avoid hallucinations
|
||||
await this.checkCooldown();
|
||||
let prompt = this.profile.conversing;
|
||||
|
@ -236,16 +243,25 @@ export class Prompter {
|
|||
console.warn('LLM hallucinated message as another bot. Trying again...');
|
||||
continue;
|
||||
}
|
||||
this.awaiting_convo = false;
|
||||
return generation;
|
||||
}
|
||||
return "*no response*";
|
||||
this.awaiting_convo = false;
|
||||
return "";
|
||||
}
|
||||
|
||||
async promptCoding(messages) {
|
||||
if (this.awaiting_coding) {
|
||||
console.warn('Already awaiting coding response, returning no response.');
|
||||
return '';
|
||||
}
|
||||
this.awaiting_coding = true;
|
||||
await this.checkCooldown();
|
||||
let prompt = this.profile.coding;
|
||||
prompt = await this.replaceStrings(prompt, messages, this.coding_examples);
|
||||
return await this.chat_model.sendRequest(messages, prompt);
|
||||
let resp = await this.chat_model.sendRequest(messages, prompt);
|
||||
this.awaiting_coding = false;
|
||||
return resp;
|
||||
}
|
||||
|
||||
async promptMemSaving(to_summarize) {
|
||||
|
|
|
@ -72,7 +72,7 @@ export function createMindServer(port = 8080) {
|
|||
console.warn(`Agent ${agentName} tried to send a message but is not logged in`);
|
||||
return;
|
||||
}
|
||||
console.log(`${curAgentName} sending message to ${agentName}: ${json}`);
|
||||
console.log(`${curAgentName} sending message to ${agentName}: ${json.message}`);
|
||||
inGameAgents[agentName].emit('chat-message', curAgentName, json);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue