some configuration options

This commit is contained in:
Eri Ishihara 2025-07-18 22:01:39 +02:00
parent ab80334788
commit 5dff3f9f68
3 changed files with 44 additions and 12 deletions

View file

@ -17,11 +17,15 @@ if (!fs.existsSync("./config.toml")) {
const config = toml.parse(fs.readFileSync("./config.toml", "utf-8"));
const assistantname = config.assistant.name;
const username = config.user.name;
const assistantface = config.assistant.assistantface;
const assistantmodel = config.assistant.model;
const systemprompt = config.assistant.system_prompt
let assistantname = config.assistant.name;
let assistantface = config.assistant.assistantface;
let assistantmodel = config.assistant.model;
let username = config.user.name;
let facefont = config.appearance.facefont;
let systemprompt = config.assistant.system_prompt
.replace("${name}", assistantname)
.replace("${username}", username);
@ -182,7 +186,7 @@ function finalizeStreamMessage() {
function setFaceBoxContent(content) {
try {
const figletOutput = execSync(`figlet -f mono9 "${content}"`, {
const figletOutput = execSync(`figlet -f ${facefont} "${content}"`, {
encoding: "utf8",
});
faceBox.setContent(figletOutput);
@ -192,6 +196,13 @@ function setFaceBoxContent(content) {
screen.render();
}
function clearChatHistory() {
chatHistory = [];
conversationHistory = [];
chatBox.setContent("");
screen.render();
}
async function sendMessage(message) {
if (!message.trim()) return;
@ -245,14 +256,11 @@ inputBox.on("submit", async (text) => {
case "help":
addMessage(
assistantname,
"available commands:\nl!help - if you wanna know what i can do, run this!\nl!clear - clear chat history, if you want me to forget everything, just run this!\nl!face <text> - if you want to force my expression, here you go! not sure i'll be too happy about it though.",
"available commands:\nl!help - if you wanna know what i can do, run this!\nl!clear - clear chat history, if you want me to forget everything, just run this!\nl!face <text> - if you want to force my expression, here you go! not sure i'll be too happy about it though.\nl!prompt <text> - if you want to change how i act, here you go! not sure i'll be too happy about that either.\n",
);
break;
case "clear":
chatHistory = [];
conversationHistory = [];
chatBox.setContent("");
screen.render();
clearChatHistory();
break;
case "face":
if (args.trim()) {
@ -261,6 +269,15 @@ inputBox.on("submit", async (text) => {
setFaceBoxContent("=w=");
}
break;
case "prompt":
if (args.trim()) {
systemprompt = args.trim();
clearChatHistory();
addMessage("system", "Prompt set.");
} else {
addMessage("system", "You didn't provide a prompt.");
}
break;
default:
addMessage(assistantname, `unknown command: ${command}`);
break;
@ -272,10 +289,14 @@ inputBox.on("submit", async (text) => {
}
});
screen.key(["escape", "q", "C-c"], () => {
screen.key(["q", "C-c"], () => {
process.exit(0); // KILL lydia!!!!!!!!!!!!!!!!!!!!!!!
});
screen.key(["escape"], () => {
// menu soon when i decide that i wanna do it
});
screen.on("resize", () => {
screen.render();
});