@@ -7,7 +7,7 @@ const mongo = require('../mongo');
77const Event = require ( '../models/event' ) ;
88const { ObjectID } = require ( 'mongodb' ) ;
99const { composeEventPayloadByRepetition } = require ( '../utils/merge' ) ;
10- const { openAIApi } = require ( '../openai ' ) ;
10+ const { vercelAIApi } = require ( '../resolvers/vercel-ai ' ) ;
1111
1212const MAX_DB_READ_BATCH_SIZE = Number ( process . env . MAX_DB_READ_BATCH_SIZE ) ;
1313
@@ -180,22 +180,22 @@ class EventsFactory extends Factory {
180180 }
181181
182182 /**
183- * Ask AI about solving repetition
183+ * Generate AI suggestion for the event
184184 *
185- * @param {string } repetitionId - repetition ID
186- * @param {string } eventId - event ID
187- *
188- * @return { string } - AI answer
185+ * @param {string } projectId - event's project
186+ * @param {string } eventId - event id
187+ * @param { string } originalEventId - original event id
188+ * @returns { Promise< string> } AI suggestion for the event
189189 */
190- async askAi ( repetitionId , eventId ) {
191- const repetition = await this . getEventRepetition ( repetitionId , eventId ) ;
190+ async aiSuggestion ( eventId , originalEventId ) {
191+ const repetition = await this . getEventRepetition ( eventId , originalEventId ) ;
192192
193193 if ( ! repetition ) {
194194 throw new Error ( 'Repetition not found' ) ;
195195 }
196196
197- const payload = repetition . event . payload ;
198- const solution = await openAIApi . solveEvent ( payload ) ;
197+ const payload = repetition . payload ;
198+ const solution = await vercelAIApi . generateSuggestion ( payload ) ;
199199
200200 return solution ;
201201 }
0 commit comments