@neta-art/generation 0.1.1 → 0.1.3
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 +69 -0
- package/dist/{builtins-BuI-rf8X.d.ts → builtins-BJ2_TVlr.d.ts} +54 -3
- package/dist/builtins-BJ2_TVlr.d.ts.map +1 -0
- package/dist/{builtins-B1AheaEa.js → builtins-FumzmWvj.js} +248 -1
- package/dist/builtins-FumzmWvj.js.map +1 -0
- package/dist/builtins.d.ts +1 -1
- package/dist/builtins.js +1 -1
- package/dist/cli/index.js +84 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/export-config-D8By2_r7.js +1263 -0
- package/dist/export-config-D8By2_r7.js.map +1 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -655
- package/models/suno_music.yaml +265 -0
- package/package.json +15 -16
- package/dist/builtins-B1AheaEa.js.map +0 -1
- package/dist/builtins-BuI-rf8X.d.ts.map +0 -1
- package/dist/export-config-Bwqnn7Vs.js +0 -128
- package/dist/export-config-Bwqnn7Vs.js.map +0 -1
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -60,12 +60,49 @@ pnpm example:image-editing
|
|
|
60
60
|
pnpm example:text-to-video
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
+
You can also call providers through the CLI:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
node --env-file=.env ./dist/cli/index.js generate gemini-3.1-flash-image-preview \
|
|
67
|
+
--prompt "a simple abstract geometric app icon" \
|
|
68
|
+
--param aspect_ratio=1:1 \
|
|
69
|
+
--param image_size=512 \
|
|
70
|
+
--debug
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Use `--image-url` for reference images, `--out` to write base64 outputs to files, and `json:` for non-string parameter values, for example `--param duration=json:5`.
|
|
74
|
+
|
|
75
|
+
## Debug provider requests
|
|
76
|
+
|
|
77
|
+
Pass `debug: true` to print the final provider request and response metadata to stderr. Sensitive fields such as `Authorization` and base64 image data are redacted by default.
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
const client = createGenerationClient({
|
|
81
|
+
apiKey: process.env.NETA_ROUTER_API_KEY!,
|
|
82
|
+
debug: true,
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
For a custom logger or full unredacted payloads:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
const client = createGenerationClient({
|
|
90
|
+
apiKey: process.env.NETA_ROUTER_API_KEY!,
|
|
91
|
+
debug: {
|
|
92
|
+
enabled: true,
|
|
93
|
+
includeSensitive: true,
|
|
94
|
+
logger: (event) => console.error(JSON.stringify(event, null, 2)),
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
63
99
|
## Built-in models
|
|
64
100
|
|
|
65
101
|
- `gpt-image-2`
|
|
66
102
|
- `gemini-3.1-flash-image-preview`
|
|
67
103
|
- `seedance-2-0`
|
|
68
104
|
- `seedance-2-0-fast`
|
|
105
|
+
- `suno_music`
|
|
69
106
|
|
|
70
107
|
Built-in model declarations share the same client-level `apiKey` and `baseUrl`.
|
|
71
108
|
|
|
@@ -114,6 +151,37 @@ await client.generate({
|
|
|
114
151
|
});
|
|
115
152
|
```
|
|
116
153
|
|
|
154
|
+
## Music generation
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
const output = await client.generate({
|
|
158
|
+
model: "suno_music",
|
|
159
|
+
content: [
|
|
160
|
+
{ type: "text", text: "uplifting cinematic pop with warm piano and clear chorus" },
|
|
161
|
+
],
|
|
162
|
+
parameters: {
|
|
163
|
+
operation: "music",
|
|
164
|
+
},
|
|
165
|
+
meta: {
|
|
166
|
+
mv: "chirp-v5-5",
|
|
167
|
+
title: "Warm Horizon",
|
|
168
|
+
tags: "cinematic pop, warm piano",
|
|
169
|
+
make_instrumental: false,
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
console.log(output);
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Suno uses one public model, `suno_music`. SDK-level parameters control execution:
|
|
177
|
+
|
|
178
|
+
- `music`
|
|
179
|
+
- `lyrics`
|
|
180
|
+
|
|
181
|
+
Provider-specific Suno fields belong in `meta`, not `parameters`. The adapter passes `meta` through to Suno and defaults
|
|
182
|
+
`meta.mv` to `chirp-v5-5` for music requests. Use `meta.task` for Yunwu-style integrated tasks such as `sound`, `cover`,
|
|
183
|
+
`image_to_song`, `video_to_song`, `remaster`, `underpainting`, or `mashup_condition`.
|
|
184
|
+
|
|
117
185
|
## Load model declarations from files
|
|
118
186
|
|
|
119
187
|
```ts
|
|
@@ -193,6 +261,7 @@ Built-in adapters:
|
|
|
193
261
|
- `openai.images`
|
|
194
262
|
- `gemini.generateContent`
|
|
195
263
|
- `ark.videoGenerations`
|
|
264
|
+
- `suno.tasks`
|
|
196
265
|
|
|
197
266
|
You can register custom adapters:
|
|
198
267
|
|
|
@@ -66,11 +66,28 @@ type GenerationParameterSpec = {
|
|
|
66
66
|
description?: string;
|
|
67
67
|
examples?: boolean[];
|
|
68
68
|
};
|
|
69
|
+
type GenerationMetaFieldSpec = GenerationParameterSpec | {
|
|
70
|
+
type: "object";
|
|
71
|
+
optional?: boolean;
|
|
72
|
+
description?: string;
|
|
73
|
+
};
|
|
74
|
+
type GenerationMetaTaskVariantSpec = {
|
|
75
|
+
description?: string;
|
|
76
|
+
required?: string[];
|
|
77
|
+
requiredContent?: Array<GenerationContentSpec["type"]>;
|
|
78
|
+
sendTask?: boolean;
|
|
79
|
+
};
|
|
80
|
+
type GenerationMetaSpec = {
|
|
81
|
+
fields?: Record<string, GenerationMetaFieldSpec>;
|
|
82
|
+
taskField?: string;
|
|
83
|
+
taskVariants?: Record<string, GenerationMetaTaskVariantSpec>;
|
|
84
|
+
};
|
|
69
85
|
type GenerationModelDeclaration = {
|
|
70
86
|
schema: typeof MODEL_SCHEMA;
|
|
71
87
|
model: string;
|
|
72
88
|
title?: string;
|
|
73
89
|
description?: string;
|
|
90
|
+
allowUnknownParameters?: boolean;
|
|
74
91
|
adapter: {
|
|
75
92
|
type: string;
|
|
76
93
|
};
|
|
@@ -78,6 +95,7 @@ type GenerationModelDeclaration = {
|
|
|
78
95
|
input: GenerationContentSpec[];
|
|
79
96
|
};
|
|
80
97
|
parameters?: Record<string, GenerationParameterSpec>;
|
|
98
|
+
meta?: GenerationMetaSpec;
|
|
81
99
|
examples?: Array<{
|
|
82
100
|
title?: string;
|
|
83
101
|
request: GenerateRequest;
|
|
@@ -87,16 +105,48 @@ type GenerateRequest = {
|
|
|
87
105
|
model: string;
|
|
88
106
|
content: GenerationContentBlock[];
|
|
89
107
|
parameters?: Record<string, unknown>;
|
|
108
|
+
meta?: Record<string, unknown>;
|
|
109
|
+
/** @deprecated Use meta. */
|
|
110
|
+
metadata?: Record<string, unknown>;
|
|
90
111
|
apiKey?: string;
|
|
91
112
|
baseUrl?: string;
|
|
92
|
-
metadata?: Record<string, unknown>;
|
|
93
113
|
};
|
|
94
114
|
type ResolvedGenerationRequest = {
|
|
95
115
|
declaration: GenerationModelDeclaration;
|
|
96
116
|
request: GenerateRequest;
|
|
97
117
|
parameters: Record<string, unknown>;
|
|
118
|
+
meta: Record<string, unknown>;
|
|
98
119
|
};
|
|
99
120
|
type GenerationSourceResolver = (source: GenerationSource) => Promise<string> | string;
|
|
121
|
+
type GenerationDebugEvent = {
|
|
122
|
+
type: "request";
|
|
123
|
+
url: string;
|
|
124
|
+
method: string;
|
|
125
|
+
headers: Record<string, string>;
|
|
126
|
+
body?: unknown;
|
|
127
|
+
} | {
|
|
128
|
+
type: "response";
|
|
129
|
+
url: string;
|
|
130
|
+
status: number;
|
|
131
|
+
statusText: string;
|
|
132
|
+
headers: Record<string, string>;
|
|
133
|
+
trace: Record<string, string>;
|
|
134
|
+
elapsedMs: number;
|
|
135
|
+
body?: unknown;
|
|
136
|
+
};
|
|
137
|
+
type GenerationDebugLogger = (event: GenerationDebugEvent) => void;
|
|
138
|
+
type GenerationDebugOptions = {
|
|
139
|
+
enabled?: boolean;
|
|
140
|
+
includeSensitive?: boolean;
|
|
141
|
+
includeResponseBody?: boolean;
|
|
142
|
+
logger?: GenerationDebugLogger;
|
|
143
|
+
};
|
|
144
|
+
type GenerationDebugConfig = GenerationDebugOptions & {
|
|
145
|
+
enabled: boolean;
|
|
146
|
+
includeSensitive: boolean;
|
|
147
|
+
includeResponseBody: boolean;
|
|
148
|
+
logger: GenerationDebugLogger;
|
|
149
|
+
};
|
|
100
150
|
type GenerationAdapterContext = {
|
|
101
151
|
apiKey: string;
|
|
102
152
|
baseUrl: string;
|
|
@@ -115,6 +165,7 @@ type CreateGenerationClientOptions = {
|
|
|
115
165
|
fetch?: typeof fetch;
|
|
116
166
|
sourceResolver?: GenerationSourceResolver;
|
|
117
167
|
adapters?: Record<string, GenerationAdapter>;
|
|
168
|
+
debug?: boolean | GenerationDebugOptions;
|
|
118
169
|
};
|
|
119
170
|
type GenerationClient = {
|
|
120
171
|
generate(request: GenerateRequest): Promise<GenerationContentBlock[]>;
|
|
@@ -133,5 +184,5 @@ declare const builtinGenerationModels: GenerationModelDeclaration[];
|
|
|
133
184
|
declare function getBuiltinGenerationModel(model: string): GenerationModelDeclaration | null;
|
|
134
185
|
declare function listBuiltinGenerationModels(): GenerationModelDeclaration[];
|
|
135
186
|
//#endregion
|
|
136
|
-
export {
|
|
137
|
-
//# sourceMappingURL=builtins-
|
|
187
|
+
export { GenerationSourceResolver as C, GenerationSource as S, ResolvedGenerationRequest as T, GenerationMetaFieldSpec as _, GenerateRequest as a, GenerationModelDeclaration as b, GenerationAdapterInput as c, GenerationContentBlockMeta as d, GenerationContentSpec as f, GenerationDebugOptions as g, GenerationDebugLogger as h, CreateGenerationClientOptions as i, GenerationClient as l, GenerationDebugEvent as m, getBuiltinGenerationModel as n, GenerationAdapter as o, GenerationDebugConfig as p, listBuiltinGenerationModels as r, GenerationAdapterContext as s, builtinGenerationModels as t, GenerationContentBlock as u, GenerationMetaSpec as v, MODEL_SCHEMA as w, GenerationParameterSpec as x, GenerationMetaTaskVariantSpec as y };
|
|
188
|
+
//# sourceMappingURL=builtins-BJ2_TVlr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins-BJ2_TVlr.d.ts","names":[],"sources":["../src/types.ts","../src/builtins.ts"],"sourcesContent":[],"mappings":";cAAa;AAAA,KAED,gBAAA,GAFmD;EAEnD,IAAA,EAAA,KAAA;EAEA,GAAA,EAAA,MAAA;AAEZ,CAAA,GAAY;EAC6B,IAAA,EAAA,QAAA;EACZ,SAAA,EAAA,MAAA;EAAyB,IAAA,EAAA,MAAA;CACzB;AAAyB,KAL1C,0BAAA,GAA6B,MAKa,CAAA,MAAA,EAAA,OAAA,CAAA;AACzB,KAJjB,sBAAA,GAIiB;EAAyB,IAAA,EAAA,MAAA;EAA0B,IAAA,EAAA,MAAA;EAEpE,IAAA,CAAA,EAL6B,0BAKR;CAKf,GAAA;EAAN,IAAA,EAAA,OAAA;EAEH,MAAA,EAXoB,gBAWpB;EAAM,IAAA,CAAA,EAXuC,0BAWvC;AAIf,CAAA,GAAY;EAmCA,IAAA,EAAA,OAAA;EAIA,MAAA,EArDiB,gBAqDjB;EAOA,IAAA,CAAA,EA5D0C,0BA4DxB;CACJ,GAAA;EAAf,IAAA,EAAA,OAAA;EAEqB,MAAA,EA9DH,gBA8DG;EAAf,IAAA,CAAA,EA9DqC,0BA8DrC;CAAM;AAGX,KA/DA,qBAAA,GA+D0B;EACrB,IAAA,EAAA,MAAA,GAAA,OAAA,GAAA,OAAA,GAAA,OAAA;EASN,QAAA,CAAA,EAAA,OAAA;EAEmB,GAAA,CAAA,EAAA,MAAA;EAAf,GAAA,CAAA,EAAA,MAAA;EACN,OAAA,CAAA,EAvEG,KAuEH,CAvES,gBAuET,CAAA,MAAA,CAAA,CAAA;EAGI,KAAA,CAAA,EAAA,SAAA,GAAA,OAAA,GAAA,QAAA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;EAClB,QAAA,CAAA,EAAA,OAAA;CAAkB;AACtB,KA5GJ,kBAAA,GA4GI;EACW,MAAA,CAAA,EA5GhB,MA4GgB,CAAA,MAAA,EA5GD,uBA4GC,CAAA;EAE2B,SAAA,CAAA,EAAA,MAAA;EACb,YAAA,CAAA,EA7GxB,MA6GwB,CAAA,MAAA,EA7GT,6BA6GS,CAAA;CAAO;KA1GpC,0BAAA;iBACK;;EC0UJ,KAAA,CAAA,EAAA,MAAA;EAEG,WAAA,CAAA,EAAA,MAAA;EAIA,sBAAA,CAAA,EAAA,OAA2B;;;;;WDvUhC;;eAEI,eAAe;SACrB;aACI;;aAEA;;;KAID,eAAA;;WAED;eACI;SACN;;aAEI;;;;KAKD,yBAAA;eACG;WACJ;cACG;QACN;;KAGI,wBAAA,YAAoC,qBAAqB;KAEzD,oBAAA;;;;WAKG;;;;;;;WAQA;SACF;;;;KAKD,qBAAA,WAAgC;KAEhC,sBAAA;;;;WAID;;KAGC,qBAAA,GAAwB;;;;UAI1B;;KAGE,wBAAA;;;gBAGI;iBACC;;KAGL,sBAAA,GAAyB;WAC1B;;KAGC,iBAAA,WAA4B,2BAA2B,QAAQ;KAE/D,6BAAA;;;WAGD;;iBAEM;mBACE;aACN,eAAe;oBACR;;KAGR,gBAAA;oBACQ,kBAAkB,QAAQ;oBAC1B,kBAAkB;gBACtB;2BACW;;;;sDAE2B;yCACb;;;;AArL5B,cCsZA,uBDtZkD,ECsZzB,0BDtZyB,EAAA;AAEnD,iBCsZI,yBAAA,CDtZY,KAAA,EAAA,MAAA,CAAA,ECsZ8B,0BDtZ9B,GAAA,IAAA;AAEhB,iBCwZI,2BAAA,CAAA,CDxZ+B,ECwZA,0BDxZA,EAAA"}
|
|
@@ -146,6 +146,116 @@ function videoParameters(defaults) {
|
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
+
const sunoContinuationTaskVariant = { required: [
|
|
150
|
+
"task_id",
|
|
151
|
+
"clip_id",
|
|
152
|
+
"continue_clip_id"
|
|
153
|
+
] };
|
|
154
|
+
const sunoMeta = {
|
|
155
|
+
taskField: "task",
|
|
156
|
+
fields: {
|
|
157
|
+
task: {
|
|
158
|
+
type: "string",
|
|
159
|
+
optional: true,
|
|
160
|
+
enum: [
|
|
161
|
+
"extend",
|
|
162
|
+
"upload_extend",
|
|
163
|
+
"infill",
|
|
164
|
+
"fixed_infill",
|
|
165
|
+
"infill_intro",
|
|
166
|
+
"infill_outro",
|
|
167
|
+
"cover_infill",
|
|
168
|
+
"cover_extend",
|
|
169
|
+
"artist_infill",
|
|
170
|
+
"artist_consistency",
|
|
171
|
+
"cover",
|
|
172
|
+
"image_to_song",
|
|
173
|
+
"video_to_song",
|
|
174
|
+
"concat",
|
|
175
|
+
"sound",
|
|
176
|
+
"underpainting",
|
|
177
|
+
"remaster",
|
|
178
|
+
"vox",
|
|
179
|
+
"mashup_condition"
|
|
180
|
+
],
|
|
181
|
+
description: "Integrated Suno music task for operation=music."
|
|
182
|
+
},
|
|
183
|
+
mv: {
|
|
184
|
+
type: "string",
|
|
185
|
+
optional: true,
|
|
186
|
+
description: "Suno music model version."
|
|
187
|
+
},
|
|
188
|
+
task_id: {
|
|
189
|
+
type: "string",
|
|
190
|
+
optional: true,
|
|
191
|
+
description: "Existing Suno task id used for continuation-style tasks."
|
|
192
|
+
},
|
|
193
|
+
clip_id: {
|
|
194
|
+
type: "string",
|
|
195
|
+
optional: true,
|
|
196
|
+
description: "Existing Suno clip id used for continuation-style tasks."
|
|
197
|
+
},
|
|
198
|
+
continue_clip_id: {
|
|
199
|
+
type: "string",
|
|
200
|
+
optional: true,
|
|
201
|
+
description: "Clip id to continue from."
|
|
202
|
+
},
|
|
203
|
+
continue_at: {
|
|
204
|
+
type: "number",
|
|
205
|
+
optional: true,
|
|
206
|
+
description: "Continue position in seconds."
|
|
207
|
+
},
|
|
208
|
+
model_name: {
|
|
209
|
+
type: "string",
|
|
210
|
+
optional: true,
|
|
211
|
+
description: "Suno model name used by remaster."
|
|
212
|
+
},
|
|
213
|
+
variation_category: {
|
|
214
|
+
type: "string",
|
|
215
|
+
optional: true,
|
|
216
|
+
description: "Remaster variation category."
|
|
217
|
+
},
|
|
218
|
+
metadata_params: {
|
|
219
|
+
type: "object",
|
|
220
|
+
optional: true,
|
|
221
|
+
description: "Yunwu/Suno task-specific metadata payload."
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
taskVariants: {
|
|
225
|
+
extend: sunoContinuationTaskVariant,
|
|
226
|
+
upload_extend: sunoContinuationTaskVariant,
|
|
227
|
+
infill: sunoContinuationTaskVariant,
|
|
228
|
+
fixed_infill: sunoContinuationTaskVariant,
|
|
229
|
+
infill_intro: sunoContinuationTaskVariant,
|
|
230
|
+
infill_outro: sunoContinuationTaskVariant,
|
|
231
|
+
cover_infill: sunoContinuationTaskVariant,
|
|
232
|
+
cover_extend: sunoContinuationTaskVariant,
|
|
233
|
+
artist_infill: sunoContinuationTaskVariant,
|
|
234
|
+
artist_consistency: sunoContinuationTaskVariant,
|
|
235
|
+
cover: sunoContinuationTaskVariant,
|
|
236
|
+
image_to_song: {
|
|
237
|
+
requiredContent: ["image"],
|
|
238
|
+
required: ["metadata_params"]
|
|
239
|
+
},
|
|
240
|
+
video_to_song: {
|
|
241
|
+
requiredContent: ["video"],
|
|
242
|
+
required: ["metadata_params"]
|
|
243
|
+
},
|
|
244
|
+
concat: sunoContinuationTaskVariant,
|
|
245
|
+
sound: { required: ["metadata_params"] },
|
|
246
|
+
underpainting: { required: ["metadata_params"] },
|
|
247
|
+
remaster: {
|
|
248
|
+
sendTask: false,
|
|
249
|
+
required: [
|
|
250
|
+
"clip_id",
|
|
251
|
+
"model_name",
|
|
252
|
+
"variation_category"
|
|
253
|
+
]
|
|
254
|
+
},
|
|
255
|
+
vox: sunoContinuationTaskVariant,
|
|
256
|
+
mashup_condition: sunoContinuationTaskVariant
|
|
257
|
+
}
|
|
258
|
+
};
|
|
149
259
|
const builtinModels = [
|
|
150
260
|
{
|
|
151
261
|
schema: MODEL_SCHEMA,
|
|
@@ -303,6 +413,143 @@ const builtinModels = [
|
|
|
303
413
|
resolution: "720p",
|
|
304
414
|
maxWait: 600
|
|
305
415
|
})
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
schema: MODEL_SCHEMA,
|
|
419
|
+
model: "suno_music",
|
|
420
|
+
title: "Suno Music",
|
|
421
|
+
description: "Suno music model for songs, lyrics, sound effects, and integrated music tasks.",
|
|
422
|
+
adapter: { type: "suno.tasks" },
|
|
423
|
+
content: { input: [
|
|
424
|
+
{
|
|
425
|
+
type: "text",
|
|
426
|
+
required: false,
|
|
427
|
+
max: 16,
|
|
428
|
+
merge: "newline",
|
|
429
|
+
description: "Optional prompt text. The adapter maps merged text to the operation's text field when that field is not provided."
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
type: "audio",
|
|
433
|
+
required: false,
|
|
434
|
+
max: 1,
|
|
435
|
+
sources: ["url", "base64"],
|
|
436
|
+
description: "Optional reference audio. The adapter maps it to url when url is not provided."
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
type: "image",
|
|
440
|
+
required: false,
|
|
441
|
+
max: 1,
|
|
442
|
+
sources: ["url", "base64"],
|
|
443
|
+
description: "Optional image source. The adapter maps it to image_url when image_url is not provided."
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
type: "video",
|
|
447
|
+
required: false,
|
|
448
|
+
max: 1,
|
|
449
|
+
sources: ["url", "base64"],
|
|
450
|
+
description: "Optional video source. The adapter maps it to video_url when video_url is not provided."
|
|
451
|
+
}
|
|
452
|
+
] },
|
|
453
|
+
parameters: {
|
|
454
|
+
operation: {
|
|
455
|
+
type: "string",
|
|
456
|
+
optional: true,
|
|
457
|
+
default: "music",
|
|
458
|
+
enum: ["music", "lyrics"],
|
|
459
|
+
description: "Stable Suno endpoint operation. Provider-specific fields such as task, mv, title, tags, metadataParams, and clip_id belong in request meta."
|
|
460
|
+
},
|
|
461
|
+
poll_interval: {
|
|
462
|
+
type: "integer",
|
|
463
|
+
optional: true,
|
|
464
|
+
default: 5,
|
|
465
|
+
min: 1,
|
|
466
|
+
max: 60,
|
|
467
|
+
description: "Seconds between task status checks."
|
|
468
|
+
},
|
|
469
|
+
max_wait: {
|
|
470
|
+
type: "integer",
|
|
471
|
+
optional: true,
|
|
472
|
+
default: 600,
|
|
473
|
+
min: 30,
|
|
474
|
+
max: 3600,
|
|
475
|
+
description: "Maximum seconds to wait for task completion."
|
|
476
|
+
}
|
|
477
|
+
},
|
|
478
|
+
meta: sunoMeta,
|
|
479
|
+
examples: [
|
|
480
|
+
{
|
|
481
|
+
title: "Music generation",
|
|
482
|
+
request: {
|
|
483
|
+
model: "suno_music",
|
|
484
|
+
content: [{
|
|
485
|
+
type: "text",
|
|
486
|
+
text: "uplifting cinematic pop with warm piano and clear chorus"
|
|
487
|
+
}],
|
|
488
|
+
parameters: { operation: "music" },
|
|
489
|
+
meta: {
|
|
490
|
+
mv: "chirp-v5-5",
|
|
491
|
+
title: "Warm Horizon",
|
|
492
|
+
tags: "cinematic pop, warm piano",
|
|
493
|
+
make_instrumental: false
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
title: "Lyrics",
|
|
499
|
+
request: {
|
|
500
|
+
model: "suno_music",
|
|
501
|
+
content: [{
|
|
502
|
+
type: "text",
|
|
503
|
+
text: "write a hopeful chorus about sunrise after a storm"
|
|
504
|
+
}],
|
|
505
|
+
parameters: { operation: "lyrics" }
|
|
506
|
+
}
|
|
507
|
+
},
|
|
508
|
+
{
|
|
509
|
+
title: "Sound effect",
|
|
510
|
+
request: {
|
|
511
|
+
model: "suno_music",
|
|
512
|
+
content: [{
|
|
513
|
+
type: "text",
|
|
514
|
+
text: "ambient music with gentle rain and distant thunder"
|
|
515
|
+
}],
|
|
516
|
+
parameters: { operation: "music" },
|
|
517
|
+
meta: {
|
|
518
|
+
task: "sound",
|
|
519
|
+
mv: "chirp-v5-5",
|
|
520
|
+
metadata_params: { sound: "gentle rain ambience with distant thunder" },
|
|
521
|
+
title: "Gentle Rain",
|
|
522
|
+
tags: "ambient, rain, cinematic",
|
|
523
|
+
make_instrumental: true
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
title: "Image to song",
|
|
529
|
+
request: {
|
|
530
|
+
model: "suno_music",
|
|
531
|
+
content: [{
|
|
532
|
+
type: "text",
|
|
533
|
+
text: "turn this image into a short hopeful pop song"
|
|
534
|
+
}, {
|
|
535
|
+
type: "image",
|
|
536
|
+
source: {
|
|
537
|
+
type: "url",
|
|
538
|
+
url: "https://picsum.photos/512/512"
|
|
539
|
+
}
|
|
540
|
+
}],
|
|
541
|
+
parameters: { operation: "music" },
|
|
542
|
+
meta: {
|
|
543
|
+
task: "image_to_song",
|
|
544
|
+
mv: "chirp-v5-5",
|
|
545
|
+
metadata_params: {
|
|
546
|
+
image_url: "https://picsum.photos/512/512",
|
|
547
|
+
prompt: "turn this image into a short hopeful pop song"
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
]
|
|
306
553
|
}
|
|
307
554
|
];
|
|
308
555
|
const builtinGenerationModels = cloneJson(builtinModels);
|
|
@@ -315,4 +562,4 @@ function listBuiltinGenerationModels() {
|
|
|
315
562
|
|
|
316
563
|
//#endregion
|
|
317
564
|
export { compactArray as a, slugifyFileName as c, cloneJson as i, MODEL_SCHEMA as l, getBuiltinGenerationModel as n, compactObject as o, listBuiltinGenerationModels as r, getBlockMeta as s, builtinGenerationModels as t };
|
|
318
|
-
//# sourceMappingURL=builtins-
|
|
565
|
+
//# sourceMappingURL=builtins-FumzmWvj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtins-FumzmWvj.js","names":["builtinGenerationModels: GenerationModelDeclaration[]"],"sources":["../src/types.ts","../src/utils.ts","../src/builtins.ts"],"sourcesContent":["export const MODEL_SCHEMA = \"neta.generation.model.v1\" as const;\n\nexport type GenerationSource = { type: \"url\"; url: string } | { type: \"base64\"; mediaType: string; data: string };\n\nexport type GenerationContentBlockMeta = Record<string, unknown>;\n\nexport type GenerationContentBlock =\n | { type: \"text\"; text: string; meta?: GenerationContentBlockMeta }\n | { type: \"image\"; source: GenerationSource; meta?: GenerationContentBlockMeta }\n | { type: \"video\"; source: GenerationSource; meta?: GenerationContentBlockMeta }\n | { type: \"audio\"; source: GenerationSource; meta?: GenerationContentBlockMeta };\n\nexport type GenerationContentSpec = {\n type: \"text\" | \"image\" | \"video\" | \"audio\";\n required?: boolean;\n min?: number;\n max?: number;\n sources?: Array<GenerationSource[\"type\"]>;\n merge?: \"newline\" | \"space\" | \"concat\";\n meta?: Record<string, unknown>;\n description?: string;\n};\n\nexport type GenerationParameterSpec =\n | {\n type: \"string\";\n optional?: boolean;\n default?: string;\n enum?: string[];\n description?: string;\n examples?: string[];\n }\n | {\n type: \"number\";\n optional?: boolean;\n default?: number;\n min?: number;\n max?: number;\n description?: string;\n examples?: number[];\n }\n | {\n type: \"integer\";\n optional?: boolean;\n default?: number;\n min?: number;\n max?: number;\n description?: string;\n examples?: number[];\n }\n | {\n type: \"boolean\";\n optional?: boolean;\n default?: boolean;\n description?: string;\n examples?: boolean[];\n };\n\nexport type GenerationMetaFieldSpec =\n | GenerationParameterSpec\n | { type: \"object\"; optional?: boolean; description?: string };\n\nexport type GenerationMetaTaskVariantSpec = {\n description?: string;\n required?: string[];\n requiredContent?: Array<GenerationContentSpec[\"type\"]>;\n sendTask?: boolean;\n};\n\nexport type GenerationMetaSpec = {\n fields?: Record<string, GenerationMetaFieldSpec>;\n taskField?: string;\n taskVariants?: Record<string, GenerationMetaTaskVariantSpec>;\n};\n\nexport type GenerationModelDeclaration = {\n schema: typeof MODEL_SCHEMA;\n model: string;\n title?: string;\n description?: string;\n allowUnknownParameters?: boolean;\n adapter: {\n type: string;\n };\n content: {\n input: GenerationContentSpec[];\n };\n parameters?: Record<string, GenerationParameterSpec>;\n meta?: GenerationMetaSpec;\n examples?: Array<{\n title?: string;\n request: GenerateRequest;\n }>;\n};\n\nexport type GenerateRequest = {\n model: string;\n content: GenerationContentBlock[];\n parameters?: Record<string, unknown>;\n meta?: Record<string, unknown>;\n /** @deprecated Use meta. */\n metadata?: Record<string, unknown>;\n apiKey?: string;\n baseUrl?: string;\n};\n\nexport type ResolvedGenerationRequest = {\n declaration: GenerationModelDeclaration;\n request: GenerateRequest;\n parameters: Record<string, unknown>;\n meta: Record<string, unknown>;\n};\n\nexport type GenerationSourceResolver = (source: GenerationSource) => Promise<string> | string;\n\nexport type GenerationDebugEvent =\n | {\n type: \"request\";\n url: string;\n method: string;\n headers: Record<string, string>;\n body?: unknown;\n }\n | {\n type: \"response\";\n url: string;\n status: number;\n statusText: string;\n headers: Record<string, string>;\n trace: Record<string, string>;\n elapsedMs: number;\n body?: unknown;\n };\n\nexport type GenerationDebugLogger = (event: GenerationDebugEvent) => void;\n\nexport type GenerationDebugOptions = {\n enabled?: boolean;\n includeSensitive?: boolean;\n includeResponseBody?: boolean;\n logger?: GenerationDebugLogger;\n};\n\nexport type GenerationDebugConfig = GenerationDebugOptions & {\n enabled: boolean;\n includeSensitive: boolean;\n includeResponseBody: boolean;\n logger: GenerationDebugLogger;\n};\n\nexport type GenerationAdapterContext = {\n apiKey: string;\n baseUrl: string;\n fetch: typeof fetch;\n resolveSource: GenerationSourceResolver;\n};\n\nexport type GenerationAdapterInput = ResolvedGenerationRequest & {\n context: GenerationAdapterContext;\n};\n\nexport type GenerationAdapter = (input: GenerationAdapterInput) => Promise<GenerationContentBlock[]>;\n\nexport type CreateGenerationClientOptions = {\n apiKey?: string;\n baseUrl?: string;\n models?: GenerationModelDeclaration[];\n includeBuiltinModels?: boolean;\n fetch?: typeof fetch;\n sourceResolver?: GenerationSourceResolver;\n adapters?: Record<string, GenerationAdapter>;\n debug?: boolean | GenerationDebugOptions;\n};\n\nexport type GenerationClient = {\n generate(request: GenerateRequest): Promise<GenerationContentBlock[]>;\n validate(request: GenerateRequest): ResolvedGenerationRequest;\n listModels(): GenerationModelDeclaration[];\n getModel(model: string): GenerationModelDeclaration | null;\n stringifyModelConfig(model: string, options?: { format?: \"yaml\" | \"json\" }): string;\n exportModelConfig(model: string, filePath: string): Promise<void>;\n exportModelConfigs(directory: string): Promise<void>;\n};\n","import type { GenerationContentBlock } from \"./types.js\";\n\nexport function cloneJson<T>(value: T): T {\n return JSON.parse(JSON.stringify(value)) as T;\n}\n\nexport function slugifyFileName(value: string): string {\n return (\n value\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9._-]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\") || \"model\"\n );\n}\n\nexport function getBlockMeta(block: GenerationContentBlock): Record<string, unknown> | undefined {\n return \"meta\" in block ? block.meta : undefined;\n}\n\nexport function compactArray<T>(values: T[]): T[] | undefined {\n return values.length > 0 ? values : undefined;\n}\n\nexport function compactObject<T extends Record<string, unknown>>(value: T): T {\n for (const key of Object.keys(value)) if (value[key] === undefined) delete value[key];\n return value;\n}\n","import type { GenerationModelDeclaration } from \"./types.js\";\nimport { MODEL_SCHEMA } from \"./types.js\";\nimport { cloneJson } from \"./utils.js\";\n\nconst imageSizeParameters = {\n size: {\n type: \"string\",\n optional: true,\n default: \"1024x1024\",\n description: \"Output image size.\",\n examples: [\"auto\", \"1024x1024\", \"1536x1024\", \"1024x1536\", \"2048x2048\", \"2048x1152\", \"3840x2160\", \"2160x3840\"],\n },\n quality: {\n type: \"string\",\n optional: true,\n default: \"auto\",\n enum: [\"auto\", \"low\", \"medium\", \"high\"],\n description: \"Image quality.\",\n },\n} satisfies GenerationModelDeclaration[\"parameters\"];\n\nfunction videoParameters(defaults: { resolution: string; maxWait: number }) {\n return {\n duration: {\n type: \"integer\",\n optional: true,\n default: 5,\n min: 4,\n max: 15,\n description: \"Video duration in seconds.\",\n },\n resolution: {\n type: \"string\",\n optional: true,\n default: defaults.resolution,\n enum: [\"480p\", \"720p\", \"1080p\", \"2K\"],\n description: \"Output video resolution.\",\n },\n aspect_ratio: {\n type: \"string\",\n optional: true,\n default: \"16:9\",\n enum: [\"16:9\", \"9:16\", \"1:1\", \"4:3\", \"3:2\", \"2:3\", \"3:4\", \"21:9\", \"adaptive\"],\n description: \"Output aspect ratio. Use adaptive to let the model choose.\",\n },\n fps: { type: \"integer\", optional: true, default: 30, min: 1, max: 60, description: \"Frames per second.\" },\n seed: { type: \"integer\", optional: true, description: \"Random seed for reproducibility.\" },\n generate_audio: { type: \"boolean\", optional: true, default: true, description: \"Generate synchronized audio.\" },\n return_last_frame: {\n type: \"boolean\",\n optional: true,\n default: true,\n description: \"Return the last frame as an image for chaining video segments.\",\n },\n camera_fixed: {\n type: \"boolean\",\n optional: true,\n default: false,\n description: \"Fix camera position when supported.\",\n },\n watermark: { type: \"boolean\", optional: true, default: false, description: \"Add AI Generated watermark.\" },\n poll_interval: {\n type: \"integer\",\n optional: true,\n default: 2,\n min: 1,\n max: 30,\n description: \"Seconds between task status checks.\",\n },\n max_wait: {\n type: \"integer\",\n optional: true,\n default: defaults.maxWait,\n min: 30,\n max: 1800,\n description: \"Maximum seconds to wait for task completion.\",\n },\n } satisfies GenerationModelDeclaration[\"parameters\"];\n}\n\nconst sunoContinuationTaskVariant = {\n required: [\"task_id\", \"clip_id\", \"continue_clip_id\"],\n};\n\nconst sunoMeta = {\n taskField: \"task\",\n fields: {\n task: {\n type: \"string\",\n optional: true,\n enum: [\n \"extend\",\n \"upload_extend\",\n \"infill\",\n \"fixed_infill\",\n \"infill_intro\",\n \"infill_outro\",\n \"cover_infill\",\n \"cover_extend\",\n \"artist_infill\",\n \"artist_consistency\",\n \"cover\",\n \"image_to_song\",\n \"video_to_song\",\n \"concat\",\n \"sound\",\n \"underpainting\",\n \"remaster\",\n \"vox\",\n \"mashup_condition\",\n ],\n description: \"Integrated Suno music task for operation=music.\",\n },\n mv: { type: \"string\", optional: true, description: \"Suno music model version.\" },\n task_id: {\n type: \"string\",\n optional: true,\n description: \"Existing Suno task id used for continuation-style tasks.\",\n },\n clip_id: {\n type: \"string\",\n optional: true,\n description: \"Existing Suno clip id used for continuation-style tasks.\",\n },\n continue_clip_id: { type: \"string\", optional: true, description: \"Clip id to continue from.\" },\n continue_at: { type: \"number\", optional: true, description: \"Continue position in seconds.\" },\n model_name: { type: \"string\", optional: true, description: \"Suno model name used by remaster.\" },\n variation_category: { type: \"string\", optional: true, description: \"Remaster variation category.\" },\n metadata_params: {\n type: \"object\",\n optional: true,\n description: \"Yunwu/Suno task-specific metadata payload.\",\n },\n },\n taskVariants: {\n extend: sunoContinuationTaskVariant,\n upload_extend: sunoContinuationTaskVariant,\n infill: sunoContinuationTaskVariant,\n fixed_infill: sunoContinuationTaskVariant,\n infill_intro: sunoContinuationTaskVariant,\n infill_outro: sunoContinuationTaskVariant,\n cover_infill: sunoContinuationTaskVariant,\n cover_extend: sunoContinuationTaskVariant,\n artist_infill: sunoContinuationTaskVariant,\n artist_consistency: sunoContinuationTaskVariant,\n cover: sunoContinuationTaskVariant,\n image_to_song: { requiredContent: [\"image\"], required: [\"metadata_params\"] },\n video_to_song: { requiredContent: [\"video\"], required: [\"metadata_params\"] },\n concat: sunoContinuationTaskVariant,\n sound: { required: [\"metadata_params\"] },\n underpainting: { required: [\"metadata_params\"] },\n remaster: { sendTask: false, required: [\"clip_id\", \"model_name\", \"variation_category\"] },\n vox: sunoContinuationTaskVariant,\n mashup_condition: sunoContinuationTaskVariant,\n },\n} satisfies GenerationModelDeclaration[\"meta\"];\n\nconst builtinModels = [\n {\n schema: MODEL_SCHEMA,\n model: \"gpt-image-2\",\n title: \"GPT Image 2\",\n description:\n \"Image generation model with optional reference images. Good for photorealistic scenes, detailed images, and image editing with references.\",\n adapter: { type: \"openai.images\" },\n content: {\n input: [\n { type: \"text\", required: true, min: 1, max: 16, merge: \"newline\", description: \"Prompt text.\" },\n {\n type: \"image\",\n required: false,\n max: 16,\n sources: [\"url\", \"base64\"],\n description: \"Optional reference images.\",\n },\n ],\n },\n parameters: imageSizeParameters,\n examples: [\n {\n title: \"Basic image\",\n request: {\n model: \"gpt-image-2\",\n content: [{ type: \"text\", text: \"a cyberpunk cat in neon rain\" }],\n parameters: { size: \"1024x1024\", quality: \"auto\" },\n },\n },\n ],\n },\n {\n schema: MODEL_SCHEMA,\n model: \"gemini-3.1-flash-image-preview\",\n title: \"Gemini 3.1 Flash Image Preview\",\n description:\n \"Gemini image generation and editing model. Good for text rendering, infographics, style transfer, and iterative image editing with references.\",\n adapter: { type: \"gemini.generateContent\" },\n content: {\n input: [\n { type: \"text\", required: true, min: 1, max: 16, merge: \"newline\", description: \"Prompt text.\" },\n {\n type: \"image\",\n required: false,\n max: 14,\n sources: [\"url\", \"base64\"],\n description: \"Optional reference images.\",\n },\n ],\n },\n parameters: {\n aspect_ratio: {\n type: \"string\",\n optional: true,\n default: \"1:1\",\n enum: [\"1:1\", \"16:9\", \"4:3\", \"3:2\", \"3:4\", \"2:3\", \"9:16\", \"5:4\", \"4:5\", \"21:9\", \"1:4\", \"4:1\", \"1:8\", \"8:1\"],\n description: \"Output aspect ratio.\",\n },\n image_size: {\n type: \"string\",\n optional: true,\n default: \"2K\",\n enum: [\"512\", \"1K\", \"2K\", \"4K\"],\n description: \"Output image resolution.\",\n },\n },\n examples: [\n {\n title: \"Basic image\",\n request: {\n model: \"gemini-3.1-flash-image-preview\",\n content: [\n { type: \"text\", text: \"a vibrant infographic explaining photosynthesis with clear readable labels\" },\n ],\n parameters: { aspect_ratio: \"16:9\", image_size: \"1K\" },\n },\n },\n ],\n },\n {\n schema: MODEL_SCHEMA,\n model: \"seedance-2-0\",\n title: \"Seedance 2.0\",\n description: \"Higher quality Ark video generation model for final production outputs.\",\n adapter: { type: \"ark.videoGenerations\" },\n content: {\n input: [\n { type: \"text\", required: true, min: 1, max: 16, merge: \"newline\", description: \"Video prompt.\" },\n {\n type: \"image\",\n required: false,\n max: 9,\n sources: [\"url\", \"base64\"],\n description: \"Optional image input. Use meta.role as first_frame, last_frame, or reference_image.\",\n },\n ],\n },\n parameters: videoParameters({ resolution: \"1080p\", maxWait: 900 }),\n },\n {\n schema: MODEL_SCHEMA,\n model: \"seedance-2-0-fast\",\n title: \"Seedance 2.0 Fast\",\n description:\n \"Fast Ark video generation model for drafts, rapid iteration, text-to-video, image-to-video, and reference-guided video generation.\",\n adapter: { type: \"ark.videoGenerations\" },\n content: {\n input: [\n { type: \"text\", required: true, min: 1, max: 16, merge: \"newline\", description: \"Video prompt.\" },\n {\n type: \"image\",\n required: false,\n max: 9,\n sources: [\"url\", \"base64\"],\n description: \"Optional image input. Use meta.role as first_frame, last_frame, or reference_image.\",\n },\n ],\n },\n parameters: videoParameters({ resolution: \"720p\", maxWait: 600 }),\n },\n {\n schema: MODEL_SCHEMA,\n model: \"suno_music\",\n title: \"Suno Music\",\n description: \"Suno music model for songs, lyrics, sound effects, and integrated music tasks.\",\n adapter: { type: \"suno.tasks\" },\n content: {\n input: [\n {\n type: \"text\",\n required: false,\n max: 16,\n merge: \"newline\",\n description:\n \"Optional prompt text. The adapter maps merged text to the operation's text field when that field is not provided.\",\n },\n {\n type: \"audio\",\n required: false,\n max: 1,\n sources: [\"url\", \"base64\"],\n description: \"Optional reference audio. The adapter maps it to url when url is not provided.\",\n },\n {\n type: \"image\",\n required: false,\n max: 1,\n sources: [\"url\", \"base64\"],\n description: \"Optional image source. The adapter maps it to image_url when image_url is not provided.\",\n },\n {\n type: \"video\",\n required: false,\n max: 1,\n sources: [\"url\", \"base64\"],\n description: \"Optional video source. The adapter maps it to video_url when video_url is not provided.\",\n },\n ],\n },\n parameters: {\n operation: {\n type: \"string\",\n optional: true,\n default: \"music\",\n enum: [\"music\", \"lyrics\"],\n description:\n \"Stable Suno endpoint operation. Provider-specific fields such as task, mv, title, tags, metadataParams, and clip_id belong in request meta.\",\n },\n poll_interval: {\n type: \"integer\",\n optional: true,\n default: 5,\n min: 1,\n max: 60,\n description: \"Seconds between task status checks.\",\n },\n max_wait: {\n type: \"integer\",\n optional: true,\n default: 600,\n min: 30,\n max: 3600,\n description: \"Maximum seconds to wait for task completion.\",\n },\n },\n meta: sunoMeta,\n examples: [\n {\n title: \"Music generation\",\n request: {\n model: \"suno_music\",\n content: [{ type: \"text\", text: \"uplifting cinematic pop with warm piano and clear chorus\" }],\n parameters: { operation: \"music\" },\n meta: {\n mv: \"chirp-v5-5\",\n title: \"Warm Horizon\",\n tags: \"cinematic pop, warm piano\",\n make_instrumental: false,\n },\n },\n },\n {\n title: \"Lyrics\",\n request: {\n model: \"suno_music\",\n content: [{ type: \"text\", text: \"write a hopeful chorus about sunrise after a storm\" }],\n parameters: { operation: \"lyrics\" },\n },\n },\n {\n title: \"Sound effect\",\n request: {\n model: \"suno_music\",\n content: [{ type: \"text\", text: \"ambient music with gentle rain and distant thunder\" }],\n parameters: { operation: \"music\" },\n meta: {\n task: \"sound\",\n mv: \"chirp-v5-5\",\n metadata_params: { sound: \"gentle rain ambience with distant thunder\" },\n title: \"Gentle Rain\",\n tags: \"ambient, rain, cinematic\",\n make_instrumental: true,\n },\n },\n },\n {\n title: \"Image to song\",\n request: {\n model: \"suno_music\",\n content: [\n { type: \"text\", text: \"turn this image into a short hopeful pop song\" },\n { type: \"image\", source: { type: \"url\", url: \"https://picsum.photos/512/512\" } },\n ],\n parameters: { operation: \"music\" },\n meta: {\n task: \"image_to_song\",\n mv: \"chirp-v5-5\",\n metadata_params: {\n image_url: \"https://picsum.photos/512/512\",\n prompt: \"turn this image into a short hopeful pop song\",\n },\n },\n },\n },\n ],\n },\n] satisfies GenerationModelDeclaration[];\n\nexport const builtinGenerationModels: GenerationModelDeclaration[] = cloneJson(builtinModels);\n\nexport function getBuiltinGenerationModel(model: string): GenerationModelDeclaration | null {\n return cloneJson(builtinModels.find((declaration) => declaration.model === model) ?? null);\n}\n\nexport function listBuiltinGenerationModels(): GenerationModelDeclaration[] {\n return cloneJson(builtinModels);\n}\n"],"mappings":";AAAA,MAAa,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AAE,MAAM;MAAS,QAAQ;OAAE,MAAM;OAAO,KAAK;OAAiC;MAAE,CACjF;KACD,YAAY,EAAE,WAAW,SAAS;KAClC,MAAM;MACJ,MAAM;MACN,IAAI;MACJ,iBAAiB;OACf,WAAW;OACX,QAAQ;OACT;MACF;KACF;IACF;GACF;EACF;CACF;AAED,MAAaA,0BAAwD,UAAU,cAAc;AAE7F,SAAgB,0BAA0B,OAAkD;AAC1F,QAAO,UAAU,cAAc,MAAM,gBAAgB,YAAY,UAAU,MAAM,IAAI,KAAK;;AAG5F,SAAgB,8BAA4D;AAC1E,QAAO,UAAU,cAAc"}
|
package/dist/builtins.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as getBuiltinGenerationModel, r as listBuiltinGenerationModels, t as builtinGenerationModels } from "./builtins-
|
|
1
|
+
import { n as getBuiltinGenerationModel, r as listBuiltinGenerationModels, t as builtinGenerationModels } from "./builtins-BJ2_TVlr.js";
|
|
2
2
|
export { builtinGenerationModels, getBuiltinGenerationModel, listBuiltinGenerationModels };
|
package/dist/builtins.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as getBuiltinGenerationModel, r as listBuiltinGenerationModels, t as builtinGenerationModels } from "./builtins-
|
|
1
|
+
import { n as getBuiltinGenerationModel, r as listBuiltinGenerationModels, t as builtinGenerationModels } from "./builtins-FumzmWvj.js";
|
|
2
2
|
|
|
3
3
|
export { builtinGenerationModels, getBuiltinGenerationModel, listBuiltinGenerationModels };
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { r as listBuiltinGenerationModels } from "../builtins-
|
|
3
|
-
import {
|
|
2
|
+
import { r as listBuiltinGenerationModels } from "../builtins-FumzmWvj.js";
|
|
3
|
+
import { h as stringifyGenerationModelDeclaration, i as createGenerationClient, n as exportBuiltinModelConfigs, t as exportBuiltinModelConfig } from "../export-config-D8By2_r7.js";
|
|
4
4
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
|
|
@@ -9,9 +9,13 @@ function usage() {
|
|
|
9
9
|
console.log(`neta-generation
|
|
10
10
|
|
|
11
11
|
Usage:
|
|
12
|
+
neta-generation generate <model> --prompt <text> [--param key=value] [--image-url <url>] [--out <directory>] [--debug] [--debug-sensitive] [--no-debug-response-body]
|
|
12
13
|
neta-generation models list
|
|
13
14
|
neta-generation models export <model> --out <file>
|
|
14
15
|
neta-generation models export-all --out <directory>
|
|
16
|
+
|
|
17
|
+
Environment:
|
|
18
|
+
NETA_ROUTER_API_KEY API key used by generate
|
|
15
19
|
`);
|
|
16
20
|
process.exit(1);
|
|
17
21
|
}
|
|
@@ -20,8 +24,86 @@ function readOption(args, name) {
|
|
|
20
24
|
if (index < 0) return null;
|
|
21
25
|
return args[index + 1] ?? null;
|
|
22
26
|
}
|
|
27
|
+
function readOptions(args, name) {
|
|
28
|
+
const values = [];
|
|
29
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
30
|
+
const value = args[index + 1];
|
|
31
|
+
if (args[index] === name && value) values.push(value);
|
|
32
|
+
}
|
|
33
|
+
return values;
|
|
34
|
+
}
|
|
35
|
+
function hasFlag(args, name) {
|
|
36
|
+
return args.includes(name);
|
|
37
|
+
}
|
|
38
|
+
function parseParameterValue(raw) {
|
|
39
|
+
if (raw.startsWith("json:")) return JSON.parse(raw.slice(5));
|
|
40
|
+
if (raw === "true") return true;
|
|
41
|
+
if (raw === "false") return false;
|
|
42
|
+
return raw;
|
|
43
|
+
}
|
|
44
|
+
function parseParameter(value) {
|
|
45
|
+
const separator = value.indexOf("=");
|
|
46
|
+
if (separator <= 0) throw new Error(`Invalid --param value: ${value}`);
|
|
47
|
+
return [value.slice(0, separator), parseParameterValue(value.slice(separator + 1))];
|
|
48
|
+
}
|
|
49
|
+
function outputSummary(block) {
|
|
50
|
+
if (block.type === "text") return block;
|
|
51
|
+
return {
|
|
52
|
+
type: block.type,
|
|
53
|
+
source: block.source.type === "url" ? block.source : {
|
|
54
|
+
type: "base64",
|
|
55
|
+
mediaType: block.source.mediaType,
|
|
56
|
+
bytes: Buffer.byteLength(block.source.data, "base64")
|
|
57
|
+
},
|
|
58
|
+
meta: block.meta
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
async function writeOutputFiles(directory, output) {
|
|
62
|
+
await mkdir(directory, { recursive: true });
|
|
63
|
+
await Promise.all(output.map(async (block, index) => {
|
|
64
|
+
if (block.type !== "image" && block.type !== "video" && block.type !== "audio" || block.source.type !== "base64") return;
|
|
65
|
+
const extension = block.source.mediaType.split("/")[1]?.split("+")[0] || block.type;
|
|
66
|
+
await writeFile(join(directory, `${String(index + 1).padStart(2, "0")}.${extension}`), Buffer.from(block.source.data, "base64"));
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
23
69
|
async function main() {
|
|
24
70
|
const args = process.argv.slice(2);
|
|
71
|
+
if (args[0] === "generate") {
|
|
72
|
+
const model = args[1];
|
|
73
|
+
const prompt = readOption(args, "--prompt");
|
|
74
|
+
const apiKey = process.env.NETA_ROUTER_API_KEY;
|
|
75
|
+
if (!model || !prompt || !apiKey) usage();
|
|
76
|
+
const outputDirectory = readOption(args, "--out");
|
|
77
|
+
const content = [{
|
|
78
|
+
type: "text",
|
|
79
|
+
text: prompt
|
|
80
|
+
}, ...readOptions(args, "--image-url").map((url) => ({
|
|
81
|
+
type: "image",
|
|
82
|
+
source: {
|
|
83
|
+
type: "url",
|
|
84
|
+
url
|
|
85
|
+
}
|
|
86
|
+
}))];
|
|
87
|
+
const parameters = Object.fromEntries(readOptions(args, "--param").map(parseParameter));
|
|
88
|
+
const baseUrl = readOption(args, "--base-url");
|
|
89
|
+
const debug = hasFlag(args, "--debug") ? {
|
|
90
|
+
enabled: true,
|
|
91
|
+
includeSensitive: hasFlag(args, "--debug-sensitive"),
|
|
92
|
+
includeResponseBody: !hasFlag(args, "--no-debug-response-body")
|
|
93
|
+
} : void 0;
|
|
94
|
+
const output = await createGenerationClient({
|
|
95
|
+
apiKey,
|
|
96
|
+
...baseUrl ? { baseUrl } : {},
|
|
97
|
+
...debug ? { debug } : {}
|
|
98
|
+
}).generate({
|
|
99
|
+
model,
|
|
100
|
+
content,
|
|
101
|
+
parameters
|
|
102
|
+
});
|
|
103
|
+
if (outputDirectory) await writeOutputFiles(outputDirectory, output);
|
|
104
|
+
console.log(JSON.stringify(output.map(outputSummary), null, 2));
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
25
107
|
if (args[0] !== "models") usage();
|
|
26
108
|
switch (args[1]) {
|
|
27
109
|
case "list":
|