Search
Code3,266
- [ ] Get OpenTownie or Gemini or Claude or OpenAI to synthesize the core of these patterns into a prompt we can use to make more ReactRouter apps, such as...- [ ] Convert this or into the basic react router guest book (and preserve this forum app in another project?)- [ ] To what extent can these patterns be packaged up into a Val Town Router project? Would be neat to get the version pinning thing all centralized, can this as-a-library be that centralized place?
// @ts-nocheckimport { OpenAI } from "https://esm.town/v/std/openai?v=4";// --- AI BEHAVIORAL GUIDELINES --- let words = ["LOOPING"]; // Fallback word try { const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{ role: "system", content: AI_LIST_PROMPT }], } } catch (error) { console.error("Failed to fetch from OpenAI, using fallback list.", error); }
Note: When changing a SQLite table's schema, change the table's name (e.g., add _2 or _3) to create a fresh table.### OpenAI```tsimport { OpenAI } from "https://esm.town/v/std/openai";const openai = new OpenAI();const completion = await openai.chat.completions.create({ messages: [ { role: "user", content: "Say hello in a creative way" },
// @ts-nocheckimport { OpenAI } from "https://esm.town/v/std/openai?v=4";// --- AI BEHAVIORAL GUIDELINES --- let words = ["LOVE"]; try { const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{ role: "system", content: AI_LIST_PROMPT }], } } catch (error) { console.error("Failed to fetch from OpenAI, utilizing fallback lexicon.", error); }
// @ts-nocheckimport { OpenAI } from "https://esm.town/v/std/openai?v=4";// --- AI BEHAVIORAL DIRECTIVE --- } const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [
import { Hono } from "https://esm.sh/hono@3.11.7";import { OpenAI } from "https://esm.town/v/std/openai";import { blob } from "https://esm.town/v/std/blob";import { readFile, serveFile } from "https://esm.town/v/std/utils@85-main/index.ts";});const openai = new OpenAI();// Serve static files } // Generate story with OpenAI const storyPrompt = `Create an engaging story about "${subject}" that is divided into exactly 4 chapters with a happy ending. Make sure the story flows well between chapters and has a satisfying, happy conclusion. Return ONLY the JSON, no markdown formatting or additional text.`; const completion = await openai.chat.completions.create({ messages: [ { role: "system", content: "You are a creative storyteller who writes engaging stories for all ages. You must respond with valid JSON only, no additional formatting or text." },
## Features- OpenAI integration for story generation- AI image generation for story and chapter visuals- Blob storage for caching generated content## Environment VariablesThe app uses OpenAI through Val Town's standard library, which handles API keys automatically.
- **Frontend**: React with TypeScript- **Styling**: TailwindCSS- **AI Services**: OpenAI for story generation, AI image generation- **Text-to-Speech**: Web Speech API with male voice preference- **Storage**: Val Town Blob storage for caching
import { sqlite } from "https://esm.town/v/std/sqlite?v=4";// @ts-ignoreimport { OpenAI } from "https://esm.town/v/std/openai?v=4";// --- CONSTANTS & CONFIGURATION --- if (session.credits < totalCost) return c.json({ error: "Not enough credits." }, 402); const openai = new OpenAI(); const completion = await openai.chat.completions.create({ model: "gpt-4o", messages: [{ role: "system", content: VIBE_CHECK_PROMPT }, { role: "user", content: text }],
import { type OpenAI } from "npm:openai";import { dedent } from "npm:ts-dedent";`.trim();const developerPrompt: OpenAI.ChatCompletionDeveloperMessageParam = { "role": "developer", "content": promptContent,
reconsumeralization
import { OpenAI } from "https://esm.town/v/std/openai";
import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
/**
* Practical Implementation of Collective Content Intelligence
* Bridging advanced AI with collaborative content creation
*/
exp
kwhinnery_openai
lost1991
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
No docs found