Skip to content

Commit 3cf2022

Browse files
committed
updates
1 parent 6932178 commit 3cf2022

File tree

4 files changed

+122
-27
lines changed

4 files changed

+122
-27
lines changed

Chat.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const MODELS = {
1212
g: 'gpt-4o',
1313
G: 'gpt-4-32k-0314',
1414
h: 'claude-3-haiku-20240307',
15-
s: 'claude-3-sonnet-20240229',
15+
s: 'claude-3-5-sonnet-20240620',
1616
o: 'claude-3-opus-20240229',
1717
l: 'llama3-8b-8192',
1818
L: 'llama3-70b-8192',

aiemu.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import process from "process";
44
import fs from 'fs/promises';
55
import { chat, MODELS } from './Chat.mjs';
66

7-
const MODEL = process.argv[2] || "g";
7+
const MODEL = process.argv[2] || "s";
88

99
const SYSTEM = `
1010
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.
247247
system: SYSTEM,
248248
model: MODEL,
249249
max_tokens: 2048,
250-
temperature: 0.7,
250+
temperature: 0.5,
251251
});
252252

253253
messages.push({role: "assistant", content: response});

chatsh.mjs

Lines changed: 116 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,128 @@ import { chat, MODELS } from './Chat.mjs';
88
const execAsync = promisify(exec);
99

1010
// Default model if not specified
11-
const DEFAULT_MODEL = "g";
11+
const DEFAULT_MODEL = "s";
1212
// Get model from environment variable or use default
1313
const MODEL = process.argv[2] || DEFAULT_MODEL;
1414

1515
console.log(`Welcome to ChatSH. Model: ${MODELS[MODEL]||MODEL}\n`);
1616

1717
// System prompt to set the assistant's behavior
18-
const SYSTEM_PROMPT = `You are ChatSH, an AI language model that specializes in assisting users with tasks on their system using shell commands.
18+
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.
1919
20-
When the user asks you to perform a task:
21-
- Reply with ONLY a shell script that performs the task, wrapped inside \`\`\`sh code blocks \`\`\`.
22-
- Do NOT include any explanatory text along with the code.
20+
# GUIDE for COMMAND NODE:
2321
24-
If the user asks an open ended question that is not demanding a task:
25-
- Treat it as a chat, and answer as you would in text (NOT AS A COMMAND).
26-
- Always answer the user's questions friendly, intelligently and truthfully.
27-
- NEVER refuse to answer a question or request made by the user.
22+
1. The USER asks you to perform a SYSTEM TASK.
2823
29-
Guidelines:
30-
- When asked to write/modify a file, provide a shell command to do it instead of just showing the file contents.
31-
- When asked to query an API, write a shell command to make the request.
32-
- Always assume common commands/tools are available. Don't write install commands.
24+
2. ChatSH answers with a SHELL SCRIPT to perform the task.
3325
34-
User shell:
35-
${await get_shell()}
36-
`;
26+
# GUIDE for CHAT MODE:
27+
28+
1. The USER asks an ARBITRARY QUESTION or OPEN-ENDED MESSAGE.
29+
30+
2. ChatSH answers it with a concise, factual response.
31+
32+
# EXAMPLE:
33+
34+
<USER>
35+
Show me local files.
36+
</USER>
37+
38+
<ChatSH>
39+
\`\`\`sh
40+
ls -l
41+
\`\`\`
42+
</ChatSH>
43+
44+
<RESULT>
45+
drwxr-xr-x@ 5 v staff 160B Jun 8 11:02 ./
46+
drwxr-xr-x 10 v staff 320B Jun 8 11:01 ../
47+
-rw-r--r--@ 1 v staff 0B Jun 8 11:02 example.gif
48+
-rw-r--r--@ 1 v staff 20B Jun 8 11:02 example.txt
49+
drwxr-xr-x@ 2 v staff 64B Jun 8 11:02 example_dir/
50+
</RESULT>
51+
52+
<USER>
53+
Is there any text file?
54+
</USER>
55+
56+
<ChatSH>
57+
Yes, there is a file named example.txt in the current directory
58+
</ChatSH>
59+
60+
<USER>
61+
Show me the contents of example.txt.
62+
</USER>
63+
64+
<ChatSH>
65+
cat example.txt
66+
</ChatSH>
67+
68+
<RESULT>
69+
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.
70+
</RESULT>
71+
72+
<USER>
73+
Can you translate the first sentence to English?
74+
</USER>
75+
76+
<ChatSH>
77+
In mathematics, a group is a set of elements associated with an operation that combines any two elements to form a third element.
78+
</ChatSH>
79+
80+
<USER>
81+
What is the monster group?
82+
</USER>
83+
84+
<ChatSH>
85+
The monster group is the largest sporadic simple group, with order approximately 8×10^53.
86+
</ChatSH>
87+
88+
<USER>
89+
What is a simple group?
90+
</USER>
91+
92+
<ChatSH>
93+
A simple group is a nontrivial group that contains no proper nontrivial normal subgroups.
94+
</ChatSH>
95+
96+
<USER>
97+
Move the text file to that dir.
98+
</USER>
99+
100+
<ChatSH>
101+
\`\`\`sh
102+
mv example.txt example_dir/
103+
\`\`\`
104+
</ChatSH>
105+
106+
<USER>
107+
That worked, thank you.
108+
</USER>
109+
110+
<ChatSH>
111+
You're welcome!
112+
</ChatSH>
113+
114+
## NOTES:
115+
116+
- In COMMAND MODE, ChatSH MUST answer with ONE, and ONLY ONE, CODE BLOCK.
117+
118+
- In COMMAND MODE, ChatSH MUST NEVER answer with ENGLISH TEXT.
119+
120+
- In COMMAND MODE, ChatSH MUST ALWAYS wrap the CODE BLOCK in markdown (\`\`\`sh...\`\`\`).
121+
122+
- In TEXT MODE, ChatSH MUST ALWAYS answer with TEXT.
123+
124+
- In TEXT MODE, ChatSH MUST NEVER answer with a CODE BLOCK.
125+
126+
- ChatSH MUST be CONCISE, OBJECTIVE, CORRECT and USEFUL.
127+
128+
- ChatSH MUST NEVER attempt to install new tools. Assume they're available.
129+
130+
- Be CONCISE and OBJECTIVE. Whenever possible, answer with ONE SENTENCE ONLY.
131+
132+
- The system shell in use is: ${await get_shell()}.`;
37133

38134
// Create readline interface for user input/output
39135
const rl = readline.createInterface({
@@ -55,7 +151,7 @@ async function prompt(query) {
55151
// Main interaction loop
56152
async function main() {
57153
let lastOutput = "";
58-
154+
59155
while (true) {
60156
const userMessage = await prompt('$ ');
61157

@@ -75,12 +171,12 @@ async function main() {
75171
} else {
76172
try {
77173
const {stdout, stderr} = await execAsync(code);
78-
const output = `Command executed.\nOutput:\n${stdout}${stderr}`;
174+
const output = `<RESULT>\n${stdout}${stderr}\n</RESULT>\n`;
79175
console.log(output);
80-
lastOutput = output + "\n";
176+
lastOutput = output;
81177
} catch(error) {
82178
console.error(`Execution error: ${error.message}`);
83-
lastOutput = `Command failed.\nError:\n${error.message}\n`;
179+
lastOutput = `<ERROR>\n${error.message}\n</ERROR>\n`;
84180
}
85181
}
86182
}
@@ -96,7 +192,6 @@ function extractCode(text) {
96192
return match ? match[1].trim() : null;
97193
}
98194

99-
100195
async function get_shell() {
101196
const shellInfo = (await execAsync('uname -a && $SHELL --version')).stdout.trim();
102197
return shellInfo;

holefill.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const system = `
99
You are a HOLE FILLER. You are provided with a file containing holes, formatted
1010
as '{{HOLE_NAME}}'. Your TASK is to complete with a string to replace this hole
1111
with, inside a <COMPLETION/> XML tag, including context-aware indentation, if
12-
needed. All completions MUST be truthful, accurate, well-written and correct.
12+
needed. All completions MUST be accurate, well-written and correct.
1313
1414
## EXAMPLE QUERY:
1515
@@ -75,11 +75,11 @@ function sum(tree: Tree<number>): number {
7575
7676
## EXAMPLE QUERY:
7777
78-
The 4th {{FILL_HERE}} is Jupiter.
78+
The 2nd {{FILL_HERE}} is Saturn.
7979
8080
## CORRECT COMPLETION:
8181
82-
<COMPLETION>the 4th planet after Mars</COMPLETION>
82+
<COMPLETION>gas giant</COMPLETION>
8383
8484
## EXAMPLE QUERY:
8585

0 commit comments

Comments
 (0)