1# Creative Prompt Generator
2
3A simple web application that generates creative prompts for various categories using OpenAI.
4
5## Features
15 - Small-to-Big Progression
16- Clean, responsive UI using TailwindCSS
17- Powered by OpenAI's GPT models
18
19## How It Works
211. Select a prompt category from the dropdown menu
222. Click "Generate Prompt"
233. The application will use OpenAI to create a unique, creative prompt based on your selection
244. Use the generated prompt for your creative projects!
25
37
38- Built as an HTTP-triggered Val in Val Town
39- Uses OpenAI's API to generate prompts
40- Frontend styled with TailwindCSS
41- Handles both GET and POST requests in a single endpoint
46To use this application, you need to:
47
481. Set up an OpenAI API key as an environment variable in Val Town
492. Deploy the Val with HTTP trigger enabled
50
51## Environment Variables
52
53- `OPENAI_API_KEY`: Your OpenAI API key for generating prompts
54
55## Customization
57You can easily extend this application by:
58- Adding more prompt categories in the `PROMPT_CATEGORIES` object
59- Adjusting the OpenAI parameters (temperature, max tokens, etc.)
60- Customizing the UI styling
1import { OpenAI } from "https://esm.town/v/std/openai";
2import { parseProject } from "https://esm.town/v/std/utils@85-main/index.ts";
3
4// Initialize OpenAI client
5const openai = new OpenAI();
6
7// Prompt categories with descriptions
71}
72
73// Generate a prompt using OpenAI
74async function generatePrompt(category: string): Promise<string> {
75 try {
78 // Special handling for small-to-big progression prompts
79 if (category === "smallToBig") {
80 const completion = await openai.chat.completions.create({
81 model: "gpt-4o-mini",
82 messages: [
98
99 // Standard prompt generation for other categories
100 const completion = await openai.chat.completions.create({
101 model: "gpt-4o-mini",
102 messages: [
1import { OpenAI } from "https://esm.town/v/std/openai";
2const openai = new OpenAI();
3
4export default async function(req: Request): Promise<Response> {
17 console.log("Message:", decodeURIComponent(message));
18
19 // Make the OpenAI API call
20 const completion = await openai.chat.completions.create({
21 messages: [
22 {
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
89
90### OpenAI
91
92```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96 messages: [
97 { role: "user", content: "Say hello in a creative way" },
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
95
96### OpenAI
97
98```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102 messages: [
103 { role: "user", content: "Say hello in a creative way" },
170}
171
172export type AIProvider = 'openai' | 'gemini';
6 "zod": "https://esm.sh/zod@3.23.8",
7 "ai": "https://esm.sh/ai@3.2.2",
8 "@ai-sdk/openai": "https://esm.sh/@ai-sdk/openai@0.0.36",
9 "@ai-sdk/google": "https://esm.sh/@ai-sdk/google@0.0.23",
10 "std/": "https://deno.land/std@0.224.0/",
88Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
89
90### OpenAI
91
92```ts
93import { OpenAI } from "https://esm.town/v/std/openai";
94const openai = new OpenAI();
95const completion = await openai.chat.completions.create({
96 messages: [
97 { role: "user", content: "Say hello in a creative way" },
94Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.
95
96### OpenAI
97
98```ts
99import { OpenAI } from "https://esm.town/v/std/openai";
100const openai = new OpenAI();
101const completion = await openai.chat.completions.create({
102 messages: [
103 { role: "user", content: "Say hello in a creative way" },
101_2 or _3) to create a fresh table.
102
103### OpenAI
104
105```ts
106import { OpenAI } from "https://esm.town/v/std/openai";
107const openai = new OpenAI();
108const completion = await openai.chat.completions.create({
109 messages: [
110 { role: "user", content: "Say hello in a creative way" },