Skip to content

options are optional in replicate.wait()#122

Merged
mattt merged 2 commits intomainfrom
make-wait-interval-optional
Aug 15, 2023
Merged

options are optional in replicate.wait()#122
mattt merged 2 commits intomainfrom
make-wait-interval-optional

Conversation

@zeke
Copy link
Copy Markdown
Member

@zeke zeke commented Aug 15, 2023

Fixes an error where this code:

  let prediction = await replicate.predictions.create({
      // zeke/nyu-llama-2-7b-chat-training-test
      version: 'aae0f2ef9dd402d20aba3e83adcbb7ab8fb55fdc3081d14abb6aa082b181c981',
      input: {
        prompt: 'mailbag ->',
        system_prompt: '',
      },
    }
  );
  console.log(prediction);
  prediction = await replicate.wait(prediction);

produces this error:

$ node test-llama.js
{
  id: 'rfxxkdtbnmvzpmol3lt4xidoti',
  version: 'aae0f2ef9dd402d20aba3e83adcbb7ab8fb55fdc3081d14abb6aa082b181c981',
  input: { prompt: 'mailbag ->', system_prompt: '' },
  logs: '',
  error: null,
  status: 'starting',
  created_at: '2023-08-15T16:23:50.344220582Z',
  urls: {
    cancel: 'https://api.replicate.com/v1/predictions/rfxxkdtbnmvzpmol3lt4xidoti/cancel',
    get: 'https://api.replicate.com/v1/predictions/rfxxkdtbnmvzpmol3lt4xidoti'
  }
}
/Users/z/Desktop/Replicate-Examples/node_modules/replicate/index.js:274
    const interval = options.interval || 500;
                             ^

TypeError: Cannot read properties of undefined (reading 'interval')
    at Replicate.wait (/Users/z/Desktop/Replicate-Examples/node_modules/replicate/index.js:274:30)
    at go (file:///Users/z/Desktop/Replicate-Examples/test-llama.js:22:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

and an empty options object circumvents the error:

prediction = await replicate.wait(prediction, {});

@zeke zeke requested a review from mattt August 15, 2023 16:50
Comment thread index.js Outdated
Copy link
Copy Markdown
Contributor

@mattt mattt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @zeke!

@mattt mattt merged commit 6c6fb5d into main Aug 15, 2023
@mattt mattt deleted the make-wait-interval-optional branch August 15, 2023 17:46
@mattt
Copy link
Copy Markdown
Contributor

mattt commented Aug 15, 2023

@zeke This is now shipped in v0.16.1.

@zeke
Copy link
Copy Markdown
Member Author

zeke commented Aug 15, 2023

Thank you! 🍓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants