-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathai.ts
More file actions
27 lines (23 loc) · 792 Bytes
/
ai.ts
File metadata and controls
27 lines (23 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { vercelAIApi } from '../integrations/vercel-ai/';
import { EventsFactoryInterface } from './types';
/**
* Service for interacting with AI
*/
export class AIService {
/**
* Generate suggestion for the event
*
* @param eventsFactory - events factory
* @param eventId - event id
* @param originalEventId - original event id
* @returns {Promise<string>} - suggestion
*/
public async generateSuggestion(eventsFactory: EventsFactoryInterface, eventId: string, originalEventId: string): Promise<string> {
const event = await eventsFactory.getEventRepetition(eventId, originalEventId);
if (!event) {
throw new Error('Event not found');
}
return vercelAIApi.generateSuggestion(event.payload);
}
}
export const aiService = new AIService();