Skip to content

Commit

Permalink
remove code forking around deployments
Browse files Browse the repository at this point in the history
if users are bringing their own Replicate API tokens, we don't need to use a private deployment any more.
  • Loading branch information
zeke committed Mar 8, 2024
1 parent 33c353c commit 2d0a01d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 27 deletions.
7 changes: 1 addition & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,4 @@ DATABASE_URL=
# so the Replicate API can send it webhooks
#
# e.g. https://8db01fea81ad.ngrok.io
NGROK_HOST=


# Optional: Set a value for this to run the private Replicate deployment of the model
# instead of the public ControlNet Scribble model.
USE_REPLICATE_DEPLOYMENT=
NGROK_HOST=
29 changes: 8 additions & 21 deletions pages/api/predictions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,15 @@ export default async function handler(req) {
userAgent: `${packageData.name}/${packageData.version}`,
});

let prediction;

if (process.env.USE_REPLICATE_DEPLOYMENT) {
prediction = await replicate.deployments.predictions.create(
"replicate",
"scribble-diffusion-jagilley-controlnet",
{
input,
webhook: `${WEBHOOK_HOST}/api/replicate-webhook`,
webhook_events_filter: ["start", "completed"],
}
);
} else {
// https://replicate.com/jagilley/controlnet-scribble/versions
prediction = await replicate.predictions.create({
version:
"435061a1b5a4c1e26740464bf786efdfa9cb3a3ac488595a2de23e143fdb0117",
input,
webhook: `${WEBHOOK_HOST}/api/replicate-webhook`,
webhook_events_filter: ["start", "completed"],
});
}
// https://replicate.com/jagilley/controlnet-scribble/versions
const prediction = await replicate.predictions.create({
version:
"435061a1b5a4c1e26740464bf786efdfa9cb3a3ac488595a2de23e143fdb0117",
input,
webhook: `${WEBHOOK_HOST}/api/replicate-webhook`,
webhook_events_filter: ["start", "completed"],
});

if (prediction?.error) {
return NextResponse.json({ detail: prediction.error }, { status: 500 });
Expand Down

0 comments on commit 2d0a01d

Please sign in to comment.