-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Image Gen example with mock photoes (#48)
* fix: put proper mock images * fix: add mock api before, we were simply using context.sleep, which can be surprising for users. Now we call a mock endpoint.
- Loading branch information
Showing
14 changed files
with
90 additions
and
49 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
examples/image-gen-with-workflow/app/api/mock-image-gen-endpoint/route.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { NextRequest } from "next/server" | ||
import { IMAGES, MOCK_WAIT_MS } from "utils/constants" | ||
import { ImageResponse, Prompt } from "utils/types" | ||
|
||
|
||
export const POST = async (request: NextRequest) => { | ||
const params = (await request.json()) as { prompt: Prompt } | ||
|
||
const prompt = params.prompt | ||
|
||
await new Promise((r) => setTimeout(r, MOCK_WAIT_MS)) | ||
const response: ImageResponse = { | ||
created: "mock", | ||
data: [ | ||
{ | ||
prompt, | ||
url: IMAGES[prompt] | ||
} | ||
] | ||
} | ||
return new Response(JSON.stringify(response)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
import { Prompt } from "./types" | ||
|
||
export const RATELIMIT_CODE = 429 | ||
export const REDIS_PREFIX = 'llm-call' | ||
export const PLACEHOLDER_IMAGE = | ||
'https://mintlify.s3-us-west-1.amazonaws.com/upstash/img/qstash/qstash-benefits.png' | ||
|
||
export const PROMPTS = [ | ||
'A supersonic jet rising to the stars in 1980s propaganda posters style. For coloring, use a contrast between a calm white/blue and a striking red', | ||
'A futuristic city skyline at dusk, with towering skyscrapers and flying vehicles in the style of retro sci-fi art. Colors should feature deep purples, bright neon pinks, and glowing electric blues.', | ||
'A high-speed train racing through a futuristic city, inspired by cyberpunk aesthetics. Use a mix of metallic greys and dark purples, with neon accents lighting up the scene.', | ||
'A tranquil mountain village under a starry night sky, painted in the style of traditional Japanese woodblock prints with a modern touch. Use soft blues and greens for the landscape, with glowing golden stars in the sky.', | ||
'A group of astronauts exploring a distant planet, depicted in the vibrant, surreal style of 1970s space art.' | ||
] | ||
] as const | ||
|
||
export const IMAGES: Record<Prompt, string> = { | ||
"A futuristic city skyline at dusk, with towering skyscrapers and flying vehicles in the style of retro sci-fi art. Colors should feature deep purples, bright neon pinks, and glowing electric blues.": "futuristic-city.png", | ||
"A group of astronauts exploring a distant planet, depicted in the vibrant, surreal style of 1970s space art.": "astronauts.png", | ||
"A high-speed train racing through a futuristic city, inspired by cyberpunk aesthetics. Use a mix of metallic greys and dark purples, with neon accents lighting up the scene.": "train.png", | ||
"A supersonic jet rising to the stars in 1980s propaganda posters style. For coloring, use a contrast between a calm white/blue and a striking red": "supersonic-jet.png", | ||
"A tranquil mountain village under a starry night sky, painted in the style of traditional Japanese woodblock prints with a modern touch. Use soft blues and greens for the landscape, with glowing golden stars in the sky.": "mountain-village.png" | ||
} | ||
export const MOCK_WAIT_MS = 7_000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters