1import { Configuration, OpenAIApi } from 'openai'; 2 3const configuration = new Configuration({ 4 organization: process.env.OPENAI_API_ORG, 5 apiKey: process.env.OPENAI_API_KEY, 6}); 7 8const openai = new OpenAIApi(configuration); 9 10export async function askChatGPTAsync(question: string): Promise<string | undefined> { 11 const response = await openai.createChatCompletion({ 12 model: 'gpt-4', 13 messages: [{ role: 'user', content: question }], 14 }); 15 16 return response.data.choices[0]?.message?.content; 17} 18