zebreus / replicate-api

A TypeScript client library for the replicate.com API
https://github.com/Zebreus/replicate-api
MIT License
23 stars 2 forks source link

You cannot set `webhook_events_filter` if `webhook` is not set #6

Closed Pwntus closed 1 year ago

Pwntus commented 1 year ago

Sorry I haven't had time to find the root cause but this error will keep showing up while trying to use webhooks with/without webhookEvents parameter when creating a prediction.

Error: You cannot set `webhook_events_filter` if `webhook` is not set
    at f (/var/task/webpack:/replicate-api/dist/helpers/makeApiRequest.js:29:19)

Most likely the cause is this line here where webhook_completed should be just webhook: https://github.com/zebreus/replicate-api/blob/master/src/predict.ts#L64

Pwntus commented 1 year ago

Also, I personally think it is confusing to change the param name of webhook_events_filter to webhookEvents since that is what it is called in Replicate's API.

zebreus commented 1 year ago

You are right, webhook_completed should have just been webhook. v0.4.4 fixes that and adds a test to assure that predictions with webhooks can be created without errors.

I understand that it is a bit confusing that the name is different from the one used in the API. My reasoning was that the consumers of this library are using it in TypeScript and expect to be able to use camel case names. I tried to mostly keep the original names but make them more concise if possible. I the parameter would be suffixed with filter in TypeScript it probably creates some confusion, because I would expect to be able to pass a filter function. Just using webhookEvents makes it clear that the parameter is a list of events.

Pwntus commented 1 year ago

Sound reasonable! Thank you for the update :)