better examples, little model fixes, less chatty

This commit is contained in:
MaxRobinsonTheGreat 2024-12-12 19:42:29 -06:00
parent 13bd9a7bba
commit ae99cedec5
6 changed files with 31 additions and 18 deletions

View file

@ -32,7 +32,9 @@
{"role": "system", "content": "say hi to john_goodman"}, {"role": "system", "content": "say hi to john_goodman"},
{"role": "assistant", "content": "!startConversation(\"john_goodman\", \"Hey John\"))"}, {"role": "assistant", "content": "!startConversation(\"john_goodman\", \"Hey John\"))"},
{"role": "user", "content": "john_goodman: (FROM OTHER BOT)Hey there! What's up?"}, {"role": "user", "content": "john_goodman: (FROM OTHER BOT)Hey there! What's up?"},
{"role": "assistant", "content": "Hey John, not much. Just saying hi. Bye! !endConversation('john_goodman')"} {"role": "assistant", "content": "Hey John, not much. Just saying hi."},
{"role": "user", "content": "john_goodman: (FROM OTHER BOT)Bye!"},
{"role": "assistant", "content": "Bye! !endConversation('john_goodman')"}
], ],
[ [

View file

@ -1,5 +1,5 @@
{ {
"name": "grok", "name": "Grok",
"model": "grok-beta", "model": "grok-beta",

View file

@ -1,15 +1,13 @@
{ {
"name": "qwen", "name": "qwen",
"cooldown": 5000,
"model": { "model": {
"api": "qwen", "api": "qwen",
"url": "https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation", "url": "https://dashscope-intl.aliyuncs.com/api/v1/services/aigc/text-generation/generation",
"model": "qwen-max" "model": "qwen-max"
}, },
"embedding": { "embedding": "openai"
"api": "qwen",
"url": "https://dashscope.aliyuncs.com/api/v1/services/embeddings/text-embedding/text-embedding",
"model": "text-embedding-v2"
}
} }

View file

@ -310,6 +310,7 @@ export class Agent {
} }
async routeResponse(to_player, message) { async routeResponse(to_player, message) {
if (this.shut_up) return;
let self_prompt = to_player === 'system' || to_player === this.name; let self_prompt = to_player === 'system' || to_player === this.name;
if (self_prompt && this.last_sender) { if (self_prompt && this.last_sender) {
// this is for when the agent is prompted by system while still in conversation // this is for when the agent is prompted by system while still in conversation

View file

@ -134,7 +134,7 @@ class ConversationManager {
convo.active = true; convo.active = true;
this.activeConversation = convo; this.activeConversation = convo;
this._startMonitor(); this._startMonitor();
this.sendToBot(send_to, message, true); this.sendToBot(send_to, message, true, false);
} }
startConversationFromOtherBot(name) { startConversationFromOtherBot(name) {
@ -144,14 +144,14 @@ class ConversationManager {
this._startMonitor(); this._startMonitor();
} }
sendToBot(send_to, message, start=false) { sendToBot(send_to, message, start=false, open_chat=true) {
if (!this.isOtherAgent(send_to)) { if (!this.isOtherAgent(send_to)) {
agent.bot.whisper(send_to, message); console.warn(`${agent.name} tried to send bot message to non-bot ${send_to}`);
return; return;
} }
const convo = this._getConvo(send_to); const convo = this._getConvo(send_to);
if (settings.chat_bot_messages && !start) if (settings.chat_bot_messages && open_chat)
agent.openChat(`(To ${send_to}) ${message}`); agent.openChat(`(To ${send_to}) ${message}`);
if (convo.ignore_until_start) if (convo.ignore_until_start)
@ -174,7 +174,7 @@ class ConversationManager {
// check if any convo is active besides the sender // check if any convo is active besides the sender
if (Object.values(this.convos).some(c => c.active && c.name !== sender)) { if (Object.values(this.convos).some(c => c.active && c.name !== sender)) {
this.sendToBot(sender, `I'm talking to someone else, try again later. !endConversation("${sender}")`); this.sendToBot(sender, `I'm talking to someone else, try again later. !endConversation("${sender}")`, false, false);
return; return;
} }
@ -240,7 +240,7 @@ class ConversationManager {
endAllConversations() { endAllConversations() {
for (const sender in this.convos) { for (const sender in this.convos) {
this.convos[sender].end(); this.endConversation(sender);
} }
if (self_prompter_paused) { if (self_prompter_paused) {
_resumeSelfPrompter(); _resumeSelfPrompter();

View file

@ -897,10 +897,7 @@ export async function giveToPlayer(bot, itemType, username, num=1) {
} }
// if we are too close, make some distance // if we are too close, make some distance
if (bot.entity.position.distanceTo(player.position) < 2) { if (bot.entity.position.distanceTo(player.position) < 2) {
let goal = new pf.goals.GoalNear(player.position.x, player.position.y, player.position.z, 2); await moveAwayFromEntity(bot, player, 2);
let inverted_goal = new pf.goals.GoalInvert(goal);
bot.pathfinder.setMovements(new pf.Movements(bot));
await bot.pathfinder.goto(inverted_goal);
} }
await bot.lookAt(player.position); await bot.lookAt(player.position);
if (await discard(bot, itemType, num)) { if (await discard(bot, itemType, num)) {
@ -1106,6 +1103,21 @@ export async function moveAway(bot, distance) {
return true; return true;
} }
export async function moveAwayFromEntity(bot, entity, distance=16) {
/**
* Move away from the given entity.
* @param {MinecraftBot} bot, reference to the minecraft bot.
* @param {Entity} entity, the entity to move away from.
* @param {number} distance, the distance to move away.
* @returns {Promise<boolean>} true if the bot moved away, false otherwise.
**/
let goal = new pf.goals.GoalFollow(entity, distance);
let inverted_goal = new pf.goals.GoalInvert(goal);
bot.pathfinder.setMovements(new pf.Movements(bot));
await bot.pathfinder.goto(inverted_goal);
return true;
}
export async function avoidEnemies(bot, distance=16) { export async function avoidEnemies(bot, distance=16) {
/** /**
* Move a given distance away from all nearby enemy mobs. * Move a given distance away from all nearby enemy mobs.