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 prompt = `Generate 10 variants of the name ${inputName}. The names should sound very much like the original but also like noble names. Examples could be "lady rosalind of whitmore" "lord byron of castlemore" "Lord Max Richter". Choose english, german, french and italian sounding names. Only respond with 10 names seperated be newlines`;

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

  return json(res);
}
