@neta-art/generation 0.1.29 → 0.1.32
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 +24 -0
- package/dist/{builtins-pLWxi8pM.js → builtins-BIKiMMUX.js} +160 -91
- package/dist/builtins-BIKiMMUX.js.map +1 -0
- package/dist/builtins-jIE_k69Z.d.ts.map +1 -1
- package/dist/builtins.js +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/{export-config-DdAPiFRF.js → export-config-DRotzV5u.js} +201 -82
- package/dist/export-config-DRotzV5u.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/models/suno_music_chirp_fenix.yaml +4 -0
- package/models/volc.seedasr.auc.yaml +48 -0
- package/package.json +3 -1
- package/dist/builtins-pLWxi8pM.js.map +0 -1
- package/dist/export-config-DdAPiFRF.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as compactArray, c as slugifyFileName, d as MODEL_SCHEMA, i as cloneJson, l as GENERATION_MODEL_CATEGORIES, n as getBuiltinGenerationModel, o as compactObject, r as listBuiltinGenerationModels, s as getBlockMeta, t as builtinGenerationModels, u as GENERATION_PRICING_UNITS } from "./builtins-
|
|
1
|
+
import { a as compactArray, c as slugifyFileName, d as MODEL_SCHEMA, i as cloneJson, l as GENERATION_MODEL_CATEGORIES, n as getBuiltinGenerationModel, o as compactObject, r as listBuiltinGenerationModels, s as getBlockMeta, t as builtinGenerationModels, u as GENERATION_PRICING_UNITS } from "./builtins-BIKiMMUX.js";
|
|
2
2
|
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
3
3
|
import { extname, join } from "node:path";
|
|
4
4
|
import { parse, stringify } from "yaml";
|
|
@@ -199,7 +199,7 @@ function transportErrorTarget(rawUrl) {
|
|
|
199
199
|
}
|
|
200
200
|
function transportErrorSummary(error) {
|
|
201
201
|
const outer = error instanceof Error ? error : new Error(String(error));
|
|
202
|
-
const cause = isRecord$
|
|
202
|
+
const cause = isRecord$8(outer.cause) ? outer.cause : void 0;
|
|
203
203
|
return compactObject({
|
|
204
204
|
name: outer.name,
|
|
205
205
|
causeName: stringProperty(cause, "name"),
|
|
@@ -210,16 +210,16 @@ function transportErrorSummary(error) {
|
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
function stringProperty(value, key) {
|
|
213
|
-
if (!isRecord$
|
|
213
|
+
if (!isRecord$8(value)) return void 0;
|
|
214
214
|
const item = value[key];
|
|
215
215
|
return typeof item === "string" && item.trim() ? item.trim() : void 0;
|
|
216
216
|
}
|
|
217
217
|
function stringOrNumberProperty(value, key) {
|
|
218
|
-
if (!isRecord$
|
|
218
|
+
if (!isRecord$8(value)) return void 0;
|
|
219
219
|
const item = value[key];
|
|
220
220
|
return typeof item === "string" || typeof item === "number" ? item : void 0;
|
|
221
221
|
}
|
|
222
|
-
function isRecord$
|
|
222
|
+
function isRecord$8(value) {
|
|
223
223
|
return typeof value === "object" && value !== null;
|
|
224
224
|
}
|
|
225
225
|
|
|
@@ -388,6 +388,23 @@ function asNumber$1(value) {
|
|
|
388
388
|
function asBoolean$1(value) {
|
|
389
389
|
return typeof value === "boolean" ? value : void 0;
|
|
390
390
|
}
|
|
391
|
+
function isSeedance25Model(model) {
|
|
392
|
+
return /seedance[-_.]?2[-_.]?5/i.test(model);
|
|
393
|
+
}
|
|
394
|
+
function seedance25LockedRatioKind(mode, parameters, requestParameters, meta) {
|
|
395
|
+
if (mode === "frame") return "first/last-frame";
|
|
396
|
+
const taskType = asString$4(requestParameters?.omni_reference_task_type) ?? asString$4(parameters.omni_reference_task_type) ?? asString$4(meta.omni_reference_task_type) ?? asString$4(requestParameters?.task_type) ?? asString$4(parameters.task_type) ?? asString$4(meta.task_type);
|
|
397
|
+
if (taskType === "edit") return "edit";
|
|
398
|
+
if (taskType === "extend") return "extend";
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
function resolveRatio$1(model, mode, parameters, requestParameters, meta) {
|
|
402
|
+
const requested = asString$4(requestParameters?.ratio);
|
|
403
|
+
const locked = isSeedance25Model(model) ? seedance25LockedRatioKind(mode, parameters, requestParameters, meta) : null;
|
|
404
|
+
if (!locked) return requested ?? asString$4(parameters.ratio) ?? "16:9";
|
|
405
|
+
if (requested !== void 0 && requested !== "adaptive") throw new GenerationValidationError(`Seedance 2.5 ${locked} tasks require ratio=adaptive, got "${requested}"`);
|
|
406
|
+
return "adaptive";
|
|
407
|
+
}
|
|
391
408
|
function normalizeStatus$4(value) {
|
|
392
409
|
const status = value.toLowerCase();
|
|
393
410
|
return status === "success" ? "succeeded" : status;
|
|
@@ -557,11 +574,11 @@ async function arkVideoGenerationsAdapter(input) {
|
|
|
557
574
|
const visualInput = inputMedia.filter(isVisualMedia);
|
|
558
575
|
validateAudioInputs(inputMedia.filter((item) => item.kind === "audio"), visualInput);
|
|
559
576
|
const mode = classifyMedia$1(visualInput);
|
|
577
|
+
const ratio = resolveRatio$1(input.declaration.model, mode, input.parameters, input.request.parameters, input.meta);
|
|
560
578
|
const media = await resolveMedia$1(input, inputMedia);
|
|
561
579
|
const visual = media.filter(isVisualResolved);
|
|
562
580
|
const audio = media.filter((item) => item.kind === "audio");
|
|
563
581
|
const resolution = asString$4(input.parameters.resolution) ?? "720p";
|
|
564
|
-
const ratio = asString$4(input.request.parameters?.ratio) ?? asString$4(input.parameters.ratio) ?? "16:9";
|
|
565
582
|
const duration = getIntegerParameter(input.parameters, "duration", 5);
|
|
566
583
|
const fps = getIntegerParameter(input.parameters, "fps", 24);
|
|
567
584
|
const pollIntervalSec = getIntegerParameter(input.parameters, "poll_interval", DEFAULT_POLL_INTERVAL_SEC$4);
|
|
@@ -653,7 +670,7 @@ const QWEN_MODELS = new Set([
|
|
|
653
670
|
]);
|
|
654
671
|
const QWEN_AUDIO_3_MODELS = new Set(["qwen-audio-3.0-tts-plus", "qwen-audio-3.0-tts-flash"]);
|
|
655
672
|
const HIGGS_MODEL = "higgs-tts";
|
|
656
|
-
function isRecord$
|
|
673
|
+
function isRecord$7(value) {
|
|
657
674
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
658
675
|
}
|
|
659
676
|
function textBlocks(input) {
|
|
@@ -774,8 +791,8 @@ function providerError(response, rawBody) {
|
|
|
774
791
|
const requestId = requestIdFromHeaders(response.headers);
|
|
775
792
|
const contentType = (response.headers.get("content-type") ?? "").toLowerCase();
|
|
776
793
|
const parsed = contentType.includes("application/json") || contentType.includes("+json") ? parseJson(rawBody) : void 0;
|
|
777
|
-
const parsedRecord = isRecord$
|
|
778
|
-
const errorRecord = isRecord$
|
|
794
|
+
const parsedRecord = isRecord$7(parsed) ? parsed : void 0;
|
|
795
|
+
const errorRecord = isRecord$7(parsedRecord?.error) ? parsedRecord.error : void 0;
|
|
779
796
|
const message = nonEmptyString(errorRecord?.message) ?? (rawBody.trim() ? rawBody : void 0) ?? (response.statusText.trim() ? response.statusText : void 0) ?? "Audio speech provider request failed";
|
|
780
797
|
const code = nonEmptyString(errorRecord?.code);
|
|
781
798
|
return new GenerationProviderError(message, {
|
|
@@ -798,7 +815,7 @@ function unsupportedSuccessResponse(response, rawBody) {
|
|
|
798
815
|
}
|
|
799
816
|
function parseSuccessResponse(response, rawBody) {
|
|
800
817
|
const parsed = parseJson(rawBody);
|
|
801
|
-
if (!isRecord$
|
|
818
|
+
if (!isRecord$7(parsed)) throw unsupportedSuccessResponse(response, rawBody);
|
|
802
819
|
const urlValue = nonEmptyString(parsed.url);
|
|
803
820
|
const contentType = nonEmptyString(parsed.content_type);
|
|
804
821
|
if (!urlValue || parsed.media_type !== "audio" || !contentType || !/^audio\/[^\s/;]+(?:\s*;.*)?$/i.test(contentType)) throw unsupportedSuccessResponse(response, rawBody);
|
|
@@ -839,6 +856,132 @@ async function generateAudioSpeech(input) {
|
|
|
839
856
|
}
|
|
840
857
|
const audioSpeechAdapter = Object.assign(generateAudioSpeech, { validate: validateAudioSpeechRequest });
|
|
841
858
|
|
|
859
|
+
//#endregion
|
|
860
|
+
//#region src/response-fields.ts
|
|
861
|
+
function numberValue(value) {
|
|
862
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
863
|
+
}
|
|
864
|
+
function stringValue(value) {
|
|
865
|
+
return typeof value === "string" && value ? value : void 0;
|
|
866
|
+
}
|
|
867
|
+
function isRecord$6(value) {
|
|
868
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
869
|
+
}
|
|
870
|
+
function extractGenerationResultHeaderFields(headers) {
|
|
871
|
+
const requestId = headers.get("x-request-id")?.trim() || void 0;
|
|
872
|
+
const oneApiRequestId = headers.get("x-oneapi-request-id")?.trim() || void 0;
|
|
873
|
+
return requestId || oneApiRequestId ? {
|
|
874
|
+
...requestId ? { requestId } : {},
|
|
875
|
+
...oneApiRequestId ? { oneApiRequestId } : {}
|
|
876
|
+
} : void 0;
|
|
877
|
+
}
|
|
878
|
+
function extractGenerationResultFields(raw) {
|
|
879
|
+
if (!isRecord$6(raw)) return void 0;
|
|
880
|
+
const usage = isRecord$6(raw.usage) ? raw.usage : void 0;
|
|
881
|
+
const fields = {};
|
|
882
|
+
const requestId = stringValue(raw.request_id);
|
|
883
|
+
const cost = usage ? numberValue(usage.cost) : void 0;
|
|
884
|
+
if (requestId !== void 0) fields.requestId = requestId;
|
|
885
|
+
if (cost !== void 0) fields.cost = cost;
|
|
886
|
+
return Object.keys(fields).length > 0 ? fields : void 0;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
//#endregion
|
|
890
|
+
//#region src/adapters/audio-transcription.ts
|
|
891
|
+
const FORMATS = new Set([
|
|
892
|
+
"wav",
|
|
893
|
+
"mp3",
|
|
894
|
+
"ogg",
|
|
895
|
+
"raw"
|
|
896
|
+
]);
|
|
897
|
+
function isRecord$5(value) {
|
|
898
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
899
|
+
}
|
|
900
|
+
function buildAudioTranscriptionPayload(input) {
|
|
901
|
+
const [audio] = input.request.content;
|
|
902
|
+
if (input.request.content.length !== 1 || audio?.type !== "audio" || audio.source.type !== "url") throw new GenerationValidationError("Audio transcription requires exactly one audio URL");
|
|
903
|
+
let url;
|
|
904
|
+
try {
|
|
905
|
+
url = new URL(audio.source.url.trim());
|
|
906
|
+
} catch {
|
|
907
|
+
throw new GenerationValidationError("Audio transcription requires a valid HTTP(S) URL");
|
|
908
|
+
}
|
|
909
|
+
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) throw new GenerationValidationError("Audio transcription requires an HTTP(S) URL without credentials");
|
|
910
|
+
for (const meta of [
|
|
911
|
+
input.request.meta,
|
|
912
|
+
input.request.metadata,
|
|
913
|
+
audio.meta
|
|
914
|
+
]) if (Object.keys(meta ?? {}).length > 0) throw new GenerationValidationError("Audio transcription does not accept metadata; use parameters");
|
|
915
|
+
const extension = url.pathname.split("/").at(-1)?.split(".").slice(1).at(-1)?.toLowerCase();
|
|
916
|
+
const format = input.parameters.audio_format ?? extension;
|
|
917
|
+
if (typeof format !== "string" || !FORMATS.has(format)) throw new GenerationValidationError("Specify audio_format as wav, mp3, ogg or raw when the URL has no supported extension");
|
|
918
|
+
const language = input.parameters.language;
|
|
919
|
+
if (language !== void 0 && (typeof language !== "string" || language.trim().length === 0)) throw new GenerationValidationError("language must be a non-empty Volcengine language code, for example zh-CN");
|
|
920
|
+
return {
|
|
921
|
+
model: input.declaration.model,
|
|
922
|
+
audio_url: url.href,
|
|
923
|
+
audio_format: format,
|
|
924
|
+
...language !== void 0 ? { language } : {},
|
|
925
|
+
response_format: "verbose_json"
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
function parseAudioTranscriptionResponse(raw) {
|
|
929
|
+
if (!isRecord$5(raw) || typeof raw.text !== "string" || typeof raw.duration !== "number" || !Number.isFinite(raw.duration) || raw.duration <= 0) throw new GenerationProviderError("Audio transcription response requires text and a positive duration");
|
|
930
|
+
const segments = [];
|
|
931
|
+
if (raw.segments !== void 0) {
|
|
932
|
+
if (!Array.isArray(raw.segments)) throw new GenerationProviderError("Invalid transcription segments");
|
|
933
|
+
for (const segment of raw.segments) {
|
|
934
|
+
if (!isRecord$5(segment) || typeof segment.text !== "string" || typeof segment.start !== "number" || !Number.isFinite(segment.start) || segment.start < 0 || typeof segment.end !== "number" || !Number.isFinite(segment.end) || segment.end < segment.start) throw new GenerationProviderError("Invalid transcription segment text or timestamps");
|
|
935
|
+
segments.push({
|
|
936
|
+
start: segment.start,
|
|
937
|
+
end: segment.end,
|
|
938
|
+
text: segment.text
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
return {
|
|
943
|
+
type: "text",
|
|
944
|
+
text: raw.text,
|
|
945
|
+
meta: {
|
|
946
|
+
duration: raw.duration,
|
|
947
|
+
segments
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
}
|
|
951
|
+
async function generateAudioTranscription(input) {
|
|
952
|
+
const payload = buildAudioTranscriptionPayload(input);
|
|
953
|
+
const response = await fetchWithTimeout(input.context.fetch, joinUrl(input.context.baseUrl, "/v1/audio/transcriptions"), {
|
|
954
|
+
method: "POST",
|
|
955
|
+
headers: {
|
|
956
|
+
Authorization: `Bearer ${input.context.apiKey}`,
|
|
957
|
+
"Content-Type": "application/json"
|
|
958
|
+
},
|
|
959
|
+
body: JSON.stringify(payload)
|
|
960
|
+
}, Number(input.parameters.max_wait) * 1e3);
|
|
961
|
+
const body = await response.text();
|
|
962
|
+
const headers = extractGenerationResultHeaderFields(response.headers);
|
|
963
|
+
const details = { requestId: headers?.requestId ?? headers?.oneApiRequestId };
|
|
964
|
+
if (!response.ok) throw new GenerationProviderError(`Audio transcription failed (HTTP ${response.status}): ${body}`, {
|
|
965
|
+
status: response.status,
|
|
966
|
+
body,
|
|
967
|
+
details
|
|
968
|
+
});
|
|
969
|
+
let raw;
|
|
970
|
+
try {
|
|
971
|
+
raw = JSON.parse(body);
|
|
972
|
+
} catch {
|
|
973
|
+
throw new GenerationProviderError("Audio transcription returned invalid JSON", {
|
|
974
|
+
status: response.status,
|
|
975
|
+
body,
|
|
976
|
+
details
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
return [parseAudioTranscriptionResponse(raw)];
|
|
980
|
+
}
|
|
981
|
+
const audioTranscriptionAdapter = Object.assign(generateAudioTranscription, { validate(input) {
|
|
982
|
+
buildAudioTranscriptionPayload(input);
|
|
983
|
+
} });
|
|
984
|
+
|
|
842
985
|
//#endregion
|
|
843
986
|
//#region src/adapters/gemini-generate-content.ts
|
|
844
987
|
const REQUEST_TIMEOUT_MS$6 = 3e5;
|
|
@@ -1008,7 +1151,7 @@ function asInteger$2(value, fallback) {
|
|
|
1008
1151
|
function asNumber(value) {
|
|
1009
1152
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1010
1153
|
}
|
|
1011
|
-
function isRecord$
|
|
1154
|
+
function isRecord$4(value) {
|
|
1012
1155
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1013
1156
|
}
|
|
1014
1157
|
function providerMeta(input) {
|
|
@@ -1150,7 +1293,7 @@ async function requestJson$3(input, path, init) {
|
|
|
1150
1293
|
});
|
|
1151
1294
|
}
|
|
1152
1295
|
if (!response.ok) {
|
|
1153
|
-
const details = isRecord$
|
|
1296
|
+
const details = isRecord$4(parsed) ? { details: parsed } : {};
|
|
1154
1297
|
throw new GenerationProviderError("Kling video provider request failed", {
|
|
1155
1298
|
status: response.status,
|
|
1156
1299
|
body,
|
|
@@ -1234,7 +1377,7 @@ function asInteger$1(value, fallback) {
|
|
|
1234
1377
|
function asBoolean(value, fallback) {
|
|
1235
1378
|
return typeof value === "boolean" ? value : fallback;
|
|
1236
1379
|
}
|
|
1237
|
-
function isRecord$
|
|
1380
|
+
function isRecord$3(value) {
|
|
1238
1381
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1239
1382
|
}
|
|
1240
1383
|
function normalizeStatus$2(value) {
|
|
@@ -1347,7 +1490,7 @@ function resolveRatio(value, mode) {
|
|
|
1347
1490
|
return mode === "text" && requested === ADAPTIVE_RATIO ? DEFAULT_RATIO : requested;
|
|
1348
1491
|
}
|
|
1349
1492
|
function extractTaskId$2(response) {
|
|
1350
|
-
const data = isRecord$
|
|
1493
|
+
const data = isRecord$3(response.data) ? response.data : void 0;
|
|
1351
1494
|
const taskId = asString$2(response.task_id) ?? asString$2(response.id) ?? asString$2(data?.task_id) ?? asString$2(data?.id);
|
|
1352
1495
|
if (!taskId) throw new GenerationProviderError("MiniMax H3 provider did not return a task id", { details: { response } });
|
|
1353
1496
|
return taskId;
|
|
@@ -1365,17 +1508,17 @@ function isTaskPayload(value) {
|
|
|
1365
1508
|
].some((key) => key in value);
|
|
1366
1509
|
}
|
|
1367
1510
|
function unwrapTaskPayload$1(response) {
|
|
1368
|
-
const data = isRecord$
|
|
1511
|
+
const data = isRecord$3(response.data) ? response.data : void 0;
|
|
1369
1512
|
return data && !isTaskPayload(response) ? data : response;
|
|
1370
1513
|
}
|
|
1371
1514
|
function extractTaskStatus$1(response) {
|
|
1372
1515
|
const payload = unwrapTaskPayload$1(response);
|
|
1373
|
-
const task = isRecord$
|
|
1374
|
-
const metadata = isRecord$
|
|
1375
|
-
const content = isRecord$
|
|
1516
|
+
const task = isRecord$3(payload.task) ? payload.task : payload;
|
|
1517
|
+
const metadata = isRecord$3(payload.metadata) ? payload.metadata : isRecord$3(task.metadata) ? task.metadata : void 0;
|
|
1518
|
+
const content = isRecord$3(task.content) ? task.content : void 0;
|
|
1376
1519
|
const status = normalizeStatus$2(payload.status ?? task.status);
|
|
1377
1520
|
const videoUrl = asString$2(metadata?.url) ?? asString$2(payload.result_url) ?? asString$2(payload.video_url) ?? asString$2(payload.url) ?? asString$2(task.result_url) ?? asString$2(task.video_url) ?? asString$2(task.url) ?? asString$2(content?.video_url) ?? asString$2(content?.url);
|
|
1378
|
-
const error = isRecord$
|
|
1521
|
+
const error = isRecord$3(payload.error) ? payload.error : isRecord$3(task.error) ? task.error : void 0;
|
|
1379
1522
|
const message = asString$2(error?.message) ?? asString$2(payload.fail_reason) ?? asString$2(payload.message) ?? asString$2(task.fail_reason) ?? asString$2(task.message) ?? asString$2(response.message);
|
|
1380
1523
|
const outputMetadata = compactObject({
|
|
1381
1524
|
progress: payload.progress ?? task.progress,
|
|
@@ -1412,7 +1555,7 @@ async function requestJson$2(input, path, init) {
|
|
|
1412
1555
|
if (!response.ok) throw new GenerationProviderError("MiniMax H3 provider request failed", {
|
|
1413
1556
|
status: response.status,
|
|
1414
1557
|
body,
|
|
1415
|
-
...isRecord$
|
|
1558
|
+
...isRecord$3(parsed) ? { details: parsed } : {}
|
|
1416
1559
|
});
|
|
1417
1560
|
return parsed;
|
|
1418
1561
|
}
|
|
@@ -1676,7 +1819,7 @@ const FINAL_FAILURE_STATUSES = new Set([
|
|
|
1676
1819
|
"canceled",
|
|
1677
1820
|
"expired"
|
|
1678
1821
|
]);
|
|
1679
|
-
function isRecord$
|
|
1822
|
+
function isRecord$2(value) {
|
|
1680
1823
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1681
1824
|
}
|
|
1682
1825
|
function asString$1(value) {
|
|
@@ -1686,7 +1829,7 @@ function asInteger(value, fallback) {
|
|
|
1686
1829
|
return typeof value === "number" && Number.isInteger(value) ? value : fallback;
|
|
1687
1830
|
}
|
|
1688
1831
|
function asRecord(value) {
|
|
1689
|
-
return isRecord$
|
|
1832
|
+
return isRecord$2(value) ? value : {};
|
|
1690
1833
|
}
|
|
1691
1834
|
function successCode(value) {
|
|
1692
1835
|
const code = String(value ?? "").trim().toLowerCase();
|
|
@@ -1702,7 +1845,7 @@ function requireSuccess(response, fallbackMessage) {
|
|
|
1702
1845
|
}
|
|
1703
1846
|
function extractTaskId$1(value) {
|
|
1704
1847
|
if (typeof value === "string" && value.trim()) return value.trim();
|
|
1705
|
-
if (!isRecord$
|
|
1848
|
+
if (!isRecord$2(value)) return void 0;
|
|
1706
1849
|
for (const key of [
|
|
1707
1850
|
"task_id",
|
|
1708
1851
|
"id",
|
|
@@ -1720,7 +1863,7 @@ function normalizeStatus$1(value) {
|
|
|
1720
1863
|
}
|
|
1721
1864
|
function normalizeTask(operation, data) {
|
|
1722
1865
|
if (Array.isArray(data)) return data.length > 0 ? normalizeTask(operation, data[0]) : null;
|
|
1723
|
-
if (!isRecord$
|
|
1866
|
+
if (!isRecord$2(data)) return null;
|
|
1724
1867
|
if ("status" in data || "taskStatus" in data || "task_status" in data || "task_id" in data || "taskBatchId" in data) {
|
|
1725
1868
|
const hasProviderEnvelope = "taskStatus" in data || "task_status" in data || "taskBatchId" in data || "task_batch_id" in data;
|
|
1726
1869
|
return {
|
|
@@ -1753,7 +1896,12 @@ async function buildPayload(input, operation) {
|
|
|
1753
1896
|
};
|
|
1754
1897
|
const config = OPERATION_PATHS[operation];
|
|
1755
1898
|
const prompt = mergeTextBlocks(input.declaration, input.request.content);
|
|
1756
|
-
|
|
1899
|
+
const descriptionMode = operation === "music" && input.declaration.model === "suno_music_chirp_fenix";
|
|
1900
|
+
if (descriptionMode && prompt && payload.gpt_description_prompt === void 0) payload.gpt_description_prompt = prompt;
|
|
1901
|
+
if (descriptionMode && payload.lyrics !== void 0) {
|
|
1902
|
+
if (payload.prompt === void 0) payload.prompt = payload.lyrics;
|
|
1903
|
+
delete payload.lyrics;
|
|
1904
|
+
} else if (prompt && config?.textField && payload[config.textField] === void 0 && !descriptionMode) payload[config.textField] = prompt;
|
|
1757
1905
|
const audioBlock = input.request.content.find((block) => block.type === "audio");
|
|
1758
1906
|
if (audioBlock && payload.url === void 0) payload.url = await input.context.resolveSource(audioBlock.source);
|
|
1759
1907
|
const imageBlock = input.request.content.find((block) => block.type === "image");
|
|
@@ -1791,7 +1939,7 @@ function applyFixedPayload(input, payload, fixed) {
|
|
|
1791
1939
|
}
|
|
1792
1940
|
}
|
|
1793
1941
|
function setMetadataParam(payload, key, value) {
|
|
1794
|
-
const metadataParams = isRecord$
|
|
1942
|
+
const metadataParams = isRecord$2(payload.metadata_params) ? payload.metadata_params : {};
|
|
1795
1943
|
if (metadataParams[key] === void 0) metadataParams[key] = value;
|
|
1796
1944
|
payload.metadata_params = metadataParams;
|
|
1797
1945
|
}
|
|
@@ -1861,8 +2009,8 @@ function appendSunoContent(output, value, meta = {}) {
|
|
|
1861
2009
|
for (const item of value) appendSunoContent(output, item, meta);
|
|
1862
2010
|
return;
|
|
1863
2011
|
}
|
|
1864
|
-
if (!isRecord$
|
|
1865
|
-
if (isRecord$
|
|
2012
|
+
if (!isRecord$2(value)) return;
|
|
2013
|
+
if (isRecord$2(value.clips)) for (const clip of Object.values(value.clips)) appendSunoContent(output, clip, meta);
|
|
1866
2014
|
if (Array.isArray(value.items)) for (const item of value.items) appendSunoContent(output, item, meta);
|
|
1867
2015
|
const itemMeta = compactObject({
|
|
1868
2016
|
...meta,
|
|
@@ -1872,9 +2020,9 @@ function appendSunoContent(output, value, meta = {}) {
|
|
|
1872
2020
|
title: value.title,
|
|
1873
2021
|
status: value.status ?? meta.status,
|
|
1874
2022
|
model: value.model_name ?? value.modelName,
|
|
1875
|
-
duration: value.duration ?? (isRecord$
|
|
1876
|
-
tags: value.tags ?? (isRecord$
|
|
1877
|
-
prompt: value.prompt ?? (isRecord$
|
|
2023
|
+
duration: value.duration ?? (isRecord$2(value.metadata) ? value.metadata.duration : void 0),
|
|
2024
|
+
tags: value.tags ?? (isRecord$2(value.metadata) ? value.metadata.tags : void 0),
|
|
2025
|
+
prompt: value.prompt ?? (isRecord$2(value.metadata) ? value.metadata.prompt : void 0),
|
|
1878
2026
|
progress: value.progress ?? meta.progress,
|
|
1879
2027
|
progress_message: value.progressMsg ?? value.progress_msg,
|
|
1880
2028
|
task_batch_id: value.taskBatchId ?? value.task_batch_id,
|
|
@@ -1895,7 +2043,7 @@ function appendSunoContent(output, value, meta = {}) {
|
|
|
1895
2043
|
text,
|
|
1896
2044
|
meta: itemMeta
|
|
1897
2045
|
});
|
|
1898
|
-
if (isRecord$
|
|
2046
|
+
if (isRecord$2(value.data)) appendSunoContent(output, value.data, itemMeta);
|
|
1899
2047
|
}
|
|
1900
2048
|
function buildImmediateResult(operation, data, raw) {
|
|
1901
2049
|
const output = [];
|
|
@@ -1988,7 +2136,7 @@ async function sunoTasksAdapter(input) {
|
|
|
1988
2136
|
const REQUEST_TIMEOUT_MS = 186e4;
|
|
1989
2137
|
const DEFAULT_POLL_INTERVAL_SEC = 1;
|
|
1990
2138
|
const DEFAULT_MAX_WAIT_SEC = 600;
|
|
1991
|
-
function isRecord$
|
|
2139
|
+
function isRecord$1(value) {
|
|
1992
2140
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1993
2141
|
}
|
|
1994
2142
|
function asString(value) {
|
|
@@ -2021,7 +2169,7 @@ function normalizeStatus(value) {
|
|
|
2021
2169
|
return status || "unknown";
|
|
2022
2170
|
}
|
|
2023
2171
|
function unwrapTaskPayload(response) {
|
|
2024
|
-
const data = isRecord$
|
|
2172
|
+
const data = isRecord$1(response.data) ? response.data : void 0;
|
|
2025
2173
|
const hasTaskFields = [
|
|
2026
2174
|
"status",
|
|
2027
2175
|
"task",
|
|
@@ -2035,19 +2183,19 @@ function unwrapTaskPayload(response) {
|
|
|
2035
2183
|
return data && !hasTaskFields ? data : response;
|
|
2036
2184
|
}
|
|
2037
2185
|
function extractTaskId(response) {
|
|
2038
|
-
const data = isRecord$
|
|
2186
|
+
const data = isRecord$1(response.data) ? response.data : void 0;
|
|
2039
2187
|
const taskId = asString(response.task_id) ?? asString(response.id) ?? asString(data?.task_id) ?? asString(data?.id);
|
|
2040
2188
|
if (!taskId) throw new GenerationProviderError("Video upscale provider did not return a task id", { details: { response } });
|
|
2041
2189
|
return taskId;
|
|
2042
2190
|
}
|
|
2043
2191
|
function extractTaskStatus(response) {
|
|
2044
2192
|
const payload = unwrapTaskPayload(response);
|
|
2045
|
-
const task = isRecord$
|
|
2046
|
-
const metadata = isRecord$
|
|
2047
|
-
const content = isRecord$
|
|
2193
|
+
const task = isRecord$1(payload.task) ? payload.task : payload;
|
|
2194
|
+
const metadata = isRecord$1(payload.metadata) ? payload.metadata : isRecord$1(task.metadata) ? task.metadata : void 0;
|
|
2195
|
+
const content = isRecord$1(task.content) ? task.content : void 0;
|
|
2048
2196
|
const status = normalizeStatus(payload.status ?? task.status);
|
|
2049
2197
|
const videoUrl = asString(metadata?.url) ?? asString(payload.result_url) ?? asString(payload.video_url) ?? asString(payload.url) ?? asString(task.result_url) ?? asString(task.video_url) ?? asString(task.url) ?? asString(content?.video_url) ?? asString(content?.url);
|
|
2050
|
-
const error = isRecord$
|
|
2198
|
+
const error = isRecord$1(payload.error) ? payload.error : isRecord$1(task.error) ? task.error : void 0;
|
|
2051
2199
|
const message = asString(error?.message) ?? asString(payload.fail_reason) ?? asString(payload.message) ?? asString(task.fail_reason) ?? asString(task.message) ?? asString(response.message);
|
|
2052
2200
|
const outputMetadata = compactObject({
|
|
2053
2201
|
progress: payload.progress ?? task.progress,
|
|
@@ -2083,7 +2231,7 @@ async function requestJson(input, path, init) {
|
|
|
2083
2231
|
if (!response.ok) throw new GenerationProviderError("Video upscale provider request failed", {
|
|
2084
2232
|
status: response.status,
|
|
2085
2233
|
body,
|
|
2086
|
-
...isRecord$
|
|
2234
|
+
...isRecord$1(parsed) ? { details: parsed } : {}
|
|
2087
2235
|
});
|
|
2088
2236
|
return parsed;
|
|
2089
2237
|
}
|
|
@@ -2144,6 +2292,7 @@ async function videoUpscaleNativeAdapter(input) {
|
|
|
2144
2292
|
//#region src/adapters/index.ts
|
|
2145
2293
|
const builtinGenerationAdapters = {
|
|
2146
2294
|
"ark.videoGenerations": arkVideoGenerationsAdapter,
|
|
2295
|
+
"newapi.audioTranscription": audioTranscriptionAdapter,
|
|
2147
2296
|
"openai.audioSpeech": audioSpeechAdapter,
|
|
2148
2297
|
"gemini.generateContent": geminiGenerateContentAdapter,
|
|
2149
2298
|
"kling.videoGenerations": klingVideoGenerationsAdapter,
|
|
@@ -2169,14 +2318,14 @@ const DECLARATION_EXTENSIONS = new Set([
|
|
|
2169
2318
|
".yml",
|
|
2170
2319
|
".json"
|
|
2171
2320
|
]);
|
|
2172
|
-
function isRecord
|
|
2321
|
+
function isRecord(value) {
|
|
2173
2322
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
2174
2323
|
}
|
|
2175
2324
|
function isPositiveInteger(value) {
|
|
2176
2325
|
return typeof value === "number" && Number.isInteger(value) && value > 0;
|
|
2177
2326
|
}
|
|
2178
2327
|
function isDimensionsSpec(value) {
|
|
2179
|
-
if (!isRecord
|
|
2328
|
+
if (!isRecord(value)) return false;
|
|
2180
2329
|
if (value.separator !== void 0 && value.separator !== "x" && value.separator !== "*") return false;
|
|
2181
2330
|
if (value.min !== void 0 && !isPositiveInteger(value.min)) return false;
|
|
2182
2331
|
if (value.max !== void 0 && !isPositiveInteger(value.max)) return false;
|
|
@@ -2184,7 +2333,7 @@ function isDimensionsSpec(value) {
|
|
|
2184
2333
|
return value.min === void 0 || value.max === void 0 || value.min <= value.max;
|
|
2185
2334
|
}
|
|
2186
2335
|
function isParameterSpec(value) {
|
|
2187
|
-
if (!isRecord
|
|
2336
|
+
if (!isRecord(value)) return false;
|
|
2188
2337
|
if (![
|
|
2189
2338
|
"string",
|
|
2190
2339
|
"number",
|
|
@@ -2194,11 +2343,11 @@ function isParameterSpec(value) {
|
|
|
2194
2343
|
return value.type !== "string" || value.dimensions === void 0 || isDimensionsSpec(value.dimensions);
|
|
2195
2344
|
}
|
|
2196
2345
|
function isMetaFieldSpec(value) {
|
|
2197
|
-
if (!isRecord
|
|
2346
|
+
if (!isRecord(value)) return false;
|
|
2198
2347
|
return isParameterSpec(value) || String(value.type) === "object";
|
|
2199
2348
|
}
|
|
2200
2349
|
function isMetaTaskVariantSpec(value) {
|
|
2201
|
-
if (!isRecord
|
|
2350
|
+
if (!isRecord(value)) return false;
|
|
2202
2351
|
return (value.description === void 0 || typeof value.description === "string") && (value.required === void 0 || Array.isArray(value.required) && value.required.every((item) => typeof item === "string")) && (value.requiredContent === void 0 || Array.isArray(value.requiredContent) && value.requiredContent.every((item) => typeof item === "string")) && (value.sendTask === void 0 || typeof value.sendTask === "boolean");
|
|
2203
2352
|
}
|
|
2204
2353
|
function isGenerationModelCategory(value) {
|
|
@@ -2208,7 +2357,7 @@ function isFiniteNonNegative(value) {
|
|
|
2208
2357
|
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
2209
2358
|
}
|
|
2210
2359
|
function isGenerationModelPricing(value) {
|
|
2211
|
-
if (!isRecord
|
|
2360
|
+
if (!isRecord(value)) return false;
|
|
2212
2361
|
if (typeof value.unit !== "string" || !GENERATION_PRICING_UNITS.includes(value.unit)) return false;
|
|
2213
2362
|
if (value.note !== void 0 && typeof value.note !== "string") return false;
|
|
2214
2363
|
if (value.amount !== void 0) {
|
|
@@ -2218,17 +2367,17 @@ function isGenerationModelPricing(value) {
|
|
|
2218
2367
|
return isFiniteNonNegative(value.min) && isFiniteNonNegative(value.max) && value.min <= value.max;
|
|
2219
2368
|
}
|
|
2220
2369
|
function isMetaSpec(value) {
|
|
2221
|
-
if (!isRecord
|
|
2222
|
-
return (value.fields === void 0 || isRecord
|
|
2370
|
+
if (!isRecord(value)) return false;
|
|
2371
|
+
return (value.fields === void 0 || isRecord(value.fields) && Object.values(value.fields).every((field) => isMetaFieldSpec(field))) && (value.taskField === void 0 || typeof value.taskField === "string") && (value.taskVariants === void 0 || isRecord(value.taskVariants) && Object.values(value.taskVariants).every((variant) => isMetaTaskVariantSpec(variant)));
|
|
2223
2372
|
}
|
|
2224
2373
|
function isGenerationModelDeclaration(value) {
|
|
2225
|
-
if (!isRecord
|
|
2374
|
+
if (!isRecord(value)) return false;
|
|
2226
2375
|
const adapter = value.adapter;
|
|
2227
2376
|
const content = value.content;
|
|
2228
2377
|
const parameters = value.parameters;
|
|
2229
2378
|
const meta = value.meta;
|
|
2230
2379
|
const examples = value.examples;
|
|
2231
|
-
return value.schema === MODEL_SCHEMA && typeof value.model === "string" && value.model.trim().length > 0 && (value.category === void 0 || isGenerationModelCategory(value.category)) && (value.pricing === void 0 || isGenerationModelPricing(value.pricing)) && (value.hidden === void 0 || typeof value.hidden === "boolean") && (value.allowUnknownParameters === void 0 || typeof value.allowUnknownParameters === "boolean") && isRecord
|
|
2380
|
+
return value.schema === MODEL_SCHEMA && typeof value.model === "string" && value.model.trim().length > 0 && (value.category === void 0 || isGenerationModelCategory(value.category)) && (value.pricing === void 0 || isGenerationModelPricing(value.pricing)) && (value.hidden === void 0 || typeof value.hidden === "boolean") && (value.allowUnknownParameters === void 0 || typeof value.allowUnknownParameters === "boolean") && isRecord(adapter) && typeof adapter.type === "string" && isRecord(content) && Array.isArray(content.input) && (parameters === void 0 || isRecord(parameters) && Object.values(parameters).every(isParameterSpec)) && (meta === void 0 || isMetaSpec(meta)) && (examples === void 0 || Array.isArray(examples));
|
|
2232
2381
|
}
|
|
2233
2382
|
function parseGenerationModelDeclaration(rawText, filePath = "model.yaml") {
|
|
2234
2383
|
const parsed = extname(filePath) === ".json" ? JSON.parse(rawText) : parse(rawText);
|
|
@@ -2263,36 +2412,6 @@ async function writeGenerationModelDeclarations(declarations, directory, options
|
|
|
2263
2412
|
await Promise.all(declarations.map((declaration) => writeGenerationModelDeclaration(declaration, join(directory, `${slugifyFileName(declaration.model)}.${ext}`), options)));
|
|
2264
2413
|
}
|
|
2265
2414
|
|
|
2266
|
-
//#endregion
|
|
2267
|
-
//#region src/response-fields.ts
|
|
2268
|
-
function numberValue(value) {
|
|
2269
|
-
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
2270
|
-
}
|
|
2271
|
-
function stringValue(value) {
|
|
2272
|
-
return typeof value === "string" && value ? value : void 0;
|
|
2273
|
-
}
|
|
2274
|
-
function isRecord(value) {
|
|
2275
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
2276
|
-
}
|
|
2277
|
-
function extractGenerationResultHeaderFields(headers) {
|
|
2278
|
-
const requestId = headers.get("x-request-id")?.trim() || void 0;
|
|
2279
|
-
const oneApiRequestId = headers.get("x-oneapi-request-id")?.trim() || void 0;
|
|
2280
|
-
return requestId || oneApiRequestId ? {
|
|
2281
|
-
...requestId ? { requestId } : {},
|
|
2282
|
-
...oneApiRequestId ? { oneApiRequestId } : {}
|
|
2283
|
-
} : void 0;
|
|
2284
|
-
}
|
|
2285
|
-
function extractGenerationResultFields(raw) {
|
|
2286
|
-
if (!isRecord(raw)) return void 0;
|
|
2287
|
-
const usage = isRecord(raw.usage) ? raw.usage : void 0;
|
|
2288
|
-
const fields = {};
|
|
2289
|
-
const requestId = stringValue(raw.request_id);
|
|
2290
|
-
const cost = usage ? numberValue(usage.cost) : void 0;
|
|
2291
|
-
if (requestId !== void 0) fields.requestId = requestId;
|
|
2292
|
-
if (cost !== void 0) fields.cost = cost;
|
|
2293
|
-
return Object.keys(fields).length > 0 ? fields : void 0;
|
|
2294
|
-
}
|
|
2295
|
-
|
|
2296
2415
|
//#endregion
|
|
2297
2416
|
//#region src/source.ts
|
|
2298
2417
|
const defaultGenerationSourceResolver = (source) => {
|
|
@@ -2518,5 +2637,5 @@ async function exportBuiltinModelConfigs(directory) {
|
|
|
2518
2637
|
}
|
|
2519
2638
|
|
|
2520
2639
|
//#endregion
|
|
2521
|
-
export {
|
|
2522
|
-
//# sourceMappingURL=export-config-
|
|
2640
|
+
export { mergeGenerationMeta as A, GenerationUnsupportedAdapterError as B, openAiImageEditsAdapter as C, audioTranscriptionAdapter as D, geminiGenerateContentAdapter as E, GenerationConfigError as F, GenerationError as I, GenerationProviderError as L, resolveGenerationMeta as M, resolveGenerationParameters as N, audioSpeechAdapter as O, validateGenerationContent as P, GenerationTimeoutError as R, openAiImagesAdapter as S, klingVideoGenerationsAdapter as T, GenerationValidationError as V, writeGenerationModelDeclarations as _, createGenerationClientFromDirectory as a, videoUpscaleNativeAdapter as b, defaultGenerationSourceResolver as c, parseGenerationModelDeclaration as d, readGenerationModelDeclaration as f, writeGenerationModelDeclaration as g, stringifyGenerationModelDeclaration as h, createGenerationClient as i, mergeTextBlocks as j, arkVideoGenerationsAdapter as k, isGenerationModelDeclaration as l, readGenerationModelDeclarationsFromFiles as m, exportBuiltinModelConfigs as n, createGenerationClientFromFile as o, readGenerationModelDeclarationsFromDirectory as p, stringifyBuiltinModelConfig as r, createGenerationClientFromFiles as s, exportBuiltinModelConfig as t, mergeGenerationModelDeclarations as u, builtinGenerationAdapters as v, minimaxH3VideoGenerationsAdapter as w, sunoTasksAdapter as x, getGenerationAdapter as y, GenerationTransportError as z };
|
|
2641
|
+
//# sourceMappingURL=export-config-DRotzV5u.js.map
|