@runware/sdk-js 1.2.0-beta.2 → 1.2.0
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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +123 -16
- package/dist/index.d.ts +123 -16
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/esm/Runware/Runware-base.d.ts +0 -70
- package/dist/esm/Runware/Runware-base.js +0 -1002
- package/dist/esm/Runware/Runware-client.d.ts +0 -5
- package/dist/esm/Runware/Runware-client.js +0 -28
- package/dist/esm/Runware/Runware-server.d.ts +0 -15
- package/dist/esm/Runware/Runware-server.js +0 -145
- package/dist/esm/Runware/Runware.d.ts +0 -4
- package/dist/esm/Runware/Runware.js +0 -13
- package/dist/esm/Runware/async-retry.d.ts +0 -5
- package/dist/esm/Runware/async-retry.js +0 -30
- package/dist/esm/Runware/index.d.ts +0 -4
- package/dist/esm/Runware/index.js +0 -20
- package/dist/esm/Runware/reconnect.d.ts +0 -11
- package/dist/esm/Runware/reconnect.js +0 -175
- package/dist/esm/Runware/types.d.ts +0 -644
- package/dist/esm/Runware/types.js +0 -156
- package/dist/esm/Runware/utils.d.ts +0 -57
- package/dist/esm/Runware/utils.js +0 -262
- package/dist/esm/tests/Runware/enhance-prompt.test.d.ts +0 -1
- package/dist/esm/tests/Runware/enhance-prompt.test.js +0 -58
- package/dist/esm/tests/Runware/remove-image-background.test.d.ts +0 -1
- package/dist/esm/tests/Runware/remove-image-background.test.js +0 -37
- package/dist/esm/tests/Runware/request-image-to-text.test.d.ts +0 -1
- package/dist/esm/tests/Runware/request-image-to-text.test.js +0 -37
- package/dist/esm/tests/Runware/request-images.test.d.ts +0 -1
- package/dist/esm/tests/Runware/request-images.test.js +0 -84
- package/dist/esm/tests/Runware/runware-server.test.d.ts +0 -1
- package/dist/esm/tests/Runware/runware-server.test.js +0 -26
- package/dist/esm/tests/Runware/upload-image.test.d.ts +0 -1
- package/dist/esm/tests/Runware/upload-image.test.js +0 -28
- package/dist/esm/tests/Runware/upscale-gan.test.d.ts +0 -1
- package/dist/esm/tests/Runware/upscale-gan.test.js +0 -41
- package/dist/esm/tests/mockServer.d.ts +0 -12
- package/dist/esm/tests/mockServer.js +0 -38
- package/dist/esm/tests/script.d.ts +0 -8
- package/dist/esm/tests/script.js +0 -570
- package/dist/esm/tests/test-utils.d.ts +0 -40
- package/dist/esm/tests/test-utils.js +0 -45
package/dist/index.d.cts
CHANGED
|
@@ -10,8 +10,8 @@ declare enum SdkType {
|
|
|
10
10
|
declare enum ETaskType {
|
|
11
11
|
IMAGE_INFERENCE = "imageInference",
|
|
12
12
|
IMAGE_UPLOAD = "imageUpload",
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
UPSCALE = "upscale",
|
|
14
|
+
REMOVE_BACKGROUND = "removeBackground",
|
|
15
15
|
VIDEO_INFERENCE = "videoInference",
|
|
16
16
|
GET_RESPONSE = "getResponse",
|
|
17
17
|
PHOTO_MAKER = "photoMaker",
|
|
@@ -21,7 +21,9 @@ declare enum ETaskType {
|
|
|
21
21
|
PROMPT_ENHANCE = "promptEnhance",
|
|
22
22
|
AUTHENTICATION = "authentication",
|
|
23
23
|
MODEL_UPLOAD = "modelUpload",
|
|
24
|
-
MODEL_SEARCH = "modelSearch"
|
|
24
|
+
MODEL_SEARCH = "modelSearch",
|
|
25
|
+
MEDIA_STORAGE = "mediaStorage",
|
|
26
|
+
VECTORIZE = "vectorize"
|
|
25
27
|
}
|
|
26
28
|
type RunwareBaseType = {
|
|
27
29
|
apiKey: string;
|
|
@@ -39,7 +41,7 @@ interface IAdditionalResponsePayload {
|
|
|
39
41
|
}
|
|
40
42
|
interface IImage {
|
|
41
43
|
taskType: ETaskType;
|
|
42
|
-
imageUUID
|
|
44
|
+
imageUUID?: string;
|
|
43
45
|
inputImageUUID?: string;
|
|
44
46
|
taskUUID: string;
|
|
45
47
|
imageURL?: string;
|
|
@@ -48,6 +50,8 @@ interface IImage {
|
|
|
48
50
|
NSFWContent?: boolean;
|
|
49
51
|
cost?: number;
|
|
50
52
|
seed: number;
|
|
53
|
+
mediaUUID?: string;
|
|
54
|
+
mediaURL?: string;
|
|
51
55
|
}
|
|
52
56
|
interface ITextToImage extends IImage {
|
|
53
57
|
positivePrompt?: string;
|
|
@@ -103,6 +107,7 @@ type IControlNetPreprocess = {
|
|
|
103
107
|
includeCost?: boolean;
|
|
104
108
|
outputQuality?: number;
|
|
105
109
|
customTaskUUID?: string;
|
|
110
|
+
taskUUID?: string;
|
|
106
111
|
retry?: number;
|
|
107
112
|
} & IAdditionalResponsePayload;
|
|
108
113
|
type IControlNet = IControlNetGeneral;
|
|
@@ -201,6 +206,7 @@ interface IRequestImageToText extends IAdditionalResponsePayload {
|
|
|
201
206
|
inputImage?: File | string;
|
|
202
207
|
includeCost?: boolean;
|
|
203
208
|
customTaskUUID?: string;
|
|
209
|
+
taskUUID?: string;
|
|
204
210
|
retry?: number;
|
|
205
211
|
}
|
|
206
212
|
interface IImageToText {
|
|
@@ -211,8 +217,12 @@ interface IImageToText {
|
|
|
211
217
|
}
|
|
212
218
|
interface IRemoveImageBackground extends IRequestImageToText {
|
|
213
219
|
outputType?: IOutputType;
|
|
214
|
-
outputFormat?: IOutputFormat;
|
|
220
|
+
outputFormat?: IOutputFormat | "MP4" | "WEBM" | "MOV";
|
|
215
221
|
model: string;
|
|
222
|
+
inputs?: {
|
|
223
|
+
video?: InputsValue;
|
|
224
|
+
image?: InputsValue;
|
|
225
|
+
};
|
|
216
226
|
settings?: {
|
|
217
227
|
rgba?: number[];
|
|
218
228
|
postProcessMask?: boolean;
|
|
@@ -225,7 +235,10 @@ interface IRemoveImageBackground extends IRequestImageToText {
|
|
|
225
235
|
includeCost?: boolean;
|
|
226
236
|
outputQuality?: number;
|
|
227
237
|
retry?: number;
|
|
238
|
+
skipResponse?: boolean;
|
|
239
|
+
deliveryMethod?: string;
|
|
228
240
|
}
|
|
241
|
+
type InputsValue = string | Record<string, unknown>;
|
|
229
242
|
interface IRequestVideo extends IRequestImageToText {
|
|
230
243
|
outputType?: IOutputType;
|
|
231
244
|
outputFormat?: IVideoOutputFormat;
|
|
@@ -233,7 +246,7 @@ interface IRequestVideo extends IRequestImageToText {
|
|
|
233
246
|
uploadEndpoint?: string;
|
|
234
247
|
checkNSFW?: boolean;
|
|
235
248
|
includeCost?: boolean;
|
|
236
|
-
positivePrompt
|
|
249
|
+
positivePrompt?: string;
|
|
237
250
|
negativePrompt?: string;
|
|
238
251
|
model: string;
|
|
239
252
|
steps?: number;
|
|
@@ -245,6 +258,22 @@ interface IRequestVideo extends IRequestImageToText {
|
|
|
245
258
|
height?: number;
|
|
246
259
|
numberResults?: number;
|
|
247
260
|
inputAudios?: string[];
|
|
261
|
+
referenceVideos?: string[];
|
|
262
|
+
inputs?: {
|
|
263
|
+
image?: InputsValue;
|
|
264
|
+
images?: InputsValue[];
|
|
265
|
+
audio?: InputsValue;
|
|
266
|
+
audios?: InputsValue[];
|
|
267
|
+
mask?: InputsValue[];
|
|
268
|
+
reference?: InputsValue;
|
|
269
|
+
references?: InputsValue[];
|
|
270
|
+
} & {
|
|
271
|
+
[key: string]: unknown;
|
|
272
|
+
};
|
|
273
|
+
speech?: {
|
|
274
|
+
voice: string;
|
|
275
|
+
text: string;
|
|
276
|
+
};
|
|
248
277
|
skipResponse?: boolean;
|
|
249
278
|
customTaskUUID?: string;
|
|
250
279
|
retry?: number;
|
|
@@ -257,7 +286,10 @@ interface IAsyncResults {
|
|
|
257
286
|
interface IRemoveImage {
|
|
258
287
|
taskType: ETaskType;
|
|
259
288
|
taskUUID: string;
|
|
260
|
-
imageUUID
|
|
289
|
+
imageUUID?: string;
|
|
290
|
+
mediaUUID?: string;
|
|
291
|
+
mediaURL?: string;
|
|
292
|
+
videoUUID?: string;
|
|
261
293
|
inputImageUUID: string;
|
|
262
294
|
imageURL?: string;
|
|
263
295
|
imageBase64Data?: string;
|
|
@@ -270,19 +302,30 @@ interface IPromptEnhancer extends IAdditionalResponsePayload {
|
|
|
270
302
|
prompt: string;
|
|
271
303
|
includeCost?: boolean;
|
|
272
304
|
customTaskUUID?: string;
|
|
305
|
+
taskUUID?: string;
|
|
273
306
|
retry?: number;
|
|
274
307
|
}
|
|
275
308
|
interface IEnhancedPrompt extends IImageToText {
|
|
276
309
|
}
|
|
277
310
|
interface IUpscaleGan extends IAdditionalResponsePayload {
|
|
278
|
-
inputImage
|
|
311
|
+
inputImage?: File | string;
|
|
279
312
|
upscaleFactor: number;
|
|
280
313
|
outputType?: IOutputType;
|
|
281
|
-
outputFormat?: IOutputFormat;
|
|
314
|
+
outputFormat?: IOutputFormat | "MP4" | "WEBM" | "MOV";
|
|
282
315
|
includeCost?: boolean;
|
|
283
316
|
outputQuality?: number;
|
|
317
|
+
inputs?: {
|
|
318
|
+
video?: InputsValue;
|
|
319
|
+
image?: InputsValue;
|
|
320
|
+
} & {
|
|
321
|
+
[key: string]: unknown;
|
|
322
|
+
};
|
|
323
|
+
model?: string;
|
|
284
324
|
customTaskUUID?: string;
|
|
325
|
+
taskUUID?: string;
|
|
285
326
|
retry?: number;
|
|
327
|
+
skipResponse?: boolean;
|
|
328
|
+
deliveryMethod?: string;
|
|
286
329
|
}
|
|
287
330
|
type ReconnectingWebsocketProps = {
|
|
288
331
|
addEventListener: (type: string, listener: EventListener, options: any) => void;
|
|
@@ -397,6 +440,7 @@ type TAddModelBaseType = {
|
|
|
397
440
|
comment?: string;
|
|
398
441
|
private: boolean;
|
|
399
442
|
customTaskUUID?: string;
|
|
443
|
+
taskUUID?: string;
|
|
400
444
|
retry?: number;
|
|
401
445
|
onUploadStream?: (response?: IAddModelResponse, error?: IErrorResponse) => void;
|
|
402
446
|
};
|
|
@@ -440,6 +484,7 @@ type TPhotoMaker = {
|
|
|
440
484
|
includeCost?: boolean;
|
|
441
485
|
outputQuality?: number;
|
|
442
486
|
customTaskUUID?: string;
|
|
487
|
+
taskUUID?: string;
|
|
443
488
|
retry?: number;
|
|
444
489
|
onPartialImages?: (images: IImage[], error?: IError) => void;
|
|
445
490
|
} & IAdditionalResponsePayload;
|
|
@@ -572,11 +617,39 @@ type TImageMasking = {
|
|
|
572
617
|
customTaskUUID?: string;
|
|
573
618
|
retry?: number;
|
|
574
619
|
};
|
|
620
|
+
type TVectorize = {
|
|
621
|
+
model: string;
|
|
622
|
+
outputFormat?: string;
|
|
623
|
+
outputType?: string;
|
|
624
|
+
includeCost?: boolean;
|
|
625
|
+
inputs: {
|
|
626
|
+
image: string;
|
|
627
|
+
};
|
|
628
|
+
customTaskUUID?: string;
|
|
629
|
+
retry?: number;
|
|
630
|
+
};
|
|
631
|
+
type TVectorizeResponse = {
|
|
632
|
+
taskType: string;
|
|
633
|
+
taskUUID: string;
|
|
634
|
+
cost: number;
|
|
635
|
+
imageURL: string;
|
|
636
|
+
};
|
|
575
637
|
type TImageUpload = {
|
|
576
638
|
image: string;
|
|
577
639
|
customTaskUUID?: string;
|
|
578
640
|
retry?: number;
|
|
579
641
|
};
|
|
642
|
+
type TMediaStorage = {
|
|
643
|
+
media: string;
|
|
644
|
+
operation?: string;
|
|
645
|
+
customTaskUUID?: string;
|
|
646
|
+
retry?: number;
|
|
647
|
+
};
|
|
648
|
+
type TMediaStorageResponse = {
|
|
649
|
+
taskType: string;
|
|
650
|
+
taskUUID: string;
|
|
651
|
+
mediaUUID: string;
|
|
652
|
+
};
|
|
580
653
|
type TImageUploadResponse = {
|
|
581
654
|
image: string;
|
|
582
655
|
taskUUID: string;
|
|
@@ -624,6 +697,14 @@ declare class RunwareBase {
|
|
|
624
697
|
_timeoutDuration: number;
|
|
625
698
|
ensureConnectionUUID: string | null;
|
|
626
699
|
constructor({ apiKey, url, shouldReconnect, globalMaxRetries, timeoutDuration, }: RunwareBaseType);
|
|
700
|
+
private getResultUUID;
|
|
701
|
+
/**
|
|
702
|
+
* Shared polling logic for async results.
|
|
703
|
+
* @param taskUUID - The task UUID to poll for.
|
|
704
|
+
* @param numberResults - Number of results expected.
|
|
705
|
+
* @returns Promise resolving to array of results.
|
|
706
|
+
*/
|
|
707
|
+
private pollForAsyncResults;
|
|
627
708
|
static initialize(props: RunwareBaseType): Promise<RunwareBase>;
|
|
628
709
|
protected isWebsocketReadyState: () => boolean;
|
|
629
710
|
protected isInvalidAPIKey: () => boolean;
|
|
@@ -641,19 +722,45 @@ declare class RunwareBase {
|
|
|
641
722
|
private listenToImages;
|
|
642
723
|
private listenToUpload;
|
|
643
724
|
private globalListener;
|
|
644
|
-
requestImages({ outputType, outputFormat, uploadEndpoint, checkNSFW, positivePrompt, negativePrompt, seedImage, maskImage, strength, height, width, model, steps, scheduler, seed, CFGScale, clipSkip, usePromptWeighting, promptWeighting, numberResults, onPartialImages, includeCost, customTaskUUID, retry, refiner, maskMargin, outputQuality, controlNet, lora, embeddings, ipAdapters, providerSettings, outpaint, acceleratorOptions, advancedFeatures, referenceImages, includeGenerationTime, includePayload, ...rest }: IRequestImage, moreOptions?: Record<string, any>): Promise<ITextToImage[] | undefined>;
|
|
645
|
-
|
|
646
|
-
|
|
725
|
+
requestImages({ outputType, outputFormat, uploadEndpoint, checkNSFW, positivePrompt, negativePrompt, seedImage, maskImage, strength, height, width, model, steps, scheduler, seed, CFGScale, clipSkip, usePromptWeighting, promptWeighting, numberResults, onPartialImages, includeCost, customTaskUUID, taskUUID: _taskUUID, retry, refiner, maskMargin, outputQuality, controlNet, lora, embeddings, ipAdapters, providerSettings, outpaint, acceleratorOptions, advancedFeatures, referenceImages, includeGenerationTime, includePayload, ...rest }: IRequestImage, moreOptions?: Record<string, any>): Promise<ITextToImage[] | undefined>;
|
|
726
|
+
imageInference(params: IRequestImage, moreOptions?: Record<string, any>): Promise<ITextToImage[] | undefined>;
|
|
727
|
+
controlNetPreProcess: ({ inputImage, preProcessorType, height, width, outputType, outputFormat, highThresholdCanny, lowThresholdCanny, includeHandsAndFaceOpenPose, includeCost, outputQuality, customTaskUUID, taskUUID: _taskUUID, retry, includeGenerationTime, includePayload, }: IControlNetPreprocess) => Promise<IControlNetImage | null>;
|
|
728
|
+
controlNetPreprocess: (params: IControlNetPreprocess) => Promise<IControlNetImage | null>;
|
|
729
|
+
requestImageToText: ({ inputImage, includeCost, customTaskUUID, taskUUID: _taskUUID, retry, includePayload, includeGenerationTime, }: IRequestImageToText) => Promise<IImageToText>;
|
|
730
|
+
caption: (params: IRequestImageToText) => Promise<IImageToText>;
|
|
731
|
+
/**
|
|
732
|
+
* Remove the background from an image or video.
|
|
733
|
+
* @remark This method now supports the removeBackground type which can handle multiple media types such as image and video.
|
|
734
|
+
* If you pass an `inputs` object with `inputs.image` or `inputs.video`, the response will contain `mediaUUID` and `mediaURL`.
|
|
735
|
+
* If you pass `inputImage`, the response will contain `imageUUID` and `imageURL`.
|
|
736
|
+
* @remark `imageUUID` is no longer guaranteed in the response. Use `mediaUUID` for new implementations.
|
|
737
|
+
* @since 1.2.0
|
|
738
|
+
* @returns {Promise<IRemoveImage>} If called with `inputs.image` or `inputs.video`, returns an object with `mediaUUID` and `mediaURL`. If called with `inputImage`, returns an object with `imageUUID` and `imageURL` (not guaranteed).
|
|
739
|
+
*/
|
|
647
740
|
removeImageBackground: (payload: IRemoveImageBackground) => Promise<IRemoveImage>;
|
|
741
|
+
removeBackground: (payload: IRemoveImageBackground) => Promise<IRemoveImage>;
|
|
742
|
+
vectorize: (payload: TVectorize) => Promise<TVectorizeResponse>;
|
|
648
743
|
videoInference: (payload: IRequestVideo) => Promise<IVideoToImage[] | IVideoToImage>;
|
|
649
|
-
getResponse: (payload: IAsyncResults) => Promise<
|
|
650
|
-
|
|
651
|
-
|
|
744
|
+
getResponse: <T>(payload: IAsyncResults) => Promise<T[]>;
|
|
745
|
+
/**
|
|
746
|
+
* Upscale an image or video
|
|
747
|
+
* @remark This method now supports the upscale type which can handle multiple media types such as image and video.
|
|
748
|
+
* If you pass an `inputs` object with `inputs.image` or `inputs.video`, the response will contain `mediaUUID` and `mediaURL`.
|
|
749
|
+
* If you pass `inputImage`, the response will contain `imageUUID` and `imageURL`.
|
|
750
|
+
* @remark `imageUUID` is no longer guaranteed in the response. Use `mediaUUID` for new implementations.
|
|
751
|
+
* @since 1.2.0
|
|
752
|
+
* @returns {Promise<IImage>} If called with `inputs.image` or `inputs.video`, returns an object with `mediaUUID` and `mediaURL`. If called with `inputImage`, returns an object with `imageUUID` and `imageURL` (not guaranteed).
|
|
753
|
+
*/
|
|
754
|
+
upscaleGan: ({ inputImage, inputs, model, upscaleFactor, outputType, outputFormat, includeCost, outputQuality, customTaskUUID, taskUUID: _taskUUID, retry, includeGenerationTime, includePayload, skipResponse, deliveryMethod }: IUpscaleGan) => Promise<IImage>;
|
|
755
|
+
upscale: (params: IUpscaleGan) => Promise<IImage>;
|
|
756
|
+
enhancePrompt: ({ prompt, promptMaxLength, promptVersions, includeCost, customTaskUUID, taskUUID: _taskUUID, retry, includeGenerationTime, includePayload, }: IPromptEnhancer) => Promise<IEnhancedPrompt[]>;
|
|
757
|
+
promptEnhance: (params: IPromptEnhancer) => Promise<IEnhancedPrompt[]>;
|
|
652
758
|
modelUpload: (payload: TAddModel) => Promise<any>;
|
|
653
759
|
photoMaker: (payload: TPhotoMaker, moreOptions?: Record<string, any>) => Promise<TPhotoMakerResponse[] | undefined>;
|
|
654
760
|
modelSearch: (payload: TModelSearch) => Promise<TModelSearchResponse>;
|
|
655
761
|
imageMasking: (payload: TImageMasking) => Promise<TImageMaskingResponse>;
|
|
656
762
|
imageUpload: (payload: TImageUpload) => Promise<TImageUploadResponse>;
|
|
763
|
+
mediaStorage: (payload: TMediaStorage) => Promise<TMediaStorageResponse>;
|
|
657
764
|
protected baseSingleRequest: <T>({ payload, debugKey, isMultiple, }: {
|
|
658
765
|
payload: Record<string, any>;
|
|
659
766
|
debugKey: string;
|
|
@@ -689,4 +796,4 @@ declare class RunwareServer extends RunwareBase {
|
|
|
689
796
|
|
|
690
797
|
declare let Runware: typeof RunwareClient | typeof RunwareServer;
|
|
691
798
|
|
|
692
|
-
export { EControlMode, EModelArchitecture, EModelConditioning, EModelFormat, EModelType, EOpenPosePreProcessor, EPhotoMakerEnum, EPreProcessor, EPreProcessorGroup, ETaskType, Environment, type GetWithPromiseAsyncCallBackType, type GetWithPromiseCallBackType, type IAddModelResponse, type IAdditionalResponsePayload, type IAsyncResults, type IBflProviderSettings, type IControlNet, type IControlNetGeneral, type IControlNetImage, type IControlNetPreprocess, type IControlNetWithUUID, type IEmbedding, type IEnhancedPrompt, type IError, type IErrorResponse, type IImage, type IImageToText, type IOutpaint, type IOutputFormat, type IOutputType, type IPromptEnhancer, type IProviderSettings, type IRefiner, type IRemoveImage, type IRemoveImageBackground, type IRequestImage, type IRequestImageToText, type IRequestVideo, type ITextToImage, type IUpscaleGan, type IVideoOutputFormat, type IVideoToImage, type IipAdapter, type ListenerType, type ProviderSettings, type ReconnectingWebsocketProps, type RequireAtLeastOne, type RequireOnlyOne, Runware, type RunwareBaseType, RunwareClient, RunwareServer, SdkType, type TAcceleratorOptions, type TAddModel, type TAddModelBaseType, type TAddModelCheckPoint, type TAddModelControlNet, type TAddModelLora, type TImageMasking, type TImageMaskingResponse, type TImageUpload, type TImageUploadResponse, type TModel, type TModelSearch, type TModelSearchResponse, type TPhotoMaker, type TPhotoMakerResponse, type TPromptWeighting, type TServerError, type UploadImageType };
|
|
799
|
+
export { EControlMode, EModelArchitecture, EModelConditioning, EModelFormat, EModelType, EOpenPosePreProcessor, EPhotoMakerEnum, EPreProcessor, EPreProcessorGroup, ETaskType, Environment, type GetWithPromiseAsyncCallBackType, type GetWithPromiseCallBackType, type IAddModelResponse, type IAdditionalResponsePayload, type IAsyncResults, type IBflProviderSettings, type IControlNet, type IControlNetGeneral, type IControlNetImage, type IControlNetPreprocess, type IControlNetWithUUID, type IEmbedding, type IEnhancedPrompt, type IError, type IErrorResponse, type IImage, type IImageToText, type IOutpaint, type IOutputFormat, type IOutputType, type IPromptEnhancer, type IProviderSettings, type IRefiner, type IRemoveImage, type IRemoveImageBackground, type IRequestImage, type IRequestImageToText, type IRequestVideo, type ITextToImage, type IUpscaleGan, type IVideoOutputFormat, type IVideoToImage, type IipAdapter, type ListenerType, type ProviderSettings, type ReconnectingWebsocketProps, type RequireAtLeastOne, type RequireOnlyOne, Runware, type RunwareBaseType, RunwareClient, RunwareServer, SdkType, type TAcceleratorOptions, type TAddModel, type TAddModelBaseType, type TAddModelCheckPoint, type TAddModelControlNet, type TAddModelLora, type TImageMasking, type TImageMaskingResponse, type TImageUpload, type TImageUploadResponse, type TMediaStorage, type TMediaStorageResponse, type TModel, type TModelSearch, type TModelSearchResponse, type TPhotoMaker, type TPhotoMakerResponse, type TPromptWeighting, type TServerError, type TVectorize, type TVectorizeResponse, type UploadImageType };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ declare enum SdkType {
|
|
|
10
10
|
declare enum ETaskType {
|
|
11
11
|
IMAGE_INFERENCE = "imageInference",
|
|
12
12
|
IMAGE_UPLOAD = "imageUpload",
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
UPSCALE = "upscale",
|
|
14
|
+
REMOVE_BACKGROUND = "removeBackground",
|
|
15
15
|
VIDEO_INFERENCE = "videoInference",
|
|
16
16
|
GET_RESPONSE = "getResponse",
|
|
17
17
|
PHOTO_MAKER = "photoMaker",
|
|
@@ -21,7 +21,9 @@ declare enum ETaskType {
|
|
|
21
21
|
PROMPT_ENHANCE = "promptEnhance",
|
|
22
22
|
AUTHENTICATION = "authentication",
|
|
23
23
|
MODEL_UPLOAD = "modelUpload",
|
|
24
|
-
MODEL_SEARCH = "modelSearch"
|
|
24
|
+
MODEL_SEARCH = "modelSearch",
|
|
25
|
+
MEDIA_STORAGE = "mediaStorage",
|
|
26
|
+
VECTORIZE = "vectorize"
|
|
25
27
|
}
|
|
26
28
|
type RunwareBaseType = {
|
|
27
29
|
apiKey: string;
|
|
@@ -39,7 +41,7 @@ interface IAdditionalResponsePayload {
|
|
|
39
41
|
}
|
|
40
42
|
interface IImage {
|
|
41
43
|
taskType: ETaskType;
|
|
42
|
-
imageUUID
|
|
44
|
+
imageUUID?: string;
|
|
43
45
|
inputImageUUID?: string;
|
|
44
46
|
taskUUID: string;
|
|
45
47
|
imageURL?: string;
|
|
@@ -48,6 +50,8 @@ interface IImage {
|
|
|
48
50
|
NSFWContent?: boolean;
|
|
49
51
|
cost?: number;
|
|
50
52
|
seed: number;
|
|
53
|
+
mediaUUID?: string;
|
|
54
|
+
mediaURL?: string;
|
|
51
55
|
}
|
|
52
56
|
interface ITextToImage extends IImage {
|
|
53
57
|
positivePrompt?: string;
|
|
@@ -103,6 +107,7 @@ type IControlNetPreprocess = {
|
|
|
103
107
|
includeCost?: boolean;
|
|
104
108
|
outputQuality?: number;
|
|
105
109
|
customTaskUUID?: string;
|
|
110
|
+
taskUUID?: string;
|
|
106
111
|
retry?: number;
|
|
107
112
|
} & IAdditionalResponsePayload;
|
|
108
113
|
type IControlNet = IControlNetGeneral;
|
|
@@ -201,6 +206,7 @@ interface IRequestImageToText extends IAdditionalResponsePayload {
|
|
|
201
206
|
inputImage?: File | string;
|
|
202
207
|
includeCost?: boolean;
|
|
203
208
|
customTaskUUID?: string;
|
|
209
|
+
taskUUID?: string;
|
|
204
210
|
retry?: number;
|
|
205
211
|
}
|
|
206
212
|
interface IImageToText {
|
|
@@ -211,8 +217,12 @@ interface IImageToText {
|
|
|
211
217
|
}
|
|
212
218
|
interface IRemoveImageBackground extends IRequestImageToText {
|
|
213
219
|
outputType?: IOutputType;
|
|
214
|
-
outputFormat?: IOutputFormat;
|
|
220
|
+
outputFormat?: IOutputFormat | "MP4" | "WEBM" | "MOV";
|
|
215
221
|
model: string;
|
|
222
|
+
inputs?: {
|
|
223
|
+
video?: InputsValue;
|
|
224
|
+
image?: InputsValue;
|
|
225
|
+
};
|
|
216
226
|
settings?: {
|
|
217
227
|
rgba?: number[];
|
|
218
228
|
postProcessMask?: boolean;
|
|
@@ -225,7 +235,10 @@ interface IRemoveImageBackground extends IRequestImageToText {
|
|
|
225
235
|
includeCost?: boolean;
|
|
226
236
|
outputQuality?: number;
|
|
227
237
|
retry?: number;
|
|
238
|
+
skipResponse?: boolean;
|
|
239
|
+
deliveryMethod?: string;
|
|
228
240
|
}
|
|
241
|
+
type InputsValue = string | Record<string, unknown>;
|
|
229
242
|
interface IRequestVideo extends IRequestImageToText {
|
|
230
243
|
outputType?: IOutputType;
|
|
231
244
|
outputFormat?: IVideoOutputFormat;
|
|
@@ -233,7 +246,7 @@ interface IRequestVideo extends IRequestImageToText {
|
|
|
233
246
|
uploadEndpoint?: string;
|
|
234
247
|
checkNSFW?: boolean;
|
|
235
248
|
includeCost?: boolean;
|
|
236
|
-
positivePrompt
|
|
249
|
+
positivePrompt?: string;
|
|
237
250
|
negativePrompt?: string;
|
|
238
251
|
model: string;
|
|
239
252
|
steps?: number;
|
|
@@ -245,6 +258,22 @@ interface IRequestVideo extends IRequestImageToText {
|
|
|
245
258
|
height?: number;
|
|
246
259
|
numberResults?: number;
|
|
247
260
|
inputAudios?: string[];
|
|
261
|
+
referenceVideos?: string[];
|
|
262
|
+
inputs?: {
|
|
263
|
+
image?: InputsValue;
|
|
264
|
+
images?: InputsValue[];
|
|
265
|
+
audio?: InputsValue;
|
|
266
|
+
audios?: InputsValue[];
|
|
267
|
+
mask?: InputsValue[];
|
|
268
|
+
reference?: InputsValue;
|
|
269
|
+
references?: InputsValue[];
|
|
270
|
+
} & {
|
|
271
|
+
[key: string]: unknown;
|
|
272
|
+
};
|
|
273
|
+
speech?: {
|
|
274
|
+
voice: string;
|
|
275
|
+
text: string;
|
|
276
|
+
};
|
|
248
277
|
skipResponse?: boolean;
|
|
249
278
|
customTaskUUID?: string;
|
|
250
279
|
retry?: number;
|
|
@@ -257,7 +286,10 @@ interface IAsyncResults {
|
|
|
257
286
|
interface IRemoveImage {
|
|
258
287
|
taskType: ETaskType;
|
|
259
288
|
taskUUID: string;
|
|
260
|
-
imageUUID
|
|
289
|
+
imageUUID?: string;
|
|
290
|
+
mediaUUID?: string;
|
|
291
|
+
mediaURL?: string;
|
|
292
|
+
videoUUID?: string;
|
|
261
293
|
inputImageUUID: string;
|
|
262
294
|
imageURL?: string;
|
|
263
295
|
imageBase64Data?: string;
|
|
@@ -270,19 +302,30 @@ interface IPromptEnhancer extends IAdditionalResponsePayload {
|
|
|
270
302
|
prompt: string;
|
|
271
303
|
includeCost?: boolean;
|
|
272
304
|
customTaskUUID?: string;
|
|
305
|
+
taskUUID?: string;
|
|
273
306
|
retry?: number;
|
|
274
307
|
}
|
|
275
308
|
interface IEnhancedPrompt extends IImageToText {
|
|
276
309
|
}
|
|
277
310
|
interface IUpscaleGan extends IAdditionalResponsePayload {
|
|
278
|
-
inputImage
|
|
311
|
+
inputImage?: File | string;
|
|
279
312
|
upscaleFactor: number;
|
|
280
313
|
outputType?: IOutputType;
|
|
281
|
-
outputFormat?: IOutputFormat;
|
|
314
|
+
outputFormat?: IOutputFormat | "MP4" | "WEBM" | "MOV";
|
|
282
315
|
includeCost?: boolean;
|
|
283
316
|
outputQuality?: number;
|
|
317
|
+
inputs?: {
|
|
318
|
+
video?: InputsValue;
|
|
319
|
+
image?: InputsValue;
|
|
320
|
+
} & {
|
|
321
|
+
[key: string]: unknown;
|
|
322
|
+
};
|
|
323
|
+
model?: string;
|
|
284
324
|
customTaskUUID?: string;
|
|
325
|
+
taskUUID?: string;
|
|
285
326
|
retry?: number;
|
|
327
|
+
skipResponse?: boolean;
|
|
328
|
+
deliveryMethod?: string;
|
|
286
329
|
}
|
|
287
330
|
type ReconnectingWebsocketProps = {
|
|
288
331
|
addEventListener: (type: string, listener: EventListener, options: any) => void;
|
|
@@ -397,6 +440,7 @@ type TAddModelBaseType = {
|
|
|
397
440
|
comment?: string;
|
|
398
441
|
private: boolean;
|
|
399
442
|
customTaskUUID?: string;
|
|
443
|
+
taskUUID?: string;
|
|
400
444
|
retry?: number;
|
|
401
445
|
onUploadStream?: (response?: IAddModelResponse, error?: IErrorResponse) => void;
|
|
402
446
|
};
|
|
@@ -440,6 +484,7 @@ type TPhotoMaker = {
|
|
|
440
484
|
includeCost?: boolean;
|
|
441
485
|
outputQuality?: number;
|
|
442
486
|
customTaskUUID?: string;
|
|
487
|
+
taskUUID?: string;
|
|
443
488
|
retry?: number;
|
|
444
489
|
onPartialImages?: (images: IImage[], error?: IError) => void;
|
|
445
490
|
} & IAdditionalResponsePayload;
|
|
@@ -572,11 +617,39 @@ type TImageMasking = {
|
|
|
572
617
|
customTaskUUID?: string;
|
|
573
618
|
retry?: number;
|
|
574
619
|
};
|
|
620
|
+
type TVectorize = {
|
|
621
|
+
model: string;
|
|
622
|
+
outputFormat?: string;
|
|
623
|
+
outputType?: string;
|
|
624
|
+
includeCost?: boolean;
|
|
625
|
+
inputs: {
|
|
626
|
+
image: string;
|
|
627
|
+
};
|
|
628
|
+
customTaskUUID?: string;
|
|
629
|
+
retry?: number;
|
|
630
|
+
};
|
|
631
|
+
type TVectorizeResponse = {
|
|
632
|
+
taskType: string;
|
|
633
|
+
taskUUID: string;
|
|
634
|
+
cost: number;
|
|
635
|
+
imageURL: string;
|
|
636
|
+
};
|
|
575
637
|
type TImageUpload = {
|
|
576
638
|
image: string;
|
|
577
639
|
customTaskUUID?: string;
|
|
578
640
|
retry?: number;
|
|
579
641
|
};
|
|
642
|
+
type TMediaStorage = {
|
|
643
|
+
media: string;
|
|
644
|
+
operation?: string;
|
|
645
|
+
customTaskUUID?: string;
|
|
646
|
+
retry?: number;
|
|
647
|
+
};
|
|
648
|
+
type TMediaStorageResponse = {
|
|
649
|
+
taskType: string;
|
|
650
|
+
taskUUID: string;
|
|
651
|
+
mediaUUID: string;
|
|
652
|
+
};
|
|
580
653
|
type TImageUploadResponse = {
|
|
581
654
|
image: string;
|
|
582
655
|
taskUUID: string;
|
|
@@ -624,6 +697,14 @@ declare class RunwareBase {
|
|
|
624
697
|
_timeoutDuration: number;
|
|
625
698
|
ensureConnectionUUID: string | null;
|
|
626
699
|
constructor({ apiKey, url, shouldReconnect, globalMaxRetries, timeoutDuration, }: RunwareBaseType);
|
|
700
|
+
private getResultUUID;
|
|
701
|
+
/**
|
|
702
|
+
* Shared polling logic for async results.
|
|
703
|
+
* @param taskUUID - The task UUID to poll for.
|
|
704
|
+
* @param numberResults - Number of results expected.
|
|
705
|
+
* @returns Promise resolving to array of results.
|
|
706
|
+
*/
|
|
707
|
+
private pollForAsyncResults;
|
|
627
708
|
static initialize(props: RunwareBaseType): Promise<RunwareBase>;
|
|
628
709
|
protected isWebsocketReadyState: () => boolean;
|
|
629
710
|
protected isInvalidAPIKey: () => boolean;
|
|
@@ -641,19 +722,45 @@ declare class RunwareBase {
|
|
|
641
722
|
private listenToImages;
|
|
642
723
|
private listenToUpload;
|
|
643
724
|
private globalListener;
|
|
644
|
-
requestImages({ outputType, outputFormat, uploadEndpoint, checkNSFW, positivePrompt, negativePrompt, seedImage, maskImage, strength, height, width, model, steps, scheduler, seed, CFGScale, clipSkip, usePromptWeighting, promptWeighting, numberResults, onPartialImages, includeCost, customTaskUUID, retry, refiner, maskMargin, outputQuality, controlNet, lora, embeddings, ipAdapters, providerSettings, outpaint, acceleratorOptions, advancedFeatures, referenceImages, includeGenerationTime, includePayload, ...rest }: IRequestImage, moreOptions?: Record<string, any>): Promise<ITextToImage[] | undefined>;
|
|
645
|
-
|
|
646
|
-
|
|
725
|
+
requestImages({ outputType, outputFormat, uploadEndpoint, checkNSFW, positivePrompt, negativePrompt, seedImage, maskImage, strength, height, width, model, steps, scheduler, seed, CFGScale, clipSkip, usePromptWeighting, promptWeighting, numberResults, onPartialImages, includeCost, customTaskUUID, taskUUID: _taskUUID, retry, refiner, maskMargin, outputQuality, controlNet, lora, embeddings, ipAdapters, providerSettings, outpaint, acceleratorOptions, advancedFeatures, referenceImages, includeGenerationTime, includePayload, ...rest }: IRequestImage, moreOptions?: Record<string, any>): Promise<ITextToImage[] | undefined>;
|
|
726
|
+
imageInference(params: IRequestImage, moreOptions?: Record<string, any>): Promise<ITextToImage[] | undefined>;
|
|
727
|
+
controlNetPreProcess: ({ inputImage, preProcessorType, height, width, outputType, outputFormat, highThresholdCanny, lowThresholdCanny, includeHandsAndFaceOpenPose, includeCost, outputQuality, customTaskUUID, taskUUID: _taskUUID, retry, includeGenerationTime, includePayload, }: IControlNetPreprocess) => Promise<IControlNetImage | null>;
|
|
728
|
+
controlNetPreprocess: (params: IControlNetPreprocess) => Promise<IControlNetImage | null>;
|
|
729
|
+
requestImageToText: ({ inputImage, includeCost, customTaskUUID, taskUUID: _taskUUID, retry, includePayload, includeGenerationTime, }: IRequestImageToText) => Promise<IImageToText>;
|
|
730
|
+
caption: (params: IRequestImageToText) => Promise<IImageToText>;
|
|
731
|
+
/**
|
|
732
|
+
* Remove the background from an image or video.
|
|
733
|
+
* @remark This method now supports the removeBackground type which can handle multiple media types such as image and video.
|
|
734
|
+
* If you pass an `inputs` object with `inputs.image` or `inputs.video`, the response will contain `mediaUUID` and `mediaURL`.
|
|
735
|
+
* If you pass `inputImage`, the response will contain `imageUUID` and `imageURL`.
|
|
736
|
+
* @remark `imageUUID` is no longer guaranteed in the response. Use `mediaUUID` for new implementations.
|
|
737
|
+
* @since 1.2.0
|
|
738
|
+
* @returns {Promise<IRemoveImage>} If called with `inputs.image` or `inputs.video`, returns an object with `mediaUUID` and `mediaURL`. If called with `inputImage`, returns an object with `imageUUID` and `imageURL` (not guaranteed).
|
|
739
|
+
*/
|
|
647
740
|
removeImageBackground: (payload: IRemoveImageBackground) => Promise<IRemoveImage>;
|
|
741
|
+
removeBackground: (payload: IRemoveImageBackground) => Promise<IRemoveImage>;
|
|
742
|
+
vectorize: (payload: TVectorize) => Promise<TVectorizeResponse>;
|
|
648
743
|
videoInference: (payload: IRequestVideo) => Promise<IVideoToImage[] | IVideoToImage>;
|
|
649
|
-
getResponse: (payload: IAsyncResults) => Promise<
|
|
650
|
-
|
|
651
|
-
|
|
744
|
+
getResponse: <T>(payload: IAsyncResults) => Promise<T[]>;
|
|
745
|
+
/**
|
|
746
|
+
* Upscale an image or video
|
|
747
|
+
* @remark This method now supports the upscale type which can handle multiple media types such as image and video.
|
|
748
|
+
* If you pass an `inputs` object with `inputs.image` or `inputs.video`, the response will contain `mediaUUID` and `mediaURL`.
|
|
749
|
+
* If you pass `inputImage`, the response will contain `imageUUID` and `imageURL`.
|
|
750
|
+
* @remark `imageUUID` is no longer guaranteed in the response. Use `mediaUUID` for new implementations.
|
|
751
|
+
* @since 1.2.0
|
|
752
|
+
* @returns {Promise<IImage>} If called with `inputs.image` or `inputs.video`, returns an object with `mediaUUID` and `mediaURL`. If called with `inputImage`, returns an object with `imageUUID` and `imageURL` (not guaranteed).
|
|
753
|
+
*/
|
|
754
|
+
upscaleGan: ({ inputImage, inputs, model, upscaleFactor, outputType, outputFormat, includeCost, outputQuality, customTaskUUID, taskUUID: _taskUUID, retry, includeGenerationTime, includePayload, skipResponse, deliveryMethod }: IUpscaleGan) => Promise<IImage>;
|
|
755
|
+
upscale: (params: IUpscaleGan) => Promise<IImage>;
|
|
756
|
+
enhancePrompt: ({ prompt, promptMaxLength, promptVersions, includeCost, customTaskUUID, taskUUID: _taskUUID, retry, includeGenerationTime, includePayload, }: IPromptEnhancer) => Promise<IEnhancedPrompt[]>;
|
|
757
|
+
promptEnhance: (params: IPromptEnhancer) => Promise<IEnhancedPrompt[]>;
|
|
652
758
|
modelUpload: (payload: TAddModel) => Promise<any>;
|
|
653
759
|
photoMaker: (payload: TPhotoMaker, moreOptions?: Record<string, any>) => Promise<TPhotoMakerResponse[] | undefined>;
|
|
654
760
|
modelSearch: (payload: TModelSearch) => Promise<TModelSearchResponse>;
|
|
655
761
|
imageMasking: (payload: TImageMasking) => Promise<TImageMaskingResponse>;
|
|
656
762
|
imageUpload: (payload: TImageUpload) => Promise<TImageUploadResponse>;
|
|
763
|
+
mediaStorage: (payload: TMediaStorage) => Promise<TMediaStorageResponse>;
|
|
657
764
|
protected baseSingleRequest: <T>({ payload, debugKey, isMultiple, }: {
|
|
658
765
|
payload: Record<string, any>;
|
|
659
766
|
debugKey: string;
|
|
@@ -689,4 +796,4 @@ declare class RunwareServer extends RunwareBase {
|
|
|
689
796
|
|
|
690
797
|
declare let Runware: typeof RunwareClient | typeof RunwareServer;
|
|
691
798
|
|
|
692
|
-
export { EControlMode, EModelArchitecture, EModelConditioning, EModelFormat, EModelType, EOpenPosePreProcessor, EPhotoMakerEnum, EPreProcessor, EPreProcessorGroup, ETaskType, Environment, type GetWithPromiseAsyncCallBackType, type GetWithPromiseCallBackType, type IAddModelResponse, type IAdditionalResponsePayload, type IAsyncResults, type IBflProviderSettings, type IControlNet, type IControlNetGeneral, type IControlNetImage, type IControlNetPreprocess, type IControlNetWithUUID, type IEmbedding, type IEnhancedPrompt, type IError, type IErrorResponse, type IImage, type IImageToText, type IOutpaint, type IOutputFormat, type IOutputType, type IPromptEnhancer, type IProviderSettings, type IRefiner, type IRemoveImage, type IRemoveImageBackground, type IRequestImage, type IRequestImageToText, type IRequestVideo, type ITextToImage, type IUpscaleGan, type IVideoOutputFormat, type IVideoToImage, type IipAdapter, type ListenerType, type ProviderSettings, type ReconnectingWebsocketProps, type RequireAtLeastOne, type RequireOnlyOne, Runware, type RunwareBaseType, RunwareClient, RunwareServer, SdkType, type TAcceleratorOptions, type TAddModel, type TAddModelBaseType, type TAddModelCheckPoint, type TAddModelControlNet, type TAddModelLora, type TImageMasking, type TImageMaskingResponse, type TImageUpload, type TImageUploadResponse, type TModel, type TModelSearch, type TModelSearchResponse, type TPhotoMaker, type TPhotoMakerResponse, type TPromptWeighting, type TServerError, type UploadImageType };
|
|
799
|
+
export { EControlMode, EModelArchitecture, EModelConditioning, EModelFormat, EModelType, EOpenPosePreProcessor, EPhotoMakerEnum, EPreProcessor, EPreProcessorGroup, ETaskType, Environment, type GetWithPromiseAsyncCallBackType, type GetWithPromiseCallBackType, type IAddModelResponse, type IAdditionalResponsePayload, type IAsyncResults, type IBflProviderSettings, type IControlNet, type IControlNetGeneral, type IControlNetImage, type IControlNetPreprocess, type IControlNetWithUUID, type IEmbedding, type IEnhancedPrompt, type IError, type IErrorResponse, type IImage, type IImageToText, type IOutpaint, type IOutputFormat, type IOutputType, type IPromptEnhancer, type IProviderSettings, type IRefiner, type IRemoveImage, type IRemoveImageBackground, type IRequestImage, type IRequestImageToText, type IRequestVideo, type ITextToImage, type IUpscaleGan, type IVideoOutputFormat, type IVideoToImage, type IipAdapter, type ListenerType, type ProviderSettings, type ReconnectingWebsocketProps, type RequireAtLeastOne, type RequireOnlyOne, Runware, type RunwareBaseType, RunwareClient, RunwareServer, SdkType, type TAcceleratorOptions, type TAddModel, type TAddModelBaseType, type TAddModelCheckPoint, type TAddModelControlNet, type TAddModelLora, type TImageMasking, type TImageMaskingResponse, type TImageUpload, type TImageUploadResponse, type TMediaStorage, type TMediaStorageResponse, type TModel, type TModelSearch, type TModelSearchResponse, type TPhotoMaker, type TPhotoMakerResponse, type TPromptWeighting, type TServerError, type TVectorize, type TVectorizeResponse, type UploadImageType };
|