import OpenAI from 'openai';
import { OPENAI_API_KEY } from '$env/static/private';

const openai = new OpenAI({
  apiKey: OPENAI_API_KEY,
});

export async function chat(prompt: string) {

  const chatCompletion = await openai.chat.completions.create({
    model: "gpt-4",
    messages: [
      {
        "role": "system",
        "content": prompt,
      },
    ],
  });

  const res = chatCompletion.choices[0].message.content;
  return res;
}
