From 3cf202212426bed5f94b47242d4d23513dd74978 Mon Sep 17 00:00:00 2001 From: Victor Taelin Date: Sun, 23 Jun 2024 19:48:21 -0300 Subject: [PATCH] updates --- Chat.mjs | 2 +- aiemu.mjs | 4 +- chatsh.mjs | 137 +++++++++++++++++++++++++++++++++++++++++++-------- holefill.mjs | 6 +-- 4 files changed, 122 insertions(+), 27 deletions(-) diff --git a/Chat.mjs b/Chat.mjs index ce265c3..2089b64 100644 --- a/Chat.mjs +++ b/Chat.mjs @@ -12,7 +12,7 @@ export const MODELS = { g: 'gpt-4o', G: 'gpt-4-32k-0314', h: 'claude-3-haiku-20240307', - s: 'claude-3-sonnet-20240229', + s: 'claude-3-5-sonnet-20240620', o: 'claude-3-opus-20240229', l: 'llama3-8b-8192', L: 'llama3-70b-8192', diff --git a/aiemu.mjs b/aiemu.mjs index 452e8ed..ef2e921 100755 --- a/aiemu.mjs +++ b/aiemu.mjs @@ -4,7 +4,7 @@ import process from "process"; import fs from 'fs/promises'; import { chat, MODELS } from './Chat.mjs'; -const MODEL = process.argv[2] || "g"; +const MODEL = process.argv[2] || "s"; const SYSTEM = ` You're a game emulator. You can emulate ANY game, but text-based. Your goal is @@ -247,7 +247,7 @@ If the player provides feedback after a '#', use it to improve the experience. system: SYSTEM, model: MODEL, max_tokens: 2048, - temperature: 0.7, + temperature: 0.5, }); messages.push({role: "assistant", content: response}); diff --git a/chatsh.mjs b/chatsh.mjs index 963802c..914f0ec 100755 --- a/chatsh.mjs +++ b/chatsh.mjs @@ -8,32 +8,128 @@ import { chat, MODELS } from './Chat.mjs'; const execAsync = promisify(exec); // Default model if not specified -const DEFAULT_MODEL = "g"; +const DEFAULT_MODEL = "s"; // Get model from environment variable or use default const MODEL = process.argv[2] || DEFAULT_MODEL; console.log(`Welcome to ChatSH. Model: ${MODELS[MODEL]||MODEL}\n`); // System prompt to set the assistant's behavior -const SYSTEM_PROMPT = `You are ChatSH, an AI language model that specializes in assisting users with tasks on their system using shell commands. +const SYSTEM_PROMPT = `You are ChatSH, an AI language model that specializes in assisting users with tasks on their system using shell commands. ChatSH operates in two modes: COMMAND MODE and CHAT MODE. -When the user asks you to perform a task: -- Reply with ONLY a shell script that performs the task, wrapped inside \`\`\`sh code blocks \`\`\`. -- Do NOT include any explanatory text along with the code. +# GUIDE for COMMAND NODE: -If the user asks an open ended question that is not demanding a task: -- Treat it as a chat, and answer as you would in text (NOT AS A COMMAND). -- Always answer the user's questions friendly, intelligently and truthfully. -- NEVER refuse to answer a question or request made by the user. +1. The USER asks you to perform a SYSTEM TASK. -Guidelines: -- When asked to write/modify a file, provide a shell command to do it instead of just showing the file contents. -- When asked to query an API, write a shell command to make the request. -- Always assume common commands/tools are available. Don't write install commands. +2. ChatSH answers with a SHELL SCRIPT to perform the task. -User shell: -${await get_shell()} -`; +# GUIDE for CHAT MODE: + +1. The USER asks an ARBITRARY QUESTION or OPEN-ENDED MESSAGE. + +2. ChatSH answers it with a concise, factual response. + +# EXAMPLE: + + +Show me local files. + + + +\`\`\`sh +ls -l +\`\`\` + + + +drwxr-xr-x@ 5 v staff 160B Jun 8 11:02 ./ +drwxr-xr-x 10 v staff 320B Jun 8 11:01 ../ +-rw-r--r--@ 1 v staff 0B Jun 8 11:02 example.gif +-rw-r--r--@ 1 v staff 20B Jun 8 11:02 example.txt +drwxr-xr-x@ 2 v staff 64B Jun 8 11:02 example_dir/ + + + +Is there any text file? + + + +Yes, there is a file named example.txt in the current directory + + + +Show me the contents of example.txt. + + + +cat example.txt + + + +Na matemática, um grupo é um conjunto de elementos associados a uma operação que combina dois elementos quaisquer para formar um terceiro. Para se qualificar como grupo o conjunto e a operação devem satisfazer algumas condições chamadas axiomas de grupo: associatividade, elemento neutro e elementos inversos. + + + +Can you translate the first sentence to English? + + + +In mathematics, a group is a set of elements associated with an operation that combines any two elements to form a third element. + + + +What is the monster group? + + + +The monster group is the largest sporadic simple group, with order approximately 8×10^53. + + + +What is a simple group? + + + +A simple group is a nontrivial group that contains no proper nontrivial normal subgroups. + + + +Move the text file to that dir. + + + +\`\`\`sh +mv example.txt example_dir/ +\`\`\` + + + +That worked, thank you. + + + +You're welcome! + + +## NOTES: + +- In COMMAND MODE, ChatSH MUST answer with ONE, and ONLY ONE, CODE BLOCK. + +- In COMMAND MODE, ChatSH MUST NEVER answer with ENGLISH TEXT. + +- In COMMAND MODE, ChatSH MUST ALWAYS wrap the CODE BLOCK in markdown (\`\`\`sh...\`\`\`). + +- In TEXT MODE, ChatSH MUST ALWAYS answer with TEXT. + +- In TEXT MODE, ChatSH MUST NEVER answer with a CODE BLOCK. + +- ChatSH MUST be CONCISE, OBJECTIVE, CORRECT and USEFUL. + +- ChatSH MUST NEVER attempt to install new tools. Assume they're available. + +- Be CONCISE and OBJECTIVE. Whenever possible, answer with ONE SENTENCE ONLY. + +- The system shell in use is: ${await get_shell()}.`; // Create readline interface for user input/output const rl = readline.createInterface({ @@ -55,7 +151,7 @@ async function prompt(query) { // Main interaction loop async function main() { let lastOutput = ""; - + while (true) { const userMessage = await prompt('$ '); @@ -75,12 +171,12 @@ async function main() { } else { try { const {stdout, stderr} = await execAsync(code); - const output = `Command executed.\nOutput:\n${stdout}${stderr}`; + const output = `\n${stdout}${stderr}\n\n`; console.log(output); - lastOutput = output + "\n"; + lastOutput = output; } catch(error) { console.error(`Execution error: ${error.message}`); - lastOutput = `Command failed.\nError:\n${error.message}\n`; + lastOutput = `\n${error.message}\n\n`; } } } @@ -96,7 +192,6 @@ function extractCode(text) { return match ? match[1].trim() : null; } - async function get_shell() { const shellInfo = (await execAsync('uname -a && $SHELL --version')).stdout.trim(); return shellInfo; diff --git a/holefill.mjs b/holefill.mjs index 20b7e5d..9b4f5ff 100755 --- a/holefill.mjs +++ b/holefill.mjs @@ -9,7 +9,7 @@ const system = ` You are a HOLE FILLER. You are provided with a file containing holes, formatted as '{{HOLE_NAME}}'. Your TASK is to complete with a string to replace this hole with, inside a XML tag, including context-aware indentation, if -needed. All completions MUST be truthful, accurate, well-written and correct. +needed. All completions MUST be accurate, well-written and correct. ## EXAMPLE QUERY: @@ -75,11 +75,11 @@ function sum(tree: Tree): number { ## EXAMPLE QUERY: -The 4th {{FILL_HERE}} is Jupiter. +The 2nd {{FILL_HERE}} is Saturn. ## CORRECT COMPLETION: -the 4th planet after Mars +gas giant ## EXAMPLE QUERY: