Allow custom model

main
Stef Dunlap 2023-03-18 11:35:07 -04:00
parent 8a59e82604
commit 103b0f7a2f
3 changed files with 28 additions and 7 deletions

View File

@ -11,5 +11,7 @@
"initialSystemMessage": "You are a helpful assistant.", "initialSystemMessage": "You are a helpful assistant.",
"newChatCmd": "!chat", "newChatCmd": "!chat",
"contChatCmd": "!cont", "contChatCmd": "!cont",
"alwaysRemember": false "alwaysRemember": false,
"debug": false,
"model": "gpt-4"
} }

16
index.js 100644 → 100755
View File

@ -63,11 +63,13 @@ client.connect({
} }
}); });
client.on('debug', console.log); if(config.debug) {
client.on('raw', console.log); client.on('debug', console.log);
client.on('raw', console.log);
}
client.on('registered', () => { client.on('registered', () => {
client.join(config.channels); config.channels.forEach(channel => client.join(channel));
}); });
// listen for messages that start with !chat and call the chatgpt api with a callback that prints the response line by line // listen for messages that start with !chat and call the chatgpt api with a callback that prints the response line by line
@ -110,7 +112,7 @@ function chatgpt(query, messages, callback) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
axios.post(apiUrl, { axios.post(apiUrl, {
messages: messages, messages: messages,
model: 'gpt-3.5-turbo', model: config.model,
stream: true, stream: true,
}, { }, {
headers: { headers: {
@ -124,7 +126,9 @@ function chatgpt(query, messages, callback) {
let parts = data.split('\n'); let parts = data.split('\n');
// parse if starts with data: // parse if starts with data:
for (let part of parts) { for (let part of parts) {
console.log(part); if(config.debug) {
console.log(part);
}
if (part === 'data: [DONE]') { if (part === 'data: [DONE]') {
callback(currentLine); callback(currentLine);
@ -184,4 +188,4 @@ function chatgpt(query, messages, callback) {
reject(error); reject(error);
}); });
}); });
} }

View File

@ -0,0 +1,15 @@
[Unit]
Description=ircgpt
After=ircgpt.service
[Service]
Type=simple
WorkingDirectory=/home/kindrobot/wrk/ircgpt
ExecStart=/home/kindrobot/wrk/ircgpt/index.js
Restart=always
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
[Install]
WantedBy=default.target