wavespeed 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +11 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -90,8 +90,8 @@ class WaveSpeed {
|
|
|
90
90
|
if (options.baseUrl) {
|
|
91
91
|
this.baseUrl = options.baseUrl;
|
|
92
92
|
}
|
|
93
|
-
this.pollInterval = options.pollInterval || Number(getEnvVar('WAVESPEED_POLL_INTERVAL')) ||
|
|
94
|
-
this.timeout = options.timeout || Number(getEnvVar('WAVESPEED_TIMEOUT')) ||
|
|
93
|
+
this.pollInterval = options.pollInterval || Number(getEnvVar('WAVESPEED_POLL_INTERVAL')) || 0.5;
|
|
94
|
+
this.timeout = options.timeout || Number(getEnvVar('WAVESPEED_TIMEOUT')) || 120;
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
97
|
* Fetch with timeout support
|
|
@@ -198,7 +198,12 @@ class WaveSpeed {
|
|
|
198
198
|
* @param options Additional fetch options
|
|
199
199
|
*/
|
|
200
200
|
async create(modelId, input, options) {
|
|
201
|
-
|
|
201
|
+
// Build URL with webhook if provided in options
|
|
202
|
+
let url = `${modelId}`;
|
|
203
|
+
if (options === null || options === void 0 ? void 0 : options.webhook) {
|
|
204
|
+
url += `?webhook=${options.webhook}`;
|
|
205
|
+
}
|
|
206
|
+
const response = await this.fetchWithTimeout(url, {
|
|
202
207
|
method: 'POST',
|
|
203
208
|
body: JSON.stringify(input),
|
|
204
209
|
...options
|
|
@@ -208,6 +213,9 @@ class WaveSpeed {
|
|
|
208
213
|
throw new Error(`Failed to create prediction: ${response.status} ${errorText}`);
|
|
209
214
|
}
|
|
210
215
|
const data = await response.json();
|
|
216
|
+
if (data.code !== 200) {
|
|
217
|
+
throw new Error(`Failed to create prediction: ${data.code} ${data}`);
|
|
218
|
+
}
|
|
211
219
|
return new Prediction(data.data, this);
|
|
212
220
|
}
|
|
213
221
|
}
|