-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
81 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,32 @@ | ||
const OpenAIService = require('../services/openAI') | ||
|
||
const LoggerService = require('../services/logger') | ||
const moment = require("moment/moment"); | ||
class OpenAI { | ||
async askOpenAI (target, text, username, bot) { | ||
const response = await OpenAIService.askAssistant(text) | ||
if (response) { | ||
bot.say(target, `@${username} ${response}`) | ||
} | ||
} | ||
|
||
async createAndUploadToChat (target, bot, isToday = false) { | ||
const today = moment().tz('Europe/Madrid') | ||
const date = isToday ? today : today.subtract(1, 'days') | ||
const startOfDay = date.startOf('day').toDate(); | ||
const endOfDay = date.endOf('day').toDate(); | ||
|
||
const response = await LoggerService.getLogChatMessagesBetweenDays(config.twitch.roomId,startOfDay, endOfDay) | ||
const json = JSON.stringify(response) | ||
|
||
const formattedDate = date.format('YYYY-MM-DD'); | ||
const result = await OpenAIService.uploadFileToVectorStore(json, formattedDate) | ||
if (result.success) { | ||
bot.say(target, `IA actualizada con el chat de ${formattedDate}`) | ||
console.log('Chat uploaded to openai ' + result.filename) | ||
} else { | ||
console.log('Error uploading chat to openai of date ' + formattedDate) | ||
} | ||
} | ||
} | ||
|
||
module.exports = OpenAI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters