@neta-art/generation 0.1.10 → 0.1.12
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 +14 -0
- package/dist/{builtins-CcT0Ufp2.js → builtins-BvtiQicj.js} +6 -8
- package/dist/builtins-BvtiQicj.js.map +1 -0
- package/dist/{builtins-CWEB_GK4.d.ts → builtins-H7pH9ppJ.d.ts} +11 -4
- package/dist/builtins-H7pH9ppJ.d.ts.map +1 -0
- package/dist/builtins.d.ts +1 -1
- package/dist/builtins.js +2 -3
- package/dist/cli/index.js +4 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/{export-config-DolxdQdi.js → export-config-BXD4Adwb.js} +103 -67
- package/dist/export-config-BXD4Adwb.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/package.json +1 -1
- package/dist/builtins-CWEB_GK4.d.ts.map +0 -1
- package/dist/builtins-CcT0Ufp2.js.map +0 -1
- package/dist/export-config-DolxdQdi.js.map +0 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as cloneJson, c as getBlockMeta, l as slugifyFileName, n as getBuiltinGenerationModel, o as compactArray, r as listBuiltinGenerationModels, s as compactObject, t as builtinGenerationModels } from "./builtins-BvtiQicj.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";
|
|
5
|
-
|
|
6
5
|
//#region src/errors.ts
|
|
7
6
|
var GenerationError = class extends Error {
|
|
8
7
|
constructor(message) {
|
|
@@ -46,7 +45,6 @@ var GenerationTimeoutError = class extends GenerationProviderError {
|
|
|
46
45
|
this.name = "GenerationTimeoutError";
|
|
47
46
|
}
|
|
48
47
|
};
|
|
49
|
-
|
|
50
48
|
//#endregion
|
|
51
49
|
//#region src/http.ts
|
|
52
50
|
function headersToRecord(headers) {
|
|
@@ -134,7 +132,6 @@ async function fetchWithTimeout(fetchFn, url, init, timeoutMs) {
|
|
|
134
132
|
function joinUrl(baseUrl, path) {
|
|
135
133
|
return `${baseUrl.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
|
|
136
134
|
}
|
|
137
|
-
|
|
138
135
|
//#endregion
|
|
139
136
|
//#region src/validation.ts
|
|
140
137
|
function specsByType(specs) {
|
|
@@ -256,7 +253,6 @@ function mergeTextBlocks(declaration, content) {
|
|
|
256
253
|
const separator = textSpec?.merge === "space" ? " " : textSpec?.merge === "concat" ? "" : "\n";
|
|
257
254
|
return content.filter((block) => block.type === "text").map((block) => block.text).join(separator).trim();
|
|
258
255
|
}
|
|
259
|
-
|
|
260
256
|
//#endregion
|
|
261
257
|
//#region src/adapters/ark-video-generations.ts
|
|
262
258
|
const REQUEST_TIMEOUT_MS$5 = 186e4;
|
|
@@ -498,7 +494,6 @@ async function arkVideoGenerationsAdapter(input) {
|
|
|
498
494
|
}
|
|
499
495
|
throw new GenerationTimeoutError("Timed out waiting for video generation", { taskId });
|
|
500
496
|
}
|
|
501
|
-
|
|
502
497
|
//#endregion
|
|
503
498
|
//#region src/adapters/gemini-generate-content.ts
|
|
504
499
|
const REQUEST_TIMEOUT_MS$4 = 3e5;
|
|
@@ -630,7 +625,6 @@ async function geminiGenerateContentAdapter(input) {
|
|
|
630
625
|
if (output.length === 0) throw new GenerationProviderError("Gemini generation returned no output", { details: collectGeminiNoOutputDetails(raw) });
|
|
631
626
|
return output;
|
|
632
627
|
}
|
|
633
|
-
|
|
634
628
|
//#endregion
|
|
635
629
|
//#region src/adapters/kling-video-generations.ts
|
|
636
630
|
const REQUEST_TIMEOUT_MS$3 = 186e4;
|
|
@@ -671,7 +665,7 @@ function asInteger$1(value, fallback) {
|
|
|
671
665
|
function asNumber(value) {
|
|
672
666
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
673
667
|
}
|
|
674
|
-
function isRecord$
|
|
668
|
+
function isRecord$3(value) {
|
|
675
669
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
676
670
|
}
|
|
677
671
|
function providerMeta(input) {
|
|
@@ -813,7 +807,7 @@ async function requestJson$1(input, path, init) {
|
|
|
813
807
|
});
|
|
814
808
|
}
|
|
815
809
|
if (!response.ok) {
|
|
816
|
-
const details = isRecord$
|
|
810
|
+
const details = isRecord$3(parsed) ? { details: parsed } : {};
|
|
817
811
|
throw new GenerationProviderError("Kling video provider request failed", {
|
|
818
812
|
status: response.status,
|
|
819
813
|
body,
|
|
@@ -869,7 +863,6 @@ async function klingVideoGenerationsAdapter(input) {
|
|
|
869
863
|
}
|
|
870
864
|
throw new GenerationTimeoutError("Timed out waiting for Kling video generation", { taskId });
|
|
871
865
|
}
|
|
872
|
-
|
|
873
866
|
//#endregion
|
|
874
867
|
//#region src/adapters/openai-image-edits.ts
|
|
875
868
|
const REQUEST_TIMEOUT_MS$2 = 3e5;
|
|
@@ -939,7 +932,6 @@ async function openAiImageEditsAdapter(input) {
|
|
|
939
932
|
if (output.length === 0) throw new GenerationProviderError("Image edit returned no output", { details: collectOpenAiImageEditsNoOutputDetails(raw) });
|
|
940
933
|
return output;
|
|
941
934
|
}
|
|
942
|
-
|
|
943
935
|
//#endregion
|
|
944
936
|
//#region src/adapters/openai-images.ts
|
|
945
937
|
const REQUEST_TIMEOUT_MS$1 = 3e5;
|
|
@@ -1016,7 +1008,6 @@ async function openAiImagesAdapter(input) {
|
|
|
1016
1008
|
if (output.length === 0) throw new GenerationProviderError("Image generation returned no output", { details: collectOpenAiImagesNoOutputDetails(raw) });
|
|
1017
1009
|
return output;
|
|
1018
1010
|
}
|
|
1019
|
-
|
|
1020
1011
|
//#endregion
|
|
1021
1012
|
//#region src/adapters/suno-tasks.ts
|
|
1022
1013
|
const REQUEST_TIMEOUT_MS = 6e4;
|
|
@@ -1051,12 +1042,12 @@ const OPERATION_PATHS = {
|
|
|
1051
1042
|
poll: true
|
|
1052
1043
|
}
|
|
1053
1044
|
};
|
|
1054
|
-
const FINAL_SUCCESS_STATUSES = new Set([
|
|
1045
|
+
const FINAL_SUCCESS_STATUSES = /* @__PURE__ */ new Set([
|
|
1055
1046
|
"success",
|
|
1056
1047
|
"succeeded",
|
|
1057
1048
|
"completed"
|
|
1058
1049
|
]);
|
|
1059
|
-
const FINAL_FAILURE_STATUSES = new Set([
|
|
1050
|
+
const FINAL_FAILURE_STATUSES = /* @__PURE__ */ new Set([
|
|
1060
1051
|
"failure",
|
|
1061
1052
|
"failed",
|
|
1062
1053
|
"error",
|
|
@@ -1067,7 +1058,7 @@ const FINAL_FAILURE_STATUSES = new Set([
|
|
|
1067
1058
|
function sleep(ms) {
|
|
1068
1059
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1069
1060
|
}
|
|
1070
|
-
function isRecord$
|
|
1061
|
+
function isRecord$2(value) {
|
|
1071
1062
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1072
1063
|
}
|
|
1073
1064
|
function asString(value) {
|
|
@@ -1077,7 +1068,7 @@ function asInteger(value, fallback) {
|
|
|
1077
1068
|
return typeof value === "number" && Number.isInteger(value) ? value : fallback;
|
|
1078
1069
|
}
|
|
1079
1070
|
function asRecord(value) {
|
|
1080
|
-
return isRecord$
|
|
1071
|
+
return isRecord$2(value) ? value : {};
|
|
1081
1072
|
}
|
|
1082
1073
|
function successCode(value) {
|
|
1083
1074
|
const code = String(value ?? "").trim().toLowerCase();
|
|
@@ -1093,7 +1084,7 @@ function requireSuccess(response, fallbackMessage) {
|
|
|
1093
1084
|
}
|
|
1094
1085
|
function extractTaskId(value) {
|
|
1095
1086
|
if (typeof value === "string" && value.trim()) return value.trim();
|
|
1096
|
-
if (!isRecord$
|
|
1087
|
+
if (!isRecord$2(value)) return void 0;
|
|
1097
1088
|
for (const key of [
|
|
1098
1089
|
"task_id",
|
|
1099
1090
|
"id",
|
|
@@ -1111,7 +1102,7 @@ function normalizeStatus(value) {
|
|
|
1111
1102
|
}
|
|
1112
1103
|
function normalizeTask(operation, data) {
|
|
1113
1104
|
if (Array.isArray(data)) return data.length > 0 ? normalizeTask(operation, data[0]) : null;
|
|
1114
|
-
if (!isRecord$
|
|
1105
|
+
if (!isRecord$2(data)) return null;
|
|
1115
1106
|
if ("status" in data || "taskStatus" in data || "task_status" in data || "task_id" in data || "taskBatchId" in data) {
|
|
1116
1107
|
const hasProviderEnvelope = "taskStatus" in data || "task_status" in data || "taskBatchId" in data || "task_batch_id" in data;
|
|
1117
1108
|
return {
|
|
@@ -1182,7 +1173,7 @@ function applyFixedPayload(input, payload, fixed) {
|
|
|
1182
1173
|
}
|
|
1183
1174
|
}
|
|
1184
1175
|
function setMetadataParam(payload, key, value) {
|
|
1185
|
-
const metadataParams = isRecord$
|
|
1176
|
+
const metadataParams = isRecord$2(payload.metadata_params) ? payload.metadata_params : {};
|
|
1186
1177
|
if (metadataParams[key] === void 0) metadataParams[key] = value;
|
|
1187
1178
|
payload.metadata_params = metadataParams;
|
|
1188
1179
|
}
|
|
@@ -1252,8 +1243,8 @@ function appendSunoContent(output, value, meta = {}) {
|
|
|
1252
1243
|
for (const item of value) appendSunoContent(output, item, meta);
|
|
1253
1244
|
return;
|
|
1254
1245
|
}
|
|
1255
|
-
if (!isRecord$
|
|
1256
|
-
if (isRecord$
|
|
1246
|
+
if (!isRecord$2(value)) return;
|
|
1247
|
+
if (isRecord$2(value.clips)) for (const clip of Object.values(value.clips)) appendSunoContent(output, clip, meta);
|
|
1257
1248
|
if (Array.isArray(value.items)) for (const item of value.items) appendSunoContent(output, item, meta);
|
|
1258
1249
|
const itemMeta = compactObject({
|
|
1259
1250
|
...meta,
|
|
@@ -1263,9 +1254,9 @@ function appendSunoContent(output, value, meta = {}) {
|
|
|
1263
1254
|
title: value.title,
|
|
1264
1255
|
status: value.status ?? meta.status,
|
|
1265
1256
|
model: value.model_name ?? value.modelName,
|
|
1266
|
-
duration: value.duration ?? (isRecord$
|
|
1267
|
-
tags: value.tags ?? (isRecord$
|
|
1268
|
-
prompt: value.prompt ?? (isRecord$
|
|
1257
|
+
duration: value.duration ?? (isRecord$2(value.metadata) ? value.metadata.duration : void 0),
|
|
1258
|
+
tags: value.tags ?? (isRecord$2(value.metadata) ? value.metadata.tags : void 0),
|
|
1259
|
+
prompt: value.prompt ?? (isRecord$2(value.metadata) ? value.metadata.prompt : void 0),
|
|
1269
1260
|
progress: value.progress ?? meta.progress,
|
|
1270
1261
|
progress_message: value.progressMsg ?? value.progress_msg,
|
|
1271
1262
|
task_batch_id: value.taskBatchId ?? value.task_batch_id,
|
|
@@ -1286,7 +1277,7 @@ function appendSunoContent(output, value, meta = {}) {
|
|
|
1286
1277
|
text,
|
|
1287
1278
|
meta: itemMeta
|
|
1288
1279
|
});
|
|
1289
|
-
if (isRecord$
|
|
1280
|
+
if (isRecord$2(value.data)) appendSunoContent(output, value.data, itemMeta);
|
|
1290
1281
|
}
|
|
1291
1282
|
function buildImmediateResult(operation, data, raw) {
|
|
1292
1283
|
const output = [];
|
|
@@ -1375,7 +1366,6 @@ async function sunoTasksAdapter(input) {
|
|
|
1375
1366
|
if (!taskId) return buildImmediateResult(operation, data, raw);
|
|
1376
1367
|
return pollSunoTask(input, operation, taskId, asInteger(input.parameters.poll_interval, DEFAULT_POLL_INTERVAL_SEC), asInteger(input.parameters.max_wait, DEFAULT_MAX_WAIT_SEC));
|
|
1377
1368
|
}
|
|
1378
|
-
|
|
1379
1369
|
//#endregion
|
|
1380
1370
|
//#region src/adapters/index.ts
|
|
1381
1371
|
const builtinGenerationAdapters = {
|
|
@@ -1391,19 +1381,18 @@ function getGenerationAdapter(type, adapters = {}) {
|
|
|
1391
1381
|
if (!adapter) throw new GenerationUnsupportedAdapterError(type);
|
|
1392
1382
|
return adapter;
|
|
1393
1383
|
}
|
|
1394
|
-
|
|
1395
1384
|
//#endregion
|
|
1396
1385
|
//#region src/config.ts
|
|
1397
|
-
const DECLARATION_EXTENSIONS = new Set([
|
|
1386
|
+
const DECLARATION_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
1398
1387
|
".yaml",
|
|
1399
1388
|
".yml",
|
|
1400
1389
|
".json"
|
|
1401
1390
|
]);
|
|
1402
|
-
function isRecord(value) {
|
|
1391
|
+
function isRecord$1(value) {
|
|
1403
1392
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1404
1393
|
}
|
|
1405
1394
|
function isParameterSpec(value) {
|
|
1406
|
-
if (!isRecord(value)) return false;
|
|
1395
|
+
if (!isRecord$1(value)) return false;
|
|
1407
1396
|
return [
|
|
1408
1397
|
"string",
|
|
1409
1398
|
"number",
|
|
@@ -1412,25 +1401,25 @@ function isParameterSpec(value) {
|
|
|
1412
1401
|
].includes(String(value.type));
|
|
1413
1402
|
}
|
|
1414
1403
|
function isMetaFieldSpec(value) {
|
|
1415
|
-
if (!isRecord(value)) return false;
|
|
1404
|
+
if (!isRecord$1(value)) return false;
|
|
1416
1405
|
return isParameterSpec(value) || String(value.type) === "object";
|
|
1417
1406
|
}
|
|
1418
1407
|
function isMetaTaskVariantSpec(value) {
|
|
1419
|
-
if (!isRecord(value)) return false;
|
|
1408
|
+
if (!isRecord$1(value)) return false;
|
|
1420
1409
|
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");
|
|
1421
1410
|
}
|
|
1422
1411
|
function isMetaSpec(value) {
|
|
1423
|
-
if (!isRecord(value)) return false;
|
|
1424
|
-
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)));
|
|
1412
|
+
if (!isRecord$1(value)) return false;
|
|
1413
|
+
return (value.fields === void 0 || isRecord$1(value.fields) && Object.values(value.fields).every((field) => isMetaFieldSpec(field))) && (value.taskField === void 0 || typeof value.taskField === "string") && (value.taskVariants === void 0 || isRecord$1(value.taskVariants) && Object.values(value.taskVariants).every((variant) => isMetaTaskVariantSpec(variant)));
|
|
1425
1414
|
}
|
|
1426
1415
|
function isGenerationModelDeclaration(value) {
|
|
1427
|
-
if (!isRecord(value)) return false;
|
|
1416
|
+
if (!isRecord$1(value)) return false;
|
|
1428
1417
|
const adapter = value.adapter;
|
|
1429
1418
|
const content = value.content;
|
|
1430
1419
|
const parameters = value.parameters;
|
|
1431
1420
|
const meta = value.meta;
|
|
1432
1421
|
const examples = value.examples;
|
|
1433
|
-
return value.schema ===
|
|
1422
|
+
return value.schema === "neta.generation.model.v1" && typeof value.model === "string" && value.model.trim().length > 0 && (value.allowUnknownParameters === void 0 || typeof value.allowUnknownParameters === "boolean") && isRecord$1(adapter) && typeof adapter.type === "string" && isRecord$1(content) && Array.isArray(content.input) && (parameters === void 0 || isRecord$1(parameters) && Object.values(parameters).every(isParameterSpec)) && (meta === void 0 || isMetaSpec(meta)) && (examples === void 0 || Array.isArray(examples));
|
|
1434
1423
|
}
|
|
1435
1424
|
function parseGenerationModelDeclaration(rawText, filePath = "model.yaml") {
|
|
1436
1425
|
const parsed = extname(filePath) === ".json" ? JSON.parse(rawText) : parse(rawText);
|
|
@@ -1464,7 +1453,27 @@ async function writeGenerationModelDeclarations(declarations, directory, options
|
|
|
1464
1453
|
const ext = options.format === "json" ? "json" : "yaml";
|
|
1465
1454
|
await Promise.all(declarations.map((declaration) => writeGenerationModelDeclaration(declaration, join(directory, `${slugifyFileName(declaration.model)}.${ext}`), options)));
|
|
1466
1455
|
}
|
|
1467
|
-
|
|
1456
|
+
//#endregion
|
|
1457
|
+
//#region src/response-fields.ts
|
|
1458
|
+
function numberValue(value) {
|
|
1459
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1460
|
+
}
|
|
1461
|
+
function stringValue(value) {
|
|
1462
|
+
return typeof value === "string" && value ? value : void 0;
|
|
1463
|
+
}
|
|
1464
|
+
function isRecord(value) {
|
|
1465
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
1466
|
+
}
|
|
1467
|
+
function extractGenerationResultFields(raw) {
|
|
1468
|
+
if (!isRecord(raw)) return void 0;
|
|
1469
|
+
const usage = isRecord(raw.usage) ? raw.usage : void 0;
|
|
1470
|
+
const fields = {};
|
|
1471
|
+
const requestId = stringValue(raw.request_id);
|
|
1472
|
+
const cost = usage ? numberValue(usage.cost) : void 0;
|
|
1473
|
+
if (requestId !== void 0) fields.requestId = requestId;
|
|
1474
|
+
if (cost !== void 0) fields.cost = cost;
|
|
1475
|
+
return Object.keys(fields).length > 0 ? fields : void 0;
|
|
1476
|
+
}
|
|
1468
1477
|
//#endregion
|
|
1469
1478
|
//#region src/source.ts
|
|
1470
1479
|
const defaultGenerationSourceResolver = (source) => {
|
|
@@ -1473,14 +1482,13 @@ const defaultGenerationSourceResolver = (source) => {
|
|
|
1473
1482
|
case "base64": return `data:${source.mediaType};base64,${source.data}`;
|
|
1474
1483
|
}
|
|
1475
1484
|
};
|
|
1476
|
-
|
|
1477
1485
|
//#endregion
|
|
1478
1486
|
//#region src/client.ts
|
|
1479
1487
|
const DEFAULT_BASE_URL = "https://router.neta.art";
|
|
1480
1488
|
const REDACTED = "[REDACTED]";
|
|
1481
1489
|
const SECRET_DEBUG_KEY_PATTERN = /^(authorization|api[-_]?key|token|thoughtSignature)$/i;
|
|
1482
1490
|
const BASE64_DEBUG_KEY_PATTERN = /^(b64_json|data)$/i;
|
|
1483
|
-
const MEDIA_PAYLOAD_KEYS = new Set([
|
|
1491
|
+
const MEDIA_PAYLOAD_KEYS = /* @__PURE__ */ new Set([
|
|
1484
1492
|
"audio",
|
|
1485
1493
|
"audio_url",
|
|
1486
1494
|
"image",
|
|
@@ -1546,6 +1554,17 @@ function resolveModels(options) {
|
|
|
1546
1554
|
for (const model of models) byModel.set(model.model, cloneJson(model));
|
|
1547
1555
|
return [...byModel.values()].sort((a, b) => a.model.localeCompare(b.model));
|
|
1548
1556
|
}
|
|
1557
|
+
function createResultFieldCaptureFetch(fetchFn, onFields) {
|
|
1558
|
+
return (async (input, init) => {
|
|
1559
|
+
const response = await fetchFn(input, init);
|
|
1560
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
1561
|
+
if (contentType.includes("application/json") || contentType.includes("+json")) try {
|
|
1562
|
+
const fields = extractGenerationResultFields(await response.clone().json());
|
|
1563
|
+
if (fields) onFields(fields);
|
|
1564
|
+
} catch {}
|
|
1565
|
+
return response;
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1549
1568
|
function createGenerationClient(options = {}) {
|
|
1550
1569
|
const models = resolveModels(options);
|
|
1551
1570
|
const byModel = new Map(models.map((declaration) => [declaration.model, declaration]));
|
|
@@ -1558,35 +1577,53 @@ function createGenerationClient(options = {}) {
|
|
|
1558
1577
|
if (!declaration) throw new GenerationConfigError(`Generation model is unavailable: ${model}`);
|
|
1559
1578
|
return declaration;
|
|
1560
1579
|
}
|
|
1580
|
+
function validateRequest(request) {
|
|
1581
|
+
const declaration = requireModel(request.model);
|
|
1582
|
+
validateGenerationContent(declaration, request.content);
|
|
1583
|
+
const parameters = resolveGenerationParameters(declaration, request.parameters);
|
|
1584
|
+
const meta = resolveGenerationMeta(declaration, mergeGenerationMeta({
|
|
1585
|
+
...request.metadata ?? {},
|
|
1586
|
+
...request.meta ?? {}
|
|
1587
|
+
}, request.content), request.content);
|
|
1588
|
+
return {
|
|
1589
|
+
declaration: cloneJson(declaration),
|
|
1590
|
+
request: cloneJson(request),
|
|
1591
|
+
parameters,
|
|
1592
|
+
meta
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
async function runAdapter(request, fetch) {
|
|
1596
|
+
const resolved = validateRequest(request);
|
|
1597
|
+
const apiKey = request.apiKey ?? options.apiKey;
|
|
1598
|
+
if (!apiKey) throw new GenerationConfigError("apiKey is required");
|
|
1599
|
+
return getGenerationAdapter(resolved.declaration.adapter.type, options.adapters)({
|
|
1600
|
+
...resolved,
|
|
1601
|
+
context: {
|
|
1602
|
+
apiKey,
|
|
1603
|
+
baseUrl: request.baseUrl ?? options.baseUrl ?? DEFAULT_BASE_URL,
|
|
1604
|
+
fetch,
|
|
1605
|
+
resolveSource: options.sourceResolver ?? defaultGenerationSourceResolver
|
|
1606
|
+
}
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1561
1609
|
return {
|
|
1562
1610
|
validate(request) {
|
|
1563
|
-
|
|
1564
|
-
validateGenerationContent(declaration, request.content);
|
|
1565
|
-
const parameters = resolveGenerationParameters(declaration, request.parameters);
|
|
1566
|
-
const meta = resolveGenerationMeta(declaration, mergeGenerationMeta({
|
|
1567
|
-
...request.metadata ?? {},
|
|
1568
|
-
...request.meta ?? {}
|
|
1569
|
-
}, request.content), request.content);
|
|
1570
|
-
return {
|
|
1571
|
-
declaration: cloneJson(declaration),
|
|
1572
|
-
request: cloneJson(request),
|
|
1573
|
-
parameters,
|
|
1574
|
-
meta
|
|
1575
|
-
};
|
|
1611
|
+
return validateRequest(request);
|
|
1576
1612
|
},
|
|
1577
1613
|
async generate(request) {
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
}
|
|
1589
|
-
|
|
1614
|
+
return runAdapter(request, adapterFetch);
|
|
1615
|
+
},
|
|
1616
|
+
async generateResult(request) {
|
|
1617
|
+
let capturedFields;
|
|
1618
|
+
return {
|
|
1619
|
+
content: await runAdapter(request, createResultFieldCaptureFetch(adapterFetch, (fields) => {
|
|
1620
|
+
capturedFields = {
|
|
1621
|
+
...capturedFields,
|
|
1622
|
+
...fields
|
|
1623
|
+
};
|
|
1624
|
+
})),
|
|
1625
|
+
...capturedFields ?? {}
|
|
1626
|
+
};
|
|
1590
1627
|
},
|
|
1591
1628
|
listModels() {
|
|
1592
1629
|
return cloneJson(models);
|
|
@@ -1625,7 +1662,6 @@ async function createGenerationClientFromDirectory(directory, options = {}) {
|
|
|
1625
1662
|
async function createGenerationClientFromFile(filePath, options = {}) {
|
|
1626
1663
|
return createGenerationClientFromFiles([filePath], options);
|
|
1627
1664
|
}
|
|
1628
|
-
|
|
1629
1665
|
//#endregion
|
|
1630
1666
|
//#region src/export-config.ts
|
|
1631
1667
|
function stringifyBuiltinModelConfig(model, options = {}) {
|
|
@@ -1641,7 +1677,7 @@ async function exportBuiltinModelConfig(model, filePath) {
|
|
|
1641
1677
|
async function exportBuiltinModelConfigs(directory) {
|
|
1642
1678
|
await writeGenerationModelDeclarations(listBuiltinGenerationModels(), directory);
|
|
1643
1679
|
}
|
|
1644
|
-
|
|
1645
1680
|
//#endregion
|
|
1646
1681
|
export { validateGenerationContent as A, klingVideoGenerationsAdapter as C, mergeTextBlocks as D, mergeGenerationMeta as E, GenerationUnsupportedAdapterError as F, GenerationValidationError as I, GenerationError as M, GenerationProviderError as N, resolveGenerationMeta as O, GenerationTimeoutError as P, openAiImageEditsAdapter as S, arkVideoGenerationsAdapter as T, writeGenerationModelDeclarations as _, createGenerationClientFromDirectory as a, sunoTasksAdapter as b, defaultGenerationSourceResolver as c, parseGenerationModelDeclaration as d, readGenerationModelDeclaration as f, writeGenerationModelDeclaration as g, stringifyGenerationModelDeclaration as h, createGenerationClient as i, GenerationConfigError as j, resolveGenerationParameters 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, geminiGenerateContentAdapter as w, openAiImagesAdapter as x, getGenerationAdapter as y };
|
|
1647
|
-
|
|
1682
|
+
|
|
1683
|
+
//# sourceMappingURL=export-config-BXD4Adwb.js.map
|