Implement OpenAI Assistant API

- Updated linkCop
- Updated standard interaction handler
This commit is contained in:
Logan Cusano
2024-07-14 15:47:46 -04:00
parent 24296c2ae4
commit 2cd5eee940
3 changed files with 106 additions and 23 deletions

View File

@@ -22,7 +22,7 @@ export const gptInteraction = async (nodeIo, message) => {
if (msg.author.id === nodeIo.serverClient.user.id) {
conversation.push({
role: 'assistant',
name: msg.author.id,
//name: msg.author.id,
content: msg.content,
});
@@ -31,13 +31,13 @@ export const gptInteraction = async (nodeIo, message) => {
conversation.push({
role: 'user',
name: msg.author.id,
//name: msg.author.id,
content: msg.content.replace(`<@${nodeIo.serverClient.user.id}>`, ''),
});
});
const response = await gptHandler(conversation);
if (response) {
const responseMessage = response.choices[0].message.content;
const responseMessage = response;
const chunkSize = 2500;
for (let i = 0; i < responseMessage.length; i += chunkSize) {

View File

@@ -35,7 +35,7 @@ export const linkCop = async (nodeIo, message) => {
if (msg.author.id === nodeIo.serverClient.user.id) {
conversation.push({
role: 'assistant',
name: msg.author.id,
//name: msg.author.id,
content: msg.content,
});
@@ -44,20 +44,20 @@ export const linkCop = async (nodeIo, message) => {
conversation.push({
role: 'user',
name: msg.author.id,
//name: msg.author.id,
content: msg.content.replace(`<@${nodeIo.serverClient.user.id}>`, ''),
});
});
conversation.push({
role: 'system',
content: `There has been a link posted to a channel that links are not allowed in. The above messages are from the channel that links are not allowed including the message with the link. The message with the link is going to be deleted and moved to the '#links' channels. You should let the user know.`
role: 'assistant',
content: `There has been a link posted to a channel that links are not allowed in. The above messages are from the channel that links are not allowed including the message with the link. The message with the link is going to be deleted and moved to the '#links' channels. You are replying to the message with the link to let the user know.`
});
const response = await gptHandler(conversation);
if (response) {
const responseMessage = response.choices[0].message.content;
const responseMessage = response;
const chunkSize = 2000;
for (let i = 0; i < responseMessage.length; i += chunkSize) {