wavespeed 0.0.13 → 0.0.15

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 CHANGED
@@ -106,6 +106,7 @@ export declare class WaveSpeed {
106
106
  * @param options Additional fetch options
107
107
  */
108
108
  create(modelId: string, input: Record<string, any>, options?: RequestOptions): Promise<Prediction>;
109
+ getPrediction(predictionId: string): Promise<Prediction>;
109
110
  /**
110
111
  * Upload a file (binary) to the /media/upload/binary endpoint
111
112
  * @param filePath Absolute path to the file to upload
@@ -116,6 +117,6 @@ export declare class WaveSpeed {
116
117
  * @param file Blob to upload
117
118
  * @returns The API response JSON
118
119
  */
119
- upload(file: Blob, options?: RequestOptions): Promise<string>;
120
+ upload(file: File | Blob, options?: RequestOptions): Promise<string>;
120
121
  }
121
122
  export default WaveSpeed;
package/dist/index.js CHANGED
@@ -131,7 +131,8 @@ class WaveSpeed {
131
131
  const timeoutId = setTimeout(() => controller.abort(), timeout);
132
132
  try {
133
133
  // Construct the full URL by joining baseUrl and path
134
- const url = new URL(path.startsWith('/') ? path.substring(1) : path, this.baseUrl).toString();
134
+ const baseUrl = options.isUpload ? this.baseUrl.replace('v3', 'v2') : this.baseUrl;
135
+ const url = new URL(path.startsWith('/') ? path.substring(1) : path, baseUrl).toString();
135
136
  const response = await fetch(url, {
136
137
  ...fetchOptions,
137
138
  signal: controller.signal
@@ -225,6 +226,18 @@ class WaveSpeed {
225
226
  }
226
227
  return new Prediction(data.data, this);
227
228
  }
229
+ async getPrediction(predictionId) {
230
+ const response = await this.fetchWithTimeout(`predictions/${predictionId}/result`);
231
+ if (!response.ok) {
232
+ const errorText = await response.text();
233
+ throw new Error(`Failed to get prediction: ${response.status} ${errorText}`);
234
+ }
235
+ const data = await response.json();
236
+ if (data.code !== 200) {
237
+ throw new Error(`Failed to get prediction: ${data.code} ${data}`);
238
+ }
239
+ return new Prediction(data.data, this);
240
+ }
228
241
  /**
229
242
  * Upload a file (binary) to the /media/upload/binary endpoint
230
243
  * @param filePath Absolute path to the file to upload
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wavespeed",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "WaveSpeed Client SDK for Wavespeed API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",