@neta-art/generation 0.1.33 → 0.1.35
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 +114 -0
- package/dist/{builtins-jIE_k69Z.d.ts → builtins-BOpYwe7W.d.ts} +41 -3
- package/dist/builtins-BOpYwe7W.d.ts.map +1 -0
- package/dist/{builtins-B2NxMnfx.js → builtins-sILlsNot.js} +63 -2
- package/dist/builtins-sILlsNot.js.map +1 -0
- package/dist/builtins.d.ts +1 -1
- package/dist/builtins.js +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/{export-config-CEA_GJEG.js → export-config-BTPXT_zu.js} +96 -5
- package/dist/export-config-BTPXT_zu.js.map +1 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/models/jev-1.13.0.yaml +25 -0
- package/models/jev-latest.yaml +25 -0
- package/models/openai-gpt-6-luna-decisions.yaml +24 -0
- package/package.json +5 -1
- package/dist/builtins-B2NxMnfx.js.map +0 -1
- package/dist/builtins-jIE_k69Z.d.ts.map +0 -1
- package/dist/export-config-CEA_GJEG.js.map +0 -1
|
@@ -1,4 +1,6 @@
|
|
|
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-sILlsNot.js";
|
|
2
|
+
import { HTTPClient, OpenRouter } from "@openrouter/sdk";
|
|
3
|
+
import { TypeSafeClient } from "@typesafe-ai/sdk";
|
|
2
4
|
import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
3
5
|
import { extname, join } from "node:path";
|
|
4
6
|
import { parse, stringify } from "yaml";
|
|
@@ -146,7 +148,11 @@ async function emitDebugResponse(debug, url, response, startedAt) {
|
|
|
146
148
|
function createDebugFetch(fetchFn, debug) {
|
|
147
149
|
return (async (input, init) => {
|
|
148
150
|
const url = String(input instanceof Request ? input.url : input);
|
|
149
|
-
const startedAt = emitDebugRequest(debug, url, init ?? (input instanceof Request ?
|
|
151
|
+
const startedAt = emitDebugRequest(debug, url, init ?? (input instanceof Request ? {
|
|
152
|
+
method: input.method,
|
|
153
|
+
headers: input.headers,
|
|
154
|
+
body: input.body ? await input.clone().text() : null
|
|
155
|
+
} : {}));
|
|
150
156
|
const response = await fetchFn(input, init);
|
|
151
157
|
await emitDebugResponse(debug, url, response, startedAt);
|
|
152
158
|
return response;
|
|
@@ -2351,6 +2357,11 @@ function isMetaTaskVariantSpec(value) {
|
|
|
2351
2357
|
if (!isRecord(value)) return false;
|
|
2352
2358
|
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");
|
|
2353
2359
|
}
|
|
2360
|
+
function isDecisionExample(value, modelRequired) {
|
|
2361
|
+
if (!isRecord(value) || !isRecord(value.request)) return false;
|
|
2362
|
+
const model = value.request.model;
|
|
2363
|
+
return (value.title === void 0 || typeof value.title === "string") && (typeof model === "string" || !modelRequired && model === void 0) && "state" in value.request && isRecord(value.request.questions);
|
|
2364
|
+
}
|
|
2354
2365
|
function isGenerationModelCategory(value) {
|
|
2355
2366
|
return typeof value === "string" && GENERATION_MODEL_CATEGORIES.includes(value);
|
|
2356
2367
|
}
|
|
@@ -2378,7 +2389,9 @@ function isGenerationModelDeclaration(value) {
|
|
|
2378
2389
|
const parameters = value.parameters;
|
|
2379
2390
|
const meta = value.meta;
|
|
2380
2391
|
const examples = value.examples;
|
|
2381
|
-
|
|
2392
|
+
const systemOneExamples = value.systemOneExamples;
|
|
2393
|
+
const decisionsExamples = value.decisionsExamples;
|
|
2394
|
+
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)) && (systemOneExamples === void 0 || Array.isArray(systemOneExamples) && systemOneExamples.every((example) => isDecisionExample(example, false))) && (decisionsExamples === void 0 || Array.isArray(decisionsExamples) && decisionsExamples.every((example) => isDecisionExample(example, true)));
|
|
2382
2395
|
}
|
|
2383
2396
|
function parseGenerationModelDeclaration(rawText, filePath = "model.yaml") {
|
|
2384
2397
|
const parsed = extname(filePath) === ".json" ? JSON.parse(rawText) : parse(rawText);
|
|
@@ -2503,10 +2516,24 @@ function createResultFieldCaptureFetch(fetchFn, onFields) {
|
|
|
2503
2516
|
if (contentType.includes("application/json") || contentType.includes("+json")) try {
|
|
2504
2517
|
fields = extractGenerationResultFields(await response.clone().json());
|
|
2505
2518
|
} catch {}
|
|
2506
|
-
|
|
2519
|
+
onFields(fields, headerFields);
|
|
2507
2520
|
return response;
|
|
2508
2521
|
});
|
|
2509
2522
|
}
|
|
2523
|
+
const DECISION_ENTRY_POINTS = new Map([["typesafe.systemOne", "systemOne()"], ["openrouter.decisions", "decisions()"]]);
|
|
2524
|
+
function createDecisionMetadataCapture(fetchFn) {
|
|
2525
|
+
let captured = {};
|
|
2526
|
+
return {
|
|
2527
|
+
fetch: createResultFieldCaptureFetch(fetchFn, (fields, headerFields) => {
|
|
2528
|
+
const requestId = fields?.requestId ?? headerFields?.requestId ?? headerFields?.oneApiRequestId;
|
|
2529
|
+
captured = {
|
|
2530
|
+
...fields,
|
|
2531
|
+
...requestId ? { requestId } : {}
|
|
2532
|
+
};
|
|
2533
|
+
}),
|
|
2534
|
+
fields: () => captured
|
|
2535
|
+
};
|
|
2536
|
+
}
|
|
2510
2537
|
function createGenerationClient(options = {}) {
|
|
2511
2538
|
const models = resolveModels(options);
|
|
2512
2539
|
const byModel = new Map(models.map((declaration) => [declaration.model, declaration]));
|
|
@@ -2514,6 +2541,21 @@ function createGenerationClient(options = {}) {
|
|
|
2514
2541
|
if (!fetchFn) throw new GenerationConfigError("A fetch implementation is required");
|
|
2515
2542
|
const debug = resolveDebugConfig(options.debug);
|
|
2516
2543
|
const adapterFetch = debug ? createDebugFetch(fetchFn, debug) : fetchFn;
|
|
2544
|
+
const systemOneConfig = {
|
|
2545
|
+
...options.systemOne,
|
|
2546
|
+
baseURL: options.systemOne?.baseURL ?? joinUrl(options.baseUrl ?? DEFAULT_BASE_URL, "typesafe"),
|
|
2547
|
+
defaultModel: options.systemOne?.defaultModel ?? "jev-latest"
|
|
2548
|
+
};
|
|
2549
|
+
let systemOneClient;
|
|
2550
|
+
const { serverURL: configuredServerURL,...decisionsConfig } = options.decisions ?? {};
|
|
2551
|
+
const decisionsServerURL = configuredServerURL || joinUrl(options.baseUrl ?? DEFAULT_BASE_URL, "openrouter");
|
|
2552
|
+
let decisionsClient;
|
|
2553
|
+
function decisionsCallOptions(requestOptions) {
|
|
2554
|
+
return {
|
|
2555
|
+
...requestOptions,
|
|
2556
|
+
serverURL: requestOptions?.serverURL || decisionsServerURL
|
|
2557
|
+
};
|
|
2558
|
+
}
|
|
2517
2559
|
function requireModel(model) {
|
|
2518
2560
|
const declaration = byModel.get(model);
|
|
2519
2561
|
if (!declaration) throw new GenerationConfigError(`Generation model is unavailable: ${model}`);
|
|
@@ -2521,6 +2563,8 @@ function createGenerationClient(options = {}) {
|
|
|
2521
2563
|
}
|
|
2522
2564
|
function validateRequest(request) {
|
|
2523
2565
|
const declaration = requireModel(request.model);
|
|
2566
|
+
const entryPoint = DECISION_ENTRY_POINTS.get(declaration.adapter.type);
|
|
2567
|
+
if (entryPoint) throw new GenerationConfigError(`Model ${request.model} requires ${entryPoint} with state and questions`);
|
|
2524
2568
|
validateGenerationContent(declaration, request.content);
|
|
2525
2569
|
const parameters = resolveGenerationParameters(declaration, request.parameters);
|
|
2526
2570
|
const meta = resolveGenerationMeta(declaration, mergeGenerationMeta({
|
|
@@ -2553,7 +2597,54 @@ function createGenerationClient(options = {}) {
|
|
|
2553
2597
|
}
|
|
2554
2598
|
});
|
|
2555
2599
|
}
|
|
2600
|
+
function requireDecisionModel(model, entryPoint) {
|
|
2601
|
+
const declaration = requireModel(model);
|
|
2602
|
+
if (DECISION_ENTRY_POINTS.get(declaration.adapter.type) !== entryPoint) throw new GenerationConfigError(`Model does not support ${entryPoint}: ${declaration.model}`);
|
|
2603
|
+
}
|
|
2604
|
+
function createSystemOneClient(fetch) {
|
|
2605
|
+
if (!options.apiKey) throw new GenerationConfigError("apiKey is required");
|
|
2606
|
+
return new TypeSafeClient({
|
|
2607
|
+
...systemOneConfig,
|
|
2608
|
+
apiKey: options.apiKey,
|
|
2609
|
+
fetch
|
|
2610
|
+
});
|
|
2611
|
+
}
|
|
2612
|
+
function createDecisionsClient(fetch) {
|
|
2613
|
+
if (!options.apiKey) throw new GenerationConfigError("apiKey is required");
|
|
2614
|
+
return new OpenRouter({
|
|
2615
|
+
...decisionsConfig,
|
|
2616
|
+
retryConfig: decisionsConfig.retryConfig ?? { strategy: "none" },
|
|
2617
|
+
apiKey: options.apiKey,
|
|
2618
|
+
httpClient: new HTTPClient({ fetcher: fetch })
|
|
2619
|
+
});
|
|
2620
|
+
}
|
|
2556
2621
|
return {
|
|
2622
|
+
systemOne(request, requestOptions) {
|
|
2623
|
+
requireDecisionModel(request.model ?? systemOneConfig.defaultModel, "systemOne()");
|
|
2624
|
+
systemOneClient ??= createSystemOneClient(adapterFetch);
|
|
2625
|
+
return systemOneClient.systemOne(request, requestOptions);
|
|
2626
|
+
},
|
|
2627
|
+
async systemOneResult(request, requestOptions) {
|
|
2628
|
+
requireDecisionModel(request.model ?? systemOneConfig.defaultModel, "systemOne()");
|
|
2629
|
+
const capture = createDecisionMetadataCapture(adapterFetch);
|
|
2630
|
+
return {
|
|
2631
|
+
result: await createSystemOneClient(capture.fetch).systemOne(request, requestOptions),
|
|
2632
|
+
...capture.fields()
|
|
2633
|
+
};
|
|
2634
|
+
},
|
|
2635
|
+
async decisions(request, requestOptions) {
|
|
2636
|
+
requireDecisionModel(request.decisionsRequest.model, "decisions()");
|
|
2637
|
+
decisionsClient ??= createDecisionsClient(adapterFetch);
|
|
2638
|
+
return decisionsClient.alpha.decisions.create(request, decisionsCallOptions(requestOptions));
|
|
2639
|
+
},
|
|
2640
|
+
async decisionsResult(request, requestOptions) {
|
|
2641
|
+
requireDecisionModel(request.decisionsRequest.model, "decisions()");
|
|
2642
|
+
const capture = createDecisionMetadataCapture(adapterFetch);
|
|
2643
|
+
return {
|
|
2644
|
+
result: await createDecisionsClient(capture.fetch).alpha.decisions.create(request, decisionsCallOptions(requestOptions)),
|
|
2645
|
+
...capture.fields()
|
|
2646
|
+
};
|
|
2647
|
+
},
|
|
2557
2648
|
validate(request) {
|
|
2558
2649
|
return validateRequest(request);
|
|
2559
2650
|
},
|
|
@@ -2639,4 +2730,4 @@ async function exportBuiltinModelConfigs(directory) {
|
|
|
2639
2730
|
|
|
2640
2731
|
//#endregion
|
|
2641
2732
|
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 };
|
|
2642
|
-
//# sourceMappingURL=export-config-
|
|
2733
|
+
//# sourceMappingURL=export-config-BTPXT_zu.js.map
|