import { json, type RequestHandler } from "@sveltejs/kit";
import { chat } from "$lib/helpers/openai";


export const GET: RequestHandler = async function ({ params }) {

  const inputName = params.name

  const a = performance.now();
  const newPrompt = `Imagine you're hosting a grand masked ball in a magical realm where guests adopt noble titles that resonate with their true essence. You have a distinguished guest named ${inputName}, and you want to create an air of mystery and elegance and mystery by providing them with alternative noble names inspired by various European regions. Generate 10 names that carry the essence of ${inputName} but with a touch of grandeur, drawing inspiration from the diverse cultures surrounding Europe. Only respond with 10 suggestions seperated by newlines.`

  const res = await chat(newPrompt, { isList: true, temperature: 1 });
  console.log(`[AI] Generated names for ${inputName} in ${performance.now() - a}ms`);
  console.log(JSON.stringify(res, null, 2));

  return json(res);
}
