From 21d4aaf5e0614582acd9301102b70f307b04b7cb Mon Sep 17 00:00:00 2001 From: Max Richter Date: Mon, 13 Nov 2023 16:23:52 +0100 Subject: [PATCH] feat: log some more stuff --- src/lib/components/Questions.svelte | 3 ++- src/routes/api/ai/frame/+server.ts | 25 ----------------------- src/routes/api/ai/image/[name]/+server.ts | 4 ++-- src/routes/api/ai/name/[name]/+server.ts | 2 ++ 4 files changed, 6 insertions(+), 28 deletions(-) delete mode 100644 src/routes/api/ai/frame/+server.ts diff --git a/src/lib/components/Questions.svelte b/src/lib/components/Questions.svelte index 35c7a06..f4cc584 100644 --- a/src/lib/components/Questions.svelte +++ b/src/lib/components/Questions.svelte @@ -64,7 +64,8 @@ hairType: $data.portraitHairType, hairColor: $data.portraitHairColor, hairLength: $data.portraitHairLength, - skinColor: $data.portraitSkinColor + skinColor: $data.portraitSkinColor, + name: $data.name }) }); diff --git a/src/routes/api/ai/frame/+server.ts b/src/routes/api/ai/frame/+server.ts deleted file mode 100644 index 82d38df..0000000 --- a/src/routes/api/ai/frame/+server.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { json } from "@sveltejs/kit"; -import type { RequestHandler } from "./$types"; -import { putObject } from "$lib/helpers/minio"; -import { generateImage } from "$lib/helpers/stability"; - -export const GET: RequestHandler = async () => { - - const prompt = `golden brown rectangular picture frame, filled with pure red color, Charles Vess, opulence, mystery, elegance`; - const negativePrompt = "blurry, persons, figure" - - const a = performance.now() - const image = await generateImage(prompt, negativePrompt); - const duration = performance.now() - a; - - console.log({ duration }) - - const imageName = `${image.seed}-frame.png` - - const res = await putObject(imageName, Buffer.from(image.base64, 'base64'), { "Content-Type": "image/png" }); - - return json({ - ...res, - url: `https://s3.app.max-richter.dev/silvester23/${imageName}` - }) -} diff --git a/src/routes/api/ai/image/[name]/+server.ts b/src/routes/api/ai/image/[name]/+server.ts index e13f7b8..60cba61 100644 --- a/src/routes/api/ai/image/[name]/+server.ts +++ b/src/routes/api/ai/image/[name]/+server.ts @@ -49,9 +49,9 @@ export const POST: RequestHandler = async ({ params, request }) => { throw new Error("Name too long"); } - const { hairType, hairColor, hairLength, skinColor } = await request.json(); - console.log(`[AI] Generating image for ${inputName} ${JSON.stringify({ hairType, hairColor, hairLength, skinColor })}`) + const { hairType, hairColor, hairLength, skinColor, name } = await request.json(); + console.log(`[AI] Generating image for ${inputName} ${JSON.stringify({ hairType, hairColor, hairLength, skinColor, name })}`) if (!hairType || !hairColor || !hairLength) { throw new Error("Missing hairType, hairColor or hairLength"); } diff --git a/src/routes/api/ai/name/[name]/+server.ts b/src/routes/api/ai/name/[name]/+server.ts index 694c987..be0ef17 100644 --- a/src/routes/api/ai/name/[name]/+server.ts +++ b/src/routes/api/ai/name/[name]/+server.ts @@ -6,9 +6,11 @@ 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); }