@sogni-ai/sogni-client 4.0.0-alpha.44 → 4.0.0-alpha.46
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/CHANGELOG.md +21 -0
- package/README.md +32 -27
- package/dist/Projects/createJobRequestMessage.d.ts +2 -1
- package/dist/Projects/createJobRequestMessage.js +27 -29
- package/dist/Projects/createJobRequestMessage.js.map +1 -1
- package/dist/Projects/index.d.ts +4 -2
- package/dist/Projects/index.js +41 -14
- package/dist/Projects/index.js.map +1 -1
- package/dist/Projects/types/ComfySamplerParams.d.ts +0 -28
- package/dist/Projects/types/ComfySamplerParams.js +0 -34
- package/dist/Projects/types/ComfySamplerParams.js.map +1 -1
- package/dist/Projects/types/ModelOptions.d.ts +31 -0
- package/dist/Projects/types/ModelOptions.js +56 -0
- package/dist/Projects/types/ModelOptions.js.map +1 -0
- package/dist/Projects/types/ModelTiersRaw.d.ts +67 -0
- package/dist/Projects/types/ModelTiersRaw.js +15 -0
- package/dist/Projects/types/ModelTiersRaw.js.map +1 -0
- package/dist/Projects/types/index.d.ts +15 -24
- package/dist/Projects/types/index.js +0 -9
- package/dist/Projects/types/index.js.map +1 -1
- package/dist/Projects/{utils.d.ts → utils/index.d.ts} +1 -1
- package/dist/Projects/{utils.js → utils/index.js} +1 -1
- package/dist/Projects/utils/index.js.map +1 -0
- package/dist/Projects/utils/samplers.d.ts +2 -0
- package/dist/Projects/{types/ForgeSamplerParams.js → utils/samplers.js} +9 -10
- package/dist/Projects/utils/samplers.js.map +1 -0
- package/dist/Projects/utils/scheduler.d.ts +2 -0
- package/dist/Projects/utils/scheduler.js +27 -0
- package/dist/Projects/utils/scheduler.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -6
- package/dist/index.js.map +1 -1
- package/dist/lib/{utils.js → utils/index.js} +1 -1
- package/dist/lib/utils/index.js.map +1 -0
- package/dist/lib/validation.d.ts +3 -14
- package/dist/lib/validation.js +23 -66
- package/dist/lib/validation.js.map +1 -1
- package/package.json +1 -1
- package/src/Projects/createJobRequestMessage.ts +43 -34
- package/src/Projects/index.ts +47 -22
- package/src/Projects/types/ComfySamplerParams.ts +0 -34
- package/src/Projects/types/ModelOptions.ts +92 -0
- package/src/Projects/types/ModelTiersRaw.ts +86 -0
- package/src/Projects/types/index.ts +17 -32
- package/src/Projects/{utils.ts → utils/index.ts} +1 -1
- package/src/Projects/{types/ForgeSamplerParams.ts → utils/samplers.ts} +9 -8
- package/src/Projects/utils/scheduler.ts +27 -0
- package/src/index.ts +1 -26
- package/src/lib/validation.ts +33 -82
- package/dist/Projects/types/ComfySchedulerParams.d.ts +0 -17
- package/dist/Projects/types/ComfySchedulerParams.js +0 -23
- package/dist/Projects/types/ComfySchedulerParams.js.map +0 -1
- package/dist/Projects/types/ForgeSamplerParams.d.ts +0 -27
- package/dist/Projects/types/ForgeSamplerParams.js.map +0 -1
- package/dist/Projects/types/ForgeSchedulerParams.d.ts +0 -17
- package/dist/Projects/types/ForgeSchedulerParams.js +0 -28
- package/dist/Projects/types/ForgeSchedulerParams.js.map +0 -1
- package/dist/Projects/utils.js.map +0 -1
- package/dist/lib/utils.js.map +0 -1
- package/src/Projects/types/ComfySchedulerParams.ts +0 -21
- package/src/Projects/types/ForgeSchedulerParams.ts +0 -26
- /package/dist/lib/{utils.d.ts → utils/index.d.ts} +0 -0
- /package/src/lib/{utils.ts → utils/index.ts} +0 -0
|
@@ -9,17 +9,16 @@ import { ControlNetParams, ControlNetParamsRaw } from './types/ControlNetParams'
|
|
|
9
9
|
import {
|
|
10
10
|
validateNumber,
|
|
11
11
|
validateCustomImageSize,
|
|
12
|
-
validateForgeSampler,
|
|
13
|
-
validateForgeScheduler,
|
|
14
12
|
validateVideoSize,
|
|
15
13
|
validateTeacacheThreshold,
|
|
16
|
-
validateComfySampler,
|
|
17
|
-
validateComfyScheduler,
|
|
18
14
|
isComfyModel,
|
|
19
|
-
validateVideoDuration
|
|
15
|
+
validateVideoDuration,
|
|
16
|
+
validateSampler,
|
|
17
|
+
validateScheduler
|
|
20
18
|
} from '../lib/validation';
|
|
21
19
|
import { getVideoWorkflowType, isVideoModel, VIDEO_WORKFLOW_ASSETS } from './utils';
|
|
22
20
|
import { ApiError } from '../ApiClient';
|
|
21
|
+
import { ImageModelOptions, ModelOptions, VideoModelOptions } from './types/ModelOptions';
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
24
|
* Validate that the provided assets match the workflow requirements.
|
|
@@ -178,31 +177,27 @@ function getControlNet(params: ControlNetParams): ControlNetParamsRaw[] {
|
|
|
178
177
|
return [cn];
|
|
179
178
|
}
|
|
180
179
|
|
|
181
|
-
function applyImageParams(
|
|
180
|
+
function applyImageParams(
|
|
181
|
+
inputKeyframe: Record<string, any>,
|
|
182
|
+
params: ImageProjectParams,
|
|
183
|
+
options: ImageModelOptions
|
|
184
|
+
) {
|
|
182
185
|
const keyFrame: Record<string, any> = {
|
|
183
186
|
...inputKeyframe,
|
|
184
187
|
sizePreset: params.sizePreset,
|
|
185
188
|
hasContextImage1: !!params.contextImages?.[0],
|
|
186
189
|
hasContextImage2: !!params.contextImages?.[1],
|
|
187
|
-
hasContextImage3: !!params.contextImages?.[2]
|
|
190
|
+
hasContextImage3: !!params.contextImages?.[2],
|
|
191
|
+
hasContextImage4: !!params.contextImages?.[3],
|
|
192
|
+
hasContextImage5: !!params.contextImages?.[4],
|
|
193
|
+
hasContextImage6: !!params.contextImages?.[5]
|
|
188
194
|
};
|
|
189
|
-
|
|
190
|
-
// Handle sampler/scheduler: ComfyUI models use comfySampler/comfyScheduler,
|
|
191
|
-
// legacy models use sampler/scheduler (mapped to scheduler/timeStepSpacing)
|
|
192
195
|
if (isComfyModel(params.modelId)) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
if (params.scheduler !== undefined) {
|
|
197
|
-
keyFrame.comfyScheduler = validateComfyScheduler(params.scheduler);
|
|
198
|
-
}
|
|
196
|
+
keyFrame.comfySampler = validateSampler(params.sampler, options);
|
|
197
|
+
keyFrame.comfyScheduler = validateScheduler(params.scheduler, options);
|
|
199
198
|
} else {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
if (params.scheduler !== undefined) {
|
|
204
|
-
keyFrame.timeStepSpacing = validateForgeScheduler(params.scheduler);
|
|
205
|
-
}
|
|
199
|
+
keyFrame.scheduler = validateSampler(params.sampler, options);
|
|
200
|
+
keyFrame.timeStepSpacing = validateScheduler(params.scheduler, options);
|
|
206
201
|
}
|
|
207
202
|
|
|
208
203
|
if (params.startingImage) {
|
|
@@ -229,7 +224,11 @@ function applyImageParams(inputKeyframe: Record<string, any>, params: ImageProje
|
|
|
229
224
|
return keyFrame;
|
|
230
225
|
}
|
|
231
226
|
|
|
232
|
-
function applyVideoParams(
|
|
227
|
+
function applyVideoParams(
|
|
228
|
+
inputKeyframe: Record<string, any>,
|
|
229
|
+
params: VideoProjectParams,
|
|
230
|
+
options: VideoModelOptions
|
|
231
|
+
) {
|
|
233
232
|
if (!isVideoModel(params.modelId)) {
|
|
234
233
|
throw new ApiError(400, {
|
|
235
234
|
status: 'error',
|
|
@@ -292,19 +291,13 @@ function applyVideoParams(inputKeyframe: Record<string, any>, params: VideoProje
|
|
|
292
291
|
keyFrame.height = validateVideoSize(params.height, 'height');
|
|
293
292
|
}
|
|
294
293
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (params.sampler !== undefined) {
|
|
298
|
-
keyFrame.comfySampler = validateComfySampler(params.sampler);
|
|
299
|
-
}
|
|
300
|
-
if (params.scheduler !== undefined) {
|
|
301
|
-
keyFrame.comfyScheduler = validateComfyScheduler(params.scheduler);
|
|
302
|
-
}
|
|
294
|
+
keyFrame.comfySampler = validateSampler(params.sampler, options);
|
|
295
|
+
keyFrame.comfyScheduler = validateScheduler(params.scheduler, options);
|
|
303
296
|
|
|
304
297
|
return keyFrame;
|
|
305
298
|
}
|
|
306
299
|
|
|
307
|
-
function createJobRequestMessage(id: string, params: ProjectParams) {
|
|
300
|
+
function createJobRequestMessage(id: string, params: ProjectParams, options: ModelOptions) {
|
|
308
301
|
const template = getTemplate();
|
|
309
302
|
// Base keyFrame with common params
|
|
310
303
|
let keyFrame: Record<string, any> = {
|
|
@@ -320,10 +313,26 @@ function createJobRequestMessage(id: string, params: ProjectParams) {
|
|
|
320
313
|
|
|
321
314
|
switch (params.type) {
|
|
322
315
|
case 'image':
|
|
323
|
-
|
|
316
|
+
if (options.type !== 'image') {
|
|
317
|
+
throw new ApiError(400, {
|
|
318
|
+
status: 'error',
|
|
319
|
+
errorCode: 0,
|
|
320
|
+
message:
|
|
321
|
+
'Invalid model type. Model does not support image generation. Please use a different model.'
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
keyFrame = applyImageParams(keyFrame, params, options);
|
|
324
325
|
break;
|
|
325
326
|
case 'video':
|
|
326
|
-
|
|
327
|
+
if (options.type !== 'video') {
|
|
328
|
+
throw new ApiError(400, {
|
|
329
|
+
status: 'error',
|
|
330
|
+
errorCode: 0,
|
|
331
|
+
message:
|
|
332
|
+
'Invalid model type. Model does not support video generation. Please use a different model.'
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
keyFrame = applyVideoParams(keyFrame, params, options);
|
|
327
336
|
break;
|
|
328
337
|
default:
|
|
329
338
|
throw new ApiError(400, {
|
package/src/Projects/index.ts
CHANGED
|
@@ -11,15 +11,7 @@ import {
|
|
|
11
11
|
SupportedModel,
|
|
12
12
|
ImageProjectParams,
|
|
13
13
|
VideoProjectParams,
|
|
14
|
-
VideoEstimateRequest
|
|
15
|
-
SupportedComfySamplers,
|
|
16
|
-
SupportedForgeSamplers,
|
|
17
|
-
SupportedComfySchedulers,
|
|
18
|
-
SupportedForgeSchedulers,
|
|
19
|
-
ComfyScheduler,
|
|
20
|
-
ForgeScheduler,
|
|
21
|
-
ComfySampler,
|
|
22
|
-
ForgeSampler
|
|
14
|
+
VideoEstimateRequest
|
|
23
15
|
} from './types';
|
|
24
16
|
import {
|
|
25
17
|
JobErrorData,
|
|
@@ -47,7 +39,9 @@ import {
|
|
|
47
39
|
VIDEO_WORKFLOW_ASSETS
|
|
48
40
|
} from './utils';
|
|
49
41
|
import { TokenType } from '../types/token';
|
|
50
|
-
import {
|
|
42
|
+
import { validateSampler } from '../lib/validation';
|
|
43
|
+
import ModelTiersRaw, { isComfyImageTier, isImageTier, isVideoTier } from './types/ModelTiersRaw';
|
|
44
|
+
import { mapComfyImageTier, mapImageTier, mapVideoTier, ModelOptions } from './types/ModelOptions';
|
|
51
45
|
|
|
52
46
|
const sizePresetCache = new Cache<SizePreset[]>(10 * 60 * 1000);
|
|
53
47
|
const GARBAGE_COLLECT_TIMEOUT = 30000;
|
|
@@ -106,6 +100,13 @@ class ProjectsApi extends ApiGroup<ProjectApiEvents> {
|
|
|
106
100
|
data: null,
|
|
107
101
|
updatedAt: new Date(0)
|
|
108
102
|
};
|
|
103
|
+
private _modelTiers: {
|
|
104
|
+
data: ModelTiersRaw;
|
|
105
|
+
updatedAt: Date;
|
|
106
|
+
} = {
|
|
107
|
+
data: {},
|
|
108
|
+
updatedAt: new Date(0)
|
|
109
|
+
};
|
|
109
110
|
|
|
110
111
|
get availableModels() {
|
|
111
112
|
return this._availableModels;
|
|
@@ -524,7 +525,8 @@ class ProjectsApi extends ApiGroup<ProjectApiEvents> {
|
|
|
524
525
|
*/
|
|
525
526
|
async create(data: ProjectParams): Promise<Project> {
|
|
526
527
|
const project = new Project({ ...data }, { api: this, logger: this.client.logger });
|
|
527
|
-
const
|
|
528
|
+
const modelOptions = await this.getModelOptions(data.modelId);
|
|
529
|
+
const request = createJobRequestMessage(project.id, data, modelOptions);
|
|
528
530
|
|
|
529
531
|
switch (data.type) {
|
|
530
532
|
case 'image':
|
|
@@ -833,6 +835,7 @@ class ProjectsApi extends ApiGroup<ProjectApiEvents> {
|
|
|
833
835
|
contextImages
|
|
834
836
|
}: EstimateRequest): Promise<CostEstimation> {
|
|
835
837
|
let apiVersion = 2;
|
|
838
|
+
const modelOptions = await this.getModelOptions(model);
|
|
836
839
|
const pathParams = [
|
|
837
840
|
tokenType || 'spark',
|
|
838
841
|
network,
|
|
@@ -858,7 +861,7 @@ class ProjectsApi extends ApiGroup<ProjectApiEvents> {
|
|
|
858
861
|
if (sampler) {
|
|
859
862
|
apiVersion = 3;
|
|
860
863
|
pathParams.push(guidance || 0);
|
|
861
|
-
pathParams.push(validateSampler(
|
|
864
|
+
pathParams.push(validateSampler(sampler, modelOptions)!);
|
|
862
865
|
pathParams.push(contextImages || 0);
|
|
863
866
|
}
|
|
864
867
|
const r = await this.client.socket.get<EstimationResponse>(
|
|
@@ -1005,6 +1008,19 @@ class ProjectsApi extends ApiGroup<ProjectApiEvents> {
|
|
|
1005
1008
|
return models;
|
|
1006
1009
|
}
|
|
1007
1010
|
|
|
1011
|
+
private async _getModelTiers(forceRefresh = false) {
|
|
1012
|
+
if (
|
|
1013
|
+
this._modelTiers.data &&
|
|
1014
|
+
!forceRefresh &&
|
|
1015
|
+
Date.now() - this._modelTiers.updatedAt.getTime() < MODELS_REFRESH_INTERVAL
|
|
1016
|
+
) {
|
|
1017
|
+
return this._modelTiers.data;
|
|
1018
|
+
}
|
|
1019
|
+
const tiers = await this.client.socket.get<ModelTiersRaw>(`/api/v2/models/tiers`);
|
|
1020
|
+
this._modelTiers = { data: tiers, updatedAt: new Date() };
|
|
1021
|
+
return tiers;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1008
1024
|
/**
|
|
1009
1025
|
* Get supported size presets for the model and network. Size presets are cached for 10 minutes.
|
|
1010
1026
|
*
|
|
@@ -1104,18 +1120,27 @@ class ProjectsApi extends ApiGroup<ProjectApiEvents> {
|
|
|
1104
1120
|
});
|
|
1105
1121
|
}
|
|
1106
1122
|
|
|
1107
|
-
async
|
|
1108
|
-
|
|
1109
|
-
|
|
1123
|
+
async getModelOptions(modelId: string): Promise<ModelOptions> {
|
|
1124
|
+
const models = await this.getSupportedModels();
|
|
1125
|
+
const tiers = await this._getModelTiers();
|
|
1126
|
+
const model = models.find((m) => m.id === modelId);
|
|
1127
|
+
if (!model) {
|
|
1128
|
+
throw new Error(`Model ${modelId} not supported`);
|
|
1110
1129
|
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
if (
|
|
1116
|
-
return
|
|
1130
|
+
const tier = tiers[model.tier];
|
|
1131
|
+
if (!tier) {
|
|
1132
|
+
throw new Error(`Unable to find model tier "${model.tier}" please contact support`);
|
|
1133
|
+
}
|
|
1134
|
+
if (isImageTier(tier)) {
|
|
1135
|
+
return mapImageTier(tier);
|
|
1136
|
+
}
|
|
1137
|
+
if (isVideoTier(tier)) {
|
|
1138
|
+
return mapVideoTier(tier);
|
|
1139
|
+
}
|
|
1140
|
+
if (isComfyImageTier(tier)) {
|
|
1141
|
+
return mapComfyImageTier(tier);
|
|
1117
1142
|
}
|
|
1118
|
-
|
|
1143
|
+
throw new Error(`Unsupported model tier "${model.tier}"`);
|
|
1119
1144
|
}
|
|
1120
1145
|
}
|
|
1121
1146
|
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ComfyUI sampler parameters for video models and ComfyUI-based image models.
|
|
3
|
-
* These use lowercase underscore format directly matching ComfyUI's internal names.
|
|
4
|
-
*/
|
|
5
|
-
export const SupportedComfySamplers = {
|
|
6
|
-
euler: 'euler',
|
|
7
|
-
euler_ancestral: 'euler_ancestral',
|
|
8
|
-
heun: 'heun',
|
|
9
|
-
dpmpp_2m: 'dpmpp_2m',
|
|
10
|
-
dpmpp_2m_sde: 'dpmpp_2m_sde',
|
|
11
|
-
dpmpp_sde: 'dpmpp_sde',
|
|
12
|
-
dpmpp_3m_sde: 'dpmpp_3m_sde',
|
|
13
|
-
uni_pc: 'uni_pc',
|
|
14
|
-
lcm: 'lcm',
|
|
15
|
-
// Additional ComfyUI samplers
|
|
16
|
-
lms: 'lms',
|
|
17
|
-
dpm_2: 'dpm_2',
|
|
18
|
-
dpm_2_ancestral: 'dpm_2_ancestral',
|
|
19
|
-
dpm_fast: 'dpm_fast',
|
|
20
|
-
dpm_adaptive: 'dpm_adaptive',
|
|
21
|
-
dpmpp_2s_ancestral: 'dpmpp_2s_ancestral',
|
|
22
|
-
ddpm: 'ddpm',
|
|
23
|
-
ddim: 'ddim',
|
|
24
|
-
uni_pc_bh2: 'uni_pc_bh2',
|
|
25
|
-
// Z-Image specific samplers
|
|
26
|
-
res_multistep: 'res_multistep',
|
|
27
|
-
res_multistep_cfg_pp: 'res_multistep_cfg_pp'
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export function isComfySampler(sampler: string): sampler is ComfySampler {
|
|
31
|
-
return sampler in SupportedComfySamplers;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export type ComfySampler = keyof typeof SupportedComfySamplers;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ComfyImageTier, ImageTier, NumericDefaults, VideoTier } from './ModelTiersRaw';
|
|
2
|
+
import { samplerValueToAlias } from '../utils/samplers';
|
|
3
|
+
import { schedulerValueToAlias } from '../utils/scheduler';
|
|
4
|
+
|
|
5
|
+
interface NumRange {
|
|
6
|
+
min: number;
|
|
7
|
+
max: number;
|
|
8
|
+
step: number;
|
|
9
|
+
default: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface Options<T> {
|
|
13
|
+
allowed: T[];
|
|
14
|
+
default: T | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface NumOptions {
|
|
18
|
+
options: number[];
|
|
19
|
+
default: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ImageModelOptions {
|
|
23
|
+
type: 'image';
|
|
24
|
+
steps: NumRange;
|
|
25
|
+
guidance: NumRange;
|
|
26
|
+
scheduler: Options<string>;
|
|
27
|
+
sampler: Options<string>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface VideoModelOptions {
|
|
31
|
+
type: 'video';
|
|
32
|
+
steps: NumRange;
|
|
33
|
+
guidance: NumRange;
|
|
34
|
+
fps: Options<number>;
|
|
35
|
+
sampler: Options<string>;
|
|
36
|
+
scheduler: Options<string>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type ModelOptions = ImageModelOptions | VideoModelOptions;
|
|
40
|
+
|
|
41
|
+
function mapRange(data: NumericDefaults): NumRange {
|
|
42
|
+
return {
|
|
43
|
+
min: data.min,
|
|
44
|
+
max: data.max,
|
|
45
|
+
step: data.decimals ? Math.pow(10, 0 - data.decimals) : data.step || 1,
|
|
46
|
+
default: data.default
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function mapOptions<T>(data: Options<T> | undefined, mapper = (value: T) => value): Options<T> {
|
|
51
|
+
if (!data) {
|
|
52
|
+
return {
|
|
53
|
+
allowed: [],
|
|
54
|
+
default: null
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
allowed: data.allowed.map(mapper),
|
|
59
|
+
default: data.default !== null ? mapper(data.default) : null
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function mapImageTier(tier: ImageTier): ImageModelOptions {
|
|
64
|
+
return {
|
|
65
|
+
type: 'image',
|
|
66
|
+
steps: mapRange(tier.steps),
|
|
67
|
+
guidance: mapRange(tier.guidance),
|
|
68
|
+
scheduler: mapOptions(tier.scheduler, schedulerValueToAlias),
|
|
69
|
+
sampler: mapOptions(tier.sampler, samplerValueToAlias)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function mapComfyImageTier(tier: ComfyImageTier): ImageModelOptions {
|
|
74
|
+
return {
|
|
75
|
+
type: 'image',
|
|
76
|
+
steps: mapRange(tier.steps),
|
|
77
|
+
guidance: mapRange(tier.guidance),
|
|
78
|
+
scheduler: mapOptions(tier.comfyScheduler, schedulerValueToAlias),
|
|
79
|
+
sampler: mapOptions(tier.comfySampler, samplerValueToAlias)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function mapVideoTier(tier: VideoTier): VideoModelOptions {
|
|
84
|
+
return {
|
|
85
|
+
type: 'video',
|
|
86
|
+
steps: mapRange(tier.steps),
|
|
87
|
+
guidance: mapRange(tier.guidance),
|
|
88
|
+
scheduler: mapOptions(tier.comfyScheduler, schedulerValueToAlias),
|
|
89
|
+
sampler: mapOptions(tier.comfySampler, samplerValueToAlias),
|
|
90
|
+
fps: tier.fps
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export type ModelTiersRaw = Record<string, ModelTier>;
|
|
2
|
+
|
|
3
|
+
export type ModelTier = ImageTier | VideoTier | ComfyImageTier;
|
|
4
|
+
|
|
5
|
+
export interface ComfyImageTier {
|
|
6
|
+
benchmark: Benchmark;
|
|
7
|
+
comfySampler: StringDefaults;
|
|
8
|
+
comfyScheduler?: StringDefaults;
|
|
9
|
+
defaultSize: number;
|
|
10
|
+
guidance: NumericDefaults;
|
|
11
|
+
steps: NumericDefaults;
|
|
12
|
+
type: 'image';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function isComfyImageTier(t: ModelTier): t is ComfyImageTier {
|
|
16
|
+
return 'type' in t && t.type === 'image';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface StringDefaults {
|
|
20
|
+
allowed: string[];
|
|
21
|
+
default: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface NumericDefaults {
|
|
25
|
+
min: number;
|
|
26
|
+
max: number;
|
|
27
|
+
decimals?: number;
|
|
28
|
+
default: number;
|
|
29
|
+
step?: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ImageTier {
|
|
33
|
+
benchmark: Benchmark;
|
|
34
|
+
guidance: NumericDefaults;
|
|
35
|
+
modelFeeUSD?: number;
|
|
36
|
+
nickname?: string;
|
|
37
|
+
scheduler: StringDefaults;
|
|
38
|
+
steps: NumericDefaults;
|
|
39
|
+
sampler: StringDefaults;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function isImageTier(t: ModelTier): t is ImageTier {
|
|
43
|
+
return !Object.prototype.hasOwnProperty.call(t, 'type');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface Benchmark {
|
|
47
|
+
sec: number;
|
|
48
|
+
secContext1?: number;
|
|
49
|
+
secContext2?: number;
|
|
50
|
+
secContext3?: number;
|
|
51
|
+
secCN: number;
|
|
52
|
+
secMaxPreviews: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface VideoTier {
|
|
56
|
+
audioDuration?: DurationDefaults;
|
|
57
|
+
audioStart?: DurationDefaults;
|
|
58
|
+
benchmark: Benchmark;
|
|
59
|
+
comfySampler: StringDefaults;
|
|
60
|
+
comfyScheduler: StringDefaults;
|
|
61
|
+
fps: NumericOptions;
|
|
62
|
+
frames: NumericDefaults;
|
|
63
|
+
guidance: NumericDefaults;
|
|
64
|
+
height: NumericDefaults;
|
|
65
|
+
shift: NumericDefaults;
|
|
66
|
+
steps: NumericDefaults;
|
|
67
|
+
type: 'video';
|
|
68
|
+
videoStart?: DurationDefaults;
|
|
69
|
+
width: NumericDefaults;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function isVideoTier(t: ModelTier): t is VideoTier {
|
|
73
|
+
return 'type' in t && t.type === 'video';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface DurationDefaults {
|
|
77
|
+
min: number;
|
|
78
|
+
default: number;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface NumericOptions {
|
|
82
|
+
allowed: number[];
|
|
83
|
+
default: number;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default ModelTiersRaw;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { SupernetType } from '../../ApiClient/WebSocketClient/types';
|
|
2
2
|
import { ControlNetParams } from './ControlNetParams';
|
|
3
3
|
import { TokenType } from '../../types/token';
|
|
4
|
-
import { ForgeSampler, SupportedForgeSamplers } from './ForgeSamplerParams';
|
|
5
|
-
import { ForgeScheduler, SupportedForgeSchedulers } from './ForgeSchedulerParams';
|
|
6
|
-
import { ComfySampler, SupportedComfySamplers } from './ComfySamplerParams';
|
|
7
|
-
import { ComfyScheduler, SupportedComfySchedulers } from './ComfySchedulerParams';
|
|
8
4
|
|
|
9
5
|
export interface SupportedModel {
|
|
10
6
|
id: string;
|
|
11
7
|
name: string;
|
|
12
8
|
SID: number;
|
|
9
|
+
tier: string;
|
|
13
10
|
/**
|
|
14
11
|
* Media type produced by this model: 'image' or 'video'
|
|
15
12
|
*/
|
|
@@ -35,19 +32,6 @@ export interface SizePreset {
|
|
|
35
32
|
aspect: string;
|
|
36
33
|
}
|
|
37
34
|
|
|
38
|
-
export type Sampler = ForgeSampler | ComfySampler;
|
|
39
|
-
|
|
40
|
-
export type Scheduler = ForgeScheduler | ComfyScheduler;
|
|
41
|
-
|
|
42
|
-
export type { ForgeSampler, ForgeScheduler, ComfySampler, ComfyScheduler };
|
|
43
|
-
|
|
44
|
-
export {
|
|
45
|
-
SupportedForgeSamplers,
|
|
46
|
-
SupportedForgeSchedulers,
|
|
47
|
-
SupportedComfySamplers,
|
|
48
|
-
SupportedComfySchedulers
|
|
49
|
-
};
|
|
50
|
-
|
|
51
35
|
export type ImageOutputFormat = 'png' | 'jpg';
|
|
52
36
|
export type VideoOutputFormat = 'mp4';
|
|
53
37
|
|
|
@@ -182,17 +166,15 @@ export interface VideoProjectParams extends BaseProjectParams {
|
|
|
182
166
|
*/
|
|
183
167
|
height?: number;
|
|
184
168
|
/**
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
* Default: euler (or uni_pc for s2v models)
|
|
169
|
+
* Sampler, available options depend on the model. Use `sogni.projects.getModelOptions(modelId)`
|
|
170
|
+
* to get the list of available samplers.
|
|
188
171
|
*/
|
|
189
|
-
sampler?:
|
|
172
|
+
sampler?: string;
|
|
190
173
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* Default: simple
|
|
174
|
+
* Scheduler, available options depend on the model. Use `sogni.projects.getModelOptions(modelId)`
|
|
175
|
+
* to get the list of available schedulers.
|
|
194
176
|
*/
|
|
195
|
-
scheduler?:
|
|
177
|
+
scheduler?: string;
|
|
196
178
|
/**
|
|
197
179
|
* Output video format. For now only 'mp4' is supported, defaults to 'mp4'.
|
|
198
180
|
*/
|
|
@@ -225,15 +207,15 @@ export interface ImageProjectParams extends BaseProjectParams {
|
|
|
225
207
|
*/
|
|
226
208
|
contextImages?: InputMedia[];
|
|
227
209
|
/**
|
|
228
|
-
*
|
|
229
|
-
*
|
|
210
|
+
* Sampler, available options depend on the model. Use `sogni.projects.getModelOptions(modelId)`
|
|
211
|
+
* to get the list of available samplers.
|
|
230
212
|
*/
|
|
231
|
-
sampler?:
|
|
213
|
+
sampler?: string;
|
|
232
214
|
/**
|
|
233
|
-
*
|
|
234
|
-
*
|
|
215
|
+
* Scheduler, available options depend on the model. Use `sogni.projects.getModelOptions(modelId)`
|
|
216
|
+
* to get the list of available schedulers.
|
|
235
217
|
*/
|
|
236
|
-
scheduler?:
|
|
218
|
+
scheduler?: string;
|
|
237
219
|
/**
|
|
238
220
|
* Size preset ID to use. You can query available size presets
|
|
239
221
|
* from `sogni.projects.sizePresets(network, modelId)`
|
|
@@ -291,6 +273,9 @@ export type ImageUrlParams = {
|
|
|
291
273
|
| 'contextImage1'
|
|
292
274
|
| 'contextImage2'
|
|
293
275
|
| 'contextImage3'
|
|
276
|
+
| 'contextImage4'
|
|
277
|
+
| 'contextImage5'
|
|
278
|
+
| 'contextImage6'
|
|
294
279
|
| 'referenceImage'
|
|
295
280
|
| 'referenceImageEnd';
|
|
296
281
|
startContentType?: string;
|
|
@@ -359,7 +344,7 @@ export interface EstimateRequest {
|
|
|
359
344
|
/**
|
|
360
345
|
* Sampler
|
|
361
346
|
*/
|
|
362
|
-
sampler?:
|
|
347
|
+
sampler?: string;
|
|
363
348
|
/**
|
|
364
349
|
* Number of context images to use (for Flux Kontext).
|
|
365
350
|
* Note that this parameter is ignored if `scheduler` is not provided
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssetRequirement, EnhancementStrength, VideoAssetKey, VideoWorkflowType } from '
|
|
1
|
+
import { AssetRequirement, EnhancementStrength, VideoAssetKey, VideoWorkflowType } from '../types';
|
|
2
2
|
|
|
3
3
|
export function getEnhacementStrength(strength: EnhancementStrength): number {
|
|
4
4
|
switch (strength) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const SamplerAliases: Record<string, string> = {
|
|
2
2
|
euler: 'Euler',
|
|
3
3
|
euler_ancestral: 'Euler Ancestral',
|
|
4
4
|
heun: 'Heun',
|
|
@@ -25,13 +25,14 @@ export const SupportedForgeSamplers = {
|
|
|
25
25
|
pndm_plms: 'PNDM (Pseudo-linear multi-step)'
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
const SamplerValueToAlias = Object.fromEntries(
|
|
29
|
+
Object.entries(SamplerAliases).map(([k, v]) => [v, k])
|
|
30
|
+
);
|
|
31
31
|
|
|
32
|
-
export function
|
|
33
|
-
|
|
34
|
-
return samplers.includes(sampler);
|
|
32
|
+
export function samplerAliasToValue(alias: string): string {
|
|
33
|
+
return SamplerAliases[alias] || alias;
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
export
|
|
36
|
+
export function samplerValueToAlias(value: string): string {
|
|
37
|
+
return SamplerValueToAlias[value] || value;
|
|
38
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const SchedulerAliases: Record<string, string> = {
|
|
2
|
+
simple: 'Simple',
|
|
3
|
+
normal: 'Normal',
|
|
4
|
+
karras: 'Karras',
|
|
5
|
+
exponential: 'Exponential',
|
|
6
|
+
sgm_uniform: 'SGM Uniform',
|
|
7
|
+
ddim_uniform: 'DDIM Uniform',
|
|
8
|
+
beta: 'Beta',
|
|
9
|
+
linear_quadratic: 'Linear Quadratic',
|
|
10
|
+
kl_optimal: 'KL Optimal',
|
|
11
|
+
// Legacy aliases
|
|
12
|
+
ddim: 'DDIM',
|
|
13
|
+
leading: 'Leading',
|
|
14
|
+
linear: 'Linear'
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const SchedulerValueToAlias = Object.fromEntries(
|
|
18
|
+
Object.entries(SchedulerAliases).map(([k, v]) => [v, k])
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export function schedulerAliasToValue(alias: string): string {
|
|
22
|
+
return SchedulerAliases[alias] || alias;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function schedulerValueToAlias(value: string): string {
|
|
26
|
+
return SchedulerValueToAlias[value] || value;
|
|
27
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -17,16 +17,6 @@ import {
|
|
|
17
17
|
ImageProjectParams,
|
|
18
18
|
ImageOutputFormat,
|
|
19
19
|
ProjectParams,
|
|
20
|
-
Sampler,
|
|
21
|
-
ForgeSampler,
|
|
22
|
-
ComfySampler,
|
|
23
|
-
Scheduler,
|
|
24
|
-
ForgeScheduler,
|
|
25
|
-
ComfyScheduler,
|
|
26
|
-
SupportedForgeSamplers,
|
|
27
|
-
SupportedForgeSchedulers,
|
|
28
|
-
SupportedComfySamplers,
|
|
29
|
-
SupportedComfySchedulers,
|
|
30
20
|
VideoProjectParams,
|
|
31
21
|
AudioFormat,
|
|
32
22
|
VideoFormat,
|
|
@@ -52,13 +42,7 @@ export type {
|
|
|
52
42
|
LogLevel,
|
|
53
43
|
ProjectParams,
|
|
54
44
|
ProjectStatus,
|
|
55
|
-
Sampler,
|
|
56
|
-
ForgeSampler,
|
|
57
|
-
ComfySampler,
|
|
58
45
|
SupernetType,
|
|
59
|
-
Scheduler,
|
|
60
|
-
ForgeScheduler,
|
|
61
|
-
ComfyScheduler,
|
|
62
46
|
TokenType,
|
|
63
47
|
VideoFormat,
|
|
64
48
|
VideoOutputFormat,
|
|
@@ -66,16 +50,7 @@ export type {
|
|
|
66
50
|
VideoWorkflowType
|
|
67
51
|
};
|
|
68
52
|
|
|
69
|
-
export {
|
|
70
|
-
ApiError,
|
|
71
|
-
CurrentAccount,
|
|
72
|
-
Job,
|
|
73
|
-
Project,
|
|
74
|
-
SupportedComfySchedulers,
|
|
75
|
-
SupportedComfySamplers,
|
|
76
|
-
SupportedForgeSchedulers,
|
|
77
|
-
SupportedForgeSamplers
|
|
78
|
-
};
|
|
53
|
+
export { ApiError, CurrentAccount, Job, Project };
|
|
79
54
|
|
|
80
55
|
export interface SogniClientConfig {
|
|
81
56
|
/**
|