Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
oelin authored Jan 21, 2023
1 parent 01dce0d commit a183bc0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default async function midjourney(prompt, inputs = {}) {

// Call the model API...

const uuid = await fetch(sessionCookieJar, `https://replicate.com/api/models/${constants.MODEL_NAME}/versions/${constants.MODEL_VERSION}/predictions`, {
const response1 = await fetch(sessionCookieJar, `https://replicate.com/api/models/${constants.MODEL_NAME}/versions/${constants.MODEL_VERSION}/predictions`, {
headers: {
'content-type': 'application/json',
'accept': 'application/json',
Expand All @@ -42,11 +42,11 @@ export default async function midjourney(prompt, inputs = {}) {

// Wait for the image to be generated...

const uuid = (await response0.json()).uuid
const uuid = (await response1.json()).uuid

for (let timeoutCounter = 0; timeoutCounter < constants.TIMEOUT; timeoutCounter ++) {

let response1 = await fetch(sessionCookieJar, `https://replicate.com/api/models/${constants.MODEL_NAME}/versions/${constants.MODEL_VERSION}/predictions/${uuid}`, {
let response2 = await fetch(sessionCookieJar, `https://replicate.com/api/models/${constants.MODEL_NAME}/versions/${constants.MODEL_VERSION}/predictions/${uuid}`, {
headers: {
'accept': '*/*',
},
Expand All @@ -56,7 +56,7 @@ export default async function midjourney(prompt, inputs = {}) {
body: null,
})

let output = (await response1.json())?.prediction?.output
let output = (await response2.json())?.prediction?.output
if (output.length) { return output }

await sleep(1000)
Expand Down

0 comments on commit a183bc0

Please sign in to comment.