-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add image gen with dall-e + update styles of home and explore pages
- Loading branch information
1 parent
76c9ea6
commit 442f7ea
Showing
13 changed files
with
201 additions
and
76 deletions.
There are no files selected for viewing
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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { v } from "convex/values"; | ||
import { internalMutation } from "./_generated/server"; | ||
|
||
export const updateJob = internalMutation({ | ||
args: { | ||
id: v.id("jobs"), | ||
result: v.optional(v.string()), | ||
status: v.union( | ||
v.literal("pending"), | ||
v.literal("completed"), | ||
v.literal("failed") | ||
), | ||
imageId: v.optional(v.string()), | ||
}, | ||
handler: async (ctx, { id, result, status, imageId }) => { | ||
await ctx.db.patch(id, { | ||
result, | ||
status: status, | ||
imageId, | ||
}); | ||
}, | ||
}); |
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 |
---|---|---|
|
@@ -11,5 +11,6 @@ export default defineSchema({ | |
v.literal("completed"), | ||
v.literal("failed") | ||
), | ||
imageId: v.string(), | ||
}), | ||
}); |
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,29 @@ | ||
import OpenAI from "openai"; | ||
|
||
export const openAiConfig = async (prompt: string) => { | ||
const apiKey = process.env.OPENAI_API_KEY; | ||
|
||
if (!apiKey) { | ||
throw new Error( | ||
"Add your OPENAI_API_KEY as an env variable in the " + | ||
"[dashboard](https://dasboard.convex.dev)" | ||
); | ||
} | ||
|
||
const openai = new OpenAI({ apiKey }); | ||
|
||
// Check if the prompt is offensive. | ||
const modResponse = await openai.moderations.create({ | ||
input: prompt, | ||
}); | ||
const modResult = modResponse.results[0]; | ||
if (modResult.flagged) { | ||
throw new Error( | ||
`Your prompt were flagged as offensive: ${JSON.stringify( | ||
modResult.categories | ||
)}` | ||
); | ||
} | ||
|
||
return openai; | ||
}; |
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,4 +1,12 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {}; | ||
const nextConfig = { | ||
images: { | ||
remotePatterns: [ | ||
{ | ||
hostname: process.env.NEXT_PUBLIC_CONVEX_DOMAIN, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export default nextConfig; |
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
Oops, something went wrong.