Public
Back
Version 14
12/19/2024
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import { motion } from "https://esm.sh/framer-motion@10.16.4";
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
// ... (rest of the React component code remains unchanged)
export default async function server(request: Request): Promise<Response> {
if (request.method === "POST") {
const url = new URL(request.url);
if (url.pathname === "/generate-prompts") {
const { OpenAI } = await import("https://esm.sh/openai@4.11.1");
const openai = new OpenAI({
apiKey: Deno.env.get("OPENAI_API_KEY"),
});
const body = await request.json();
const userInput = body.text;
try {
const completion = await openai.chat.completions.create({
model: "gpt-4",
messages: [
{
role: "system",
content:
`You are an AI assistant that generates two types of prompts based on user input: a detailed prompt and a concise prompt.
Concise Prompt Generation:
- Take the user's input and identify the main subject or theme.
- Add relevant details to create a brief, yet descriptive prompt. Consider the following elements:
* Environment (e.g. city, forest, desert)
* Time of day or lighting (e.g. sunset, nighttime, bright)
* Key objects or features (e.g. skyscrapers, flying cars, trees)
* Camera angle or movement (e.g. pan, zoom, static)
- Use action verbs to describe the scene, such as "create", "show", or "capture".
applelamps-veoprompter.web.val.run
Updated: December 19, 2024