Add color to some console logs

This commit is contained in:
powermaker450 2024-07-02 01:19:47 -04:00
parent 4ec048423f
commit e4d822957c
3 changed files with 75 additions and 9 deletions

75
package-lock.json generated
View file

@ -6,6 +6,7 @@
"": {
"name": "Tailchat-Assistant",
"dependencies": {
"chalk": "^4.1.2",
"openai": "^4.50.0",
"tailchat-client-sdk": "^1.0.9"
},
@ -124,17 +125,34 @@
}
},
"node_modules/chalk": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz",
"integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==",
"dev": true,
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": "^12.17.0 || ^14.13 || >=16.0.0"
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/chalk/node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/cli-cursor": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-4.0.0.tgz",
@ -166,6 +184,22 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"node_modules/colorette": {
"version": "2.0.20",
"resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz",
@ -399,6 +433,14 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"engines": {
"node": ">=8"
}
},
"node_modules/human-signals": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/human-signals/-/human-signals-5.0.0.tgz",
@ -509,6 +551,18 @@
"url": "https://opencollective.com/lint-staged"
}
},
"node_modules/lint-staged/node_modules/chalk": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz",
"integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==",
"dev": true,
"engines": {
"node": "^12.17.0 || ^14.13 || >=16.0.0"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/listr2": {
"version": "8.2.1",
"resolved": "https://registry.npmjs.org/listr2/-/listr2-8.2.1.tgz",
@ -975,6 +1029,17 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/tailchat-client-sdk": {
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/tailchat-client-sdk/-/tailchat-client-sdk-1.0.9.tgz",

View file

@ -1,6 +1,7 @@
{
"name": "Tailchat-Assistant",
"dependencies": {
"chalk": "^4.1.2",
"openai": "^4.50.0",
"tailchat-client-sdk": "^1.0.9"
},

View file

@ -15,6 +15,7 @@ import {
system,
} from "./assistant";
import { ImagesResponse } from "openai/resources";
import chalk from "chalk";
// Specific to Tailchat. The endpoint of my Tailchat server, the bot ID and Secret.
const HOST = process.env.HOST;
@ -40,11 +41,10 @@ const assistant = new OpenAI({
const client = new TailchatWsClient(HOST, APPID, APPSECRET);
client.connect().then(async () => {
console.log("Logged in.");
const SELF = await client.whoami().then((response) => {
return response.userId;
});
console.log("Our userId is:", SELF);
console.log("Our userId is:", chalk.green(SELF));
console.log("Messages from this userId are automatically ignored.");
client.onMessage(async (message) => {
@ -70,7 +70,7 @@ client.connect().then(async () => {
.replace("Please generate: ", "")
.replace("please generate: ", "")
.replace("without", "|");
console.log("Generating image:", prompt);
console.log("Generating image:", chalk.green(prompt));
await client.sendMessage({
converseId: message.converseId,
@ -99,7 +99,7 @@ client.connect().then(async () => {
.replace(/(\[(.*?)\])/g, "")
.replace("{BACKEND}", HOST);
const username = await getUsername(HOST, message.author!);
console.log("Analyzing image at:", imageData);
console.log("Analyzing image at:", chalk.green(imageData));
await client.sendMessage({
converseId: message.converseId,