import { Configuration, OpenAIApi } from 'openai'; const gptSummarize = async (text: string) => { text += '.'; try { const configuration = new Configuration({ apiKey: process.env.OPENAI_KEY, }); const openai = new OpenAIApi(configuration); const response = await openai.createCompletion({ model: 'text-curie-001', max_tokens: 256, temperature: 0.7, prompt: `Summarize this text in one sentence: ${text}`, }); return response.data.choices[0].text; } catch (err) { console.log(err); return ''; } }; export { gptSummarize };