Public
Readme
Inspired from a RedwoodJS demo I mde last year, this adds generative art powered by Fal to the bedtime story maker.
Start writing a story by picking
- a style (spooky, colofrol, adventurous
- an animal (penguin, mouse, unicorn, whale ...)
- a color for the animal
- and activity (befriends aliens, goes to the doctor, rides a rollercoaster, bakes a cake for friends)
It uses OpenAI to write a children's bedtime story
- title
- summary
- story
for a "fantastical story about a green whale who rides the bus" or the "spooky story about the tomato fox who explores a cave".
Then using the summary, OpenAI geenrates another prompt to describe the instructions to geneate a childrens story book image.
That's sent to Fal to generate an image.
Stories get saved to bedtime_stories
in SQLite for viewing, searching and maybe sharing.
You then get a bedtime story to enjoy!
Code
HTTP
/** @jsxImportSource npm:hono@3/jsx */
import { unkey, type UnkeyContext } from "npm:@unkey/hono"
import { Hono } from "npm:hono"
import {
createBedtimeStory,
getBedtimeStoryById,
getRecentBedtimeStories,
} from "https://esm.town/v/dthyresson/bedtimeStoriesDb"
import type { BedtimeStory } from "https://esm.town/v/dthyresson/bedtimeStoriesDb"
import { getSortedActivities } from "https://esm.town/v/dthyresson/bedtimeStoryActivities"
import { getSortedAdjectives } from "https://esm.town/v/dthyresson/bedtimeStoryAdjectives"
import { getSortedAnimals } from "https://esm.town/v/dthyresson/bedtimeStoryAnimals"
import { getSortedColors } from "https://esm.town/v/dthyresson/bedtimeStoryColors"
import { generateOpenGraphTags, OpenGraphData } from "https://esm.town/v/dthyresson/generateOpenGraphTags"
import { ValTownLink } from "https://esm.town/v/dthyresson/viewOnValTownComponent"
import { chat } from "https://esm.town/v/stevekrouse/openai"
import * as fal from "npm:@fal-ai/serverless-client"
export const falConfig = () => {
fal.config({
// Can also be auto-configured using environment variables:
credentials: Deno.env.get("FAL_KEY"),
})
return fal
}
const app = new Hono<{ Variables: { unkey: UnkeyContext } }>()
// app.use(
// "*",
// unkey({
// apiId: "rlns_2AMjVgwwMksmssLVb56LVmkpB56C",
// }),
// );
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
tmcw-bedtimestorymaker.web.val.run
Updated: January 21, 2025