diffio 0.2.49 → 0.3.0
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/README.md +13 -8
- package/dist/Client.js +15 -4
- package/dist/api/types.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Diffio JS SDK
|
|
2
2
|
|
|
3
|
-
The Diffio JS SDK helps you call the Diffio API from Node. This version covers project creation, edge upload, Diffio 4.
|
|
3
|
+
The Diffio JS SDK helps you call the Diffio API from Node. This version covers project creation, edge upload, Diffio 4.6 generations, progress checks, and download URLs.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -46,10 +46,10 @@ const projects = await client.listProjects({
|
|
|
46
46
|
|
|
47
47
|
| Model | `model` value | Endpoint | Notes |
|
|
48
48
|
|---|---|---|---|
|
|
49
|
-
| Diffio 4.
|
|
50
|
-
| Diffio 4.
|
|
49
|
+
| Diffio 4.6 Flash | `diffio-4.6-flash` | `/v1/diffio-4.6-flash-generation` | Default. Fast, high quality speech restoration. |
|
|
50
|
+
| Diffio 4.6 Pro | `diffio-4.6-pro` | `/v1/diffio-4.6-pro-generation` | Best quality. Paid accounts only. |
|
|
51
51
|
|
|
52
|
-
Omitting `model` uses `diffio-4.
|
|
52
|
+
Omitting `model` uses `diffio-4.6-flash`. Earlier models (`diffio-2`, `diffio-2-flash`, `diffio-3.2`,
|
|
53
53
|
`diffio-3.4`, `diffio-3.5`, `diffio-4.0-flash`, `diffio-4.0-pro`) are retired: the SDK refuses them
|
|
54
54
|
before sending a request, and the API answers their endpoints with HTTP 410 `model_retired`.
|
|
55
55
|
Generations created before a model was retired keep their original `modelKey`, so response
|
|
@@ -83,7 +83,7 @@ const project = await client.createProject({
|
|
|
83
83
|
|
|
84
84
|
const generation = await client.createGeneration({
|
|
85
85
|
apiProjectId: project.apiProjectId,
|
|
86
|
-
model: "diffio-4.
|
|
86
|
+
model: "diffio-4.6-flash",
|
|
87
87
|
idempotencyKey: "restore-sample-001"
|
|
88
88
|
});
|
|
89
89
|
|
|
@@ -110,7 +110,7 @@ retrying after an uncertain response.
|
|
|
110
110
|
`waitForGeneration` and `generations.waitForComplete` wait for the overall `status` to become
|
|
111
111
|
`complete`. Individual stages reaching 100% or `complete` do not end polling while video publication
|
|
112
112
|
or usage settlement is still pending. They poll for up to 600 seconds unless you pass `timeout`
|
|
113
|
-
or `timeoutInSeconds`. `complete` means restored media is ready. Diffio 4.
|
|
113
|
+
or `timeoutInSeconds`. `complete` means restored media is ready. Diffio 4.6 transcribes the recording before
|
|
114
114
|
restoration starts, so a completed generation has its transcript unless transcription finished as
|
|
115
115
|
`unavailable`; while a generation runs, transcription can be `pending`, `available`, or `unavailable`. Read
|
|
116
116
|
`progress.transcription?.status` independently. Older responses omit `transcription`; absence does
|
|
@@ -124,7 +124,7 @@ import { DiffioClient } from "diffio";
|
|
|
124
124
|
const client = new DiffioClient({ apiKey: "diffio_live_..." });
|
|
125
125
|
const result = await client.audioIsolation.isolate({
|
|
126
126
|
filePath: "sample.wav",
|
|
127
|
-
model: "diffio-4.
|
|
127
|
+
model: "diffio-4.6-flash",
|
|
128
128
|
idempotencyKey: "restore-sample-001"
|
|
129
129
|
});
|
|
130
130
|
|
|
@@ -145,7 +145,7 @@ import { DiffioClient } from "diffio";
|
|
|
145
145
|
const client = new DiffioClient({ apiKey: "diffio_live_..." });
|
|
146
146
|
const [audioBytes, info] = await client.restoreAudio({
|
|
147
147
|
filePath: "sample.wav",
|
|
148
|
-
model: "diffio-4.
|
|
148
|
+
model: "diffio-4.6-flash",
|
|
149
149
|
idempotencyKey: "restore-sample-001",
|
|
150
150
|
onProgress: (progress) => console.log(progress.status)
|
|
151
151
|
});
|
|
@@ -335,6 +335,11 @@ app.post("/webhooks/diffio", express.raw({ type: "application/json" }), (req, re
|
|
|
335
335
|
});
|
|
336
336
|
```
|
|
337
337
|
|
|
338
|
+
## Upgrading to 0.3.0
|
|
339
|
+
|
|
340
|
+
0.3.0 adds Diffio 4.6 Flash (`diffio-4.6-flash`) and Diffio 4.6 Pro (`diffio-4.6-pro`), and the
|
|
341
|
+
default model is now `diffio-4.6-flash`. Request and response shapes are unchanged.
|
|
342
|
+
|
|
338
343
|
## Runtime compatibility
|
|
339
344
|
|
|
340
345
|
Use Node 18 or later so `fetch` is available without extra packages.
|
package/dist/Client.js
CHANGED
|
@@ -48,12 +48,23 @@ const DEFAULT_BASE_URL = "https://api.diffio.ai";
|
|
|
48
48
|
const API_PREFIX = "v1";
|
|
49
49
|
/** Generation endpoint for each supported model, as api/model_registry.json in diffio-ui lists them. */
|
|
50
50
|
const MODEL_ENDPOINTS = {
|
|
51
|
-
"diffio-4.
|
|
52
|
-
"diffio-4.
|
|
51
|
+
"diffio-4.6-flash": "diffio-4.6-flash-generation",
|
|
52
|
+
"diffio-4.6-pro": "diffio-4.6-pro-generation"
|
|
53
|
+
};
|
|
54
|
+
/** Keys accepted from code written against 0.2.x; they run the matching 4.6 model. Not part of ModelKey. */
|
|
55
|
+
const LEGACY_MODEL_KEYS = {
|
|
56
|
+
"diffio-4.5-flash": "diffio-4.6-flash",
|
|
57
|
+
"diffio-4.5-pro": "diffio-4.6-pro"
|
|
53
58
|
};
|
|
54
59
|
/** The registry's `freeDefault` model; Pro is paid-only, so it cannot be the default for every key. */
|
|
55
|
-
const DEFAULT_MODEL_KEY = "diffio-4.
|
|
60
|
+
const DEFAULT_MODEL_KEY = "diffio-4.6-flash";
|
|
56
61
|
const SUPPORTED_MODEL_KEYS = Object.keys(MODEL_ENDPOINTS);
|
|
62
|
+
const hasOwn = (record, key) => Object.prototype.hasOwnProperty.call(record, key);
|
|
63
|
+
/** Returns the generation endpoint for a model key, or undefined when the SDK does not support it. */
|
|
64
|
+
function generationEndpointForModel(model) {
|
|
65
|
+
const modelKey = hasOwn(LEGACY_MODEL_KEYS, model) ? LEGACY_MODEL_KEYS[model] : model;
|
|
66
|
+
return hasOwn(MODEL_ENDPOINTS, modelKey) ? MODEL_ENDPOINTS[modelKey] : undefined;
|
|
67
|
+
}
|
|
57
68
|
/** Per-request timeout for one edge upload call; a 32 MiB part needs about 1 Mbit/s to finish in time. */
|
|
58
69
|
const DEFAULT_EDGE_UPLOAD_TIMEOUT_SECONDS = 300;
|
|
59
70
|
/** complete_project_upload is idempotent, so it is retried even when the client disables retries by default. */
|
|
@@ -180,7 +191,7 @@ class DiffioClient {
|
|
|
180
191
|
/** Retries generation admission only when the caller supplies a nonblank idempotency key. */
|
|
181
192
|
async createGeneration(options) {
|
|
182
193
|
const { apiProjectId, model = DEFAULT_MODEL_KEY, sampling, params, idempotencyKey, requestOptions } = options;
|
|
183
|
-
const endpoint =
|
|
194
|
+
const endpoint = generationEndpointForModel(model);
|
|
184
195
|
if (!endpoint) {
|
|
185
196
|
throw new errors_1.DiffioApiError(`Unsupported model: ${model}. Use ${SUPPORTED_MODEL_KEYS.join(" or ")}.`);
|
|
186
197
|
}
|
package/dist/api/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Models new generations can use (api/model_registry.json in diffio-ui); each has its own endpoint. */
|
|
2
|
-
export type ModelKey = "diffio-4.
|
|
2
|
+
export type ModelKey = "diffio-4.6-flash" | "diffio-4.6-pro";
|
|
3
3
|
export type DownloadType = "audio" | "video" | "transcript";
|
|
4
4
|
export type WebhookMode = "test" | "live";
|
|
5
5
|
export type WebhookEventType = "generation.queued" | "generation.processing" | "generation.failed" | "generation.completed";
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const DIFFIO_SDK_VERSION = "0.
|
|
1
|
+
export declare const DIFFIO_SDK_VERSION = "0.3.0";
|
package/dist/version.js
CHANGED