From 0d4a67aaeb9e88a569fc47d63ecf4577838635af Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Fri, 11 Oct 2024 21:12:52 -0500 Subject: [PATCH] unsupported embeddings fall back on word overlap --- profiles/llama.json | 2 ++ src/utils/examples.js | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/profiles/llama.json b/profiles/llama.json index e805945..bc49cf7 100644 --- a/profiles/llama.json +++ b/profiles/llama.json @@ -5,6 +5,8 @@ "max_tokens": 8000, + "embedding": "openai", + "conversing": "You are a playful Minecraft bot named $NAME that can converse with players, see, move, mine, build, and interact with the world by using commands.\n$SELF_PROMPT Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'Sure, I've stopped.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer('playername', 3)'. This is extremely important to me, take a deep breath and have fun :)\n$MEMORY\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:", "coding": "You are an intelligent mineflayer bot $NAME that plays minecraft by writing javascript codeblocks. Given the conversation between you and the user, use the provided skills and world functions to write a js codeblock that controls the mineflayer bot ``` // using this syntax ```. The code will be executed and you will recieve it's output. If you are satisfied with the response, respond without a codeblock in a conversational way. If something major went wrong, like an error or complete failure, write another codeblock and try to fix the problem. Minor mistakes are acceptable. Be maximally efficient, creative, and clear. Do not use commands !likeThis, only use codeblocks. The code is asynchronous and MUST CALL AWAIT for all async function calls. DO NOT write an immediately-invoked function expression without using `await`!! Use double-quotes for strings, not singles. Don't write long paragraphs and lists in your responses unless explicitly asked! Only summarize the code you write with a sentence or two when done. This is extremely important to me, think step-by-step, take a deep breath and good luck! \n$SELF_PROMPT\n$MEMORY\n$STATS\n$INVENTORY\n$CODE_DOCS\n$EXAMPLES\nConversation:", diff --git a/src/utils/examples.js b/src/utils/examples.js index 5307642..eb8ce32 100644 --- a/src/utils/examples.js +++ b/src/utils/examples.js @@ -31,13 +31,19 @@ export class Examples { async load(examples) { this.examples = examples; - if (this.model !== null) { - const embeddingPromises = this.examples.map(async (example) => { - let turn_text = this.turnsToText(example); - this.embeddings[turn_text] = await this.model.embed(turn_text); - }); - await Promise.all(embeddingPromises); + try { + if (this.model !== null) { + const embeddingPromises = this.examples.map(async (example) => { + let turn_text = this.turnsToText(example); + this.embeddings[turn_text] = await this.model.embed(turn_text); + }); + await Promise.all(embeddingPromises); + } + } catch (err) { + console.warn('Error with embedding model, using word overlap instead.'); + this.model = null; } + } async getRelevant(turns) {