From 76204664cd4c4d4bac455ae3ca88925d9b2bb496 Mon Sep 17 00:00:00 2001 From: uukelele-scratch Date: Sun, 9 Mar 2025 17:17:41 +0000 Subject: [PATCH] added searchwiki action --- package.json | 1 + profiles/gemini.json | 2 +- settings.js | 4 ++-- src/agent/commands/actions.js | 26 ++++++++++++++++++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 817a37e..003df5f 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "@huggingface/inference": "^2.8.1", "@mistralai/mistralai": "^1.1.0", "canvas": "^3.1.0", + "cheerio": "^1.0.0", "express": "^4.18.2", "google-translate-api-x": "^10.7.1", "groq-sdk": "^0.15.0", diff --git a/profiles/gemini.json b/profiles/gemini.json index 4f3cf43..9331aed 100644 --- a/profiles/gemini.json +++ b/profiles/gemini.json @@ -1,7 +1,7 @@ { "name": "gemini", - "model": "gemini-1.5-flash", + "model": "gemini-2.0-flash", "cooldown": 10000 } \ No newline at end of file diff --git a/settings.js b/settings.js index c226658..76fca5f 100644 --- a/settings.js +++ b/settings.js @@ -13,10 +13,10 @@ export default // the base profile is shared by all bots for default prompts/examples/modes "base_profile": "./profiles/defaults/survival.json", // also see creative.json, god_mode.json "profiles": ((process.env.PROFILES) && JSON.parse(process.env.PROFILES)) || [ - "./andy.json", + // "./andy.json", // "./profiles/gpt.json", // "./profiles/claude.json", - // "./profiles/gemini.json", + "./profiles/gemini.json", // "./profiles/llama.json", // "./profiles/qwen.json", // "./profiles/mistral.json", diff --git a/src/agent/commands/actions.js b/src/agent/commands/actions.js index 19b231e..ab444d7 100644 --- a/src/agent/commands/actions.js +++ b/src/agent/commands/actions.js @@ -1,6 +1,7 @@ import * as skills from '../library/skills.js'; import settings from '../../../settings.js'; import convoManager from '../conversation.js'; +import { load } from 'cheerio'; function runAsAction (actionFn, resume = false, timeout = -1) { let actionLabel = null; // Will be set on first use @@ -354,6 +355,31 @@ export const actionsList = [ return `Mode ${mode_name} is now ${on ? 'on' : 'off'}.`; } }, + { + name: '!searchWiki', + description: 'Search the Minecraft Wiki for the given query.', + params: { + 'query': { type: 'string', description: 'The query to search for.' } + }, + perform: async function (agent, query) { + const url = `https://minecraft.wiki/w/${query}` + try { + const response = await fetch(url); + if (response.status === 404) { + return `${query} was not found on the Minecraft Wiki. Try adjusting your search term.`; + } + const html = await response.text(); + const $ = load(html); + + const divContent = $("div.mw-parser-output").text(); + + return divContent.trim(); + } catch (error) { + console.error("Error fetching or parsing HTML:", error); + return `The following error occured: ${error}` + } + } + }, { name: '!goal', description: 'Set a goal prompt to endlessly work towards with continuous self-prompting.',