AI da dat ten cho dong song
This commit is contained in:
24
src/OpenAI/openai.service.ts
Normal file
24
src/OpenAI/openai.service.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { OpenAI } from 'openai';
|
||||
|
||||
@Injectable()
|
||||
export class OpenaiService {
|
||||
constructor(private openai: OpenAI) {}
|
||||
|
||||
async generateInvitationMailContent(
|
||||
mail: string,
|
||||
username: string,
|
||||
url: string,
|
||||
) {
|
||||
const prompt = `
|
||||
give me mail content for invitation to a workshop to EPESS and replace {{ mail }} with ${mail}, {{ username }} with ${username} and {{ url }} with ${url}
|
||||
`;
|
||||
|
||||
const response = await this.openai.chat.completions.create({
|
||||
model: 'gpt-4o',
|
||||
messages: [{ role: 'user', content: prompt }],
|
||||
});
|
||||
|
||||
return response.choices[0].message.content;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user