@runware/sdk-js 1.0.27 → 1.0.28

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.d.mts CHANGED
@@ -16,6 +16,8 @@ interface IImage {
16
16
  imageUUID: string;
17
17
  taskUUID: string;
18
18
  bNSFWContent: boolean;
19
+ cost: number;
20
+ imageBase64Data?: string;
19
21
  }
20
22
  interface ILora {
21
23
  modelId: string | number;
@@ -34,16 +36,19 @@ type IControlNetGeneral = {
34
36
  guideImage: string | File;
35
37
  guideImageUnprocessed: string | File;
36
38
  controlMode: EControlMode;
39
+ returnBase64Image?: boolean;
37
40
  };
38
41
  type IControlNetA = RequireOnlyOne<IControlNetGeneral, "guideImage" | "guideImageUnprocessed">;
39
42
  type IControlNetCanny = IControlNetA & {
40
43
  preprocessor: "canny";
41
44
  lowThresholdCanny: Number;
42
45
  highThresholdCanny: Number;
46
+ returnBase64Image?: boolean;
43
47
  };
44
48
  type IControlNetHandsAndFace = IControlNetA & {
45
49
  preprocessor: keyof typeof EOpenPosePreProcessor;
46
50
  includeHandsAndFaceOpenPose: boolean;
51
+ returnBase64Image?: boolean;
47
52
  };
48
53
  type IControlNet = IControlNetCanny | IControlNetA | IControlNetHandsAndFace;
49
54
  type IControlNetWithUUID = Omit<IControlNet, "guideImage"> & {
@@ -70,6 +75,8 @@ interface IRequestImage {
70
75
  seed?: number;
71
76
  gScale?: number;
72
77
  checkNsfw?: boolean;
78
+ returnBase64Image?: boolean;
79
+ scheduler?: string;
73
80
  }
74
81
  interface IRequestImageToText {
75
82
  imageInitiator?: File | string;
@@ -92,6 +99,7 @@ interface IUpscaleGan {
92
99
  imageInitiator: File | string;
93
100
  upscaleFactor: number;
94
101
  isImageUUID?: boolean;
102
+ returnBase64Image?: boolean;
95
103
  }
96
104
  type ReconnectingWebsocketProps = {
97
105
  addEventListener: (type: string, listener: EventListener, options: any) => void;
@@ -212,7 +220,7 @@ declare class RunwareBase {
212
220
  }): {
213
221
  destroy: () => void;
214
222
  };
215
- requestImages({ modelId, positivePrompt, imageSize, negativePrompt, numberOfImages, useCache, imageInitiator, controlNet, imageMaskInitiator, steps, onPartialImages, lora, seed, gScale, checkNsfw, }: IRequestImage): Promise<IImage[] | undefined>;
223
+ requestImages({ modelId, positivePrompt, imageSize, negativePrompt, numberOfImages, useCache, imageInitiator, controlNet, imageMaskInitiator, steps, onPartialImages, lora, seed, gScale, checkNsfw, returnBase64Image, scheduler, }: IRequestImage): Promise<IImage[] | undefined>;
216
224
  handleIncompleteImages({ taskUUIDs, error, }: {
217
225
  taskUUIDs: string[];
218
226
  error: any;
package/dist/index.d.ts CHANGED
@@ -16,6 +16,8 @@ interface IImage {
16
16
  imageUUID: string;
17
17
  taskUUID: string;
18
18
  bNSFWContent: boolean;
19
+ cost: number;
20
+ imageBase64Data?: string;
19
21
  }
20
22
  interface ILora {
21
23
  modelId: string | number;
@@ -34,16 +36,19 @@ type IControlNetGeneral = {
34
36
  guideImage: string | File;
35
37
  guideImageUnprocessed: string | File;
36
38
  controlMode: EControlMode;
39
+ returnBase64Image?: boolean;
37
40
  };
38
41
  type IControlNetA = RequireOnlyOne<IControlNetGeneral, "guideImage" | "guideImageUnprocessed">;
39
42
  type IControlNetCanny = IControlNetA & {
40
43
  preprocessor: "canny";
41
44
  lowThresholdCanny: Number;
42
45
  highThresholdCanny: Number;
46
+ returnBase64Image?: boolean;
43
47
  };
44
48
  type IControlNetHandsAndFace = IControlNetA & {
45
49
  preprocessor: keyof typeof EOpenPosePreProcessor;
46
50
  includeHandsAndFaceOpenPose: boolean;
51
+ returnBase64Image?: boolean;
47
52
  };
48
53
  type IControlNet = IControlNetCanny | IControlNetA | IControlNetHandsAndFace;
49
54
  type IControlNetWithUUID = Omit<IControlNet, "guideImage"> & {
@@ -70,6 +75,8 @@ interface IRequestImage {
70
75
  seed?: number;
71
76
  gScale?: number;
72
77
  checkNsfw?: boolean;
78
+ returnBase64Image?: boolean;
79
+ scheduler?: string;
73
80
  }
74
81
  interface IRequestImageToText {
75
82
  imageInitiator?: File | string;
@@ -92,6 +99,7 @@ interface IUpscaleGan {
92
99
  imageInitiator: File | string;
93
100
  upscaleFactor: number;
94
101
  isImageUUID?: boolean;
102
+ returnBase64Image?: boolean;
95
103
  }
96
104
  type ReconnectingWebsocketProps = {
97
105
  addEventListener: (type: string, listener: EventListener, options: any) => void;
@@ -212,7 +220,7 @@ declare class RunwareBase {
212
220
  }): {
213
221
  destroy: () => void;
214
222
  };
215
- requestImages({ modelId, positivePrompt, imageSize, negativePrompt, numberOfImages, useCache, imageInitiator, controlNet, imageMaskInitiator, steps, onPartialImages, lora, seed, gScale, checkNsfw, }: IRequestImage): Promise<IImage[] | undefined>;
223
+ requestImages({ modelId, positivePrompt, imageSize, negativePrompt, numberOfImages, useCache, imageInitiator, controlNet, imageMaskInitiator, steps, onPartialImages, lora, seed, gScale, checkNsfw, returnBase64Image, scheduler, }: IRequestImage): Promise<IImage[] | undefined>;
216
224
  handleIncompleteImages({ taskUUIDs, error, }: {
217
225
  taskUUIDs: string[];
218
226
  error: any;
package/dist/index.js CHANGED
@@ -562,7 +562,8 @@ var RunwareBase = class {
562
562
  height,
563
563
  lowThresholdCanny,
564
564
  highThresholdCanny,
565
- includeHandsAndFaceOpenPose = true
565
+ includeHandsAndFaceOpenPose = true,
566
+ returnBase64Image
566
567
  }) => {
567
568
  try {
568
569
  const image = await this.uploadImage(file);
@@ -570,12 +571,12 @@ var RunwareBase = class {
570
571
  return null;
571
572
  const taskUUID = getUUID();
572
573
  this.send({
573
- newPreProcessControlNet: __spreadValues(__spreadValues({
574
+ newPreProcessControlNet: __spreadValues(__spreadValues(__spreadValues({
574
575
  taskUUID,
575
576
  preProcessorType,
576
577
  guideImageUUID: image.newImageUUID,
577
578
  includeHandsAndFaceOpenPose
578
- }, compact(lowThresholdCanny, { lowThresholdCanny })), compact(highThresholdCanny, { highThresholdCanny }))
579
+ }, returnBase64Image ? { returnBase64Image } : {}), compact(lowThresholdCanny, { lowThresholdCanny })), compact(highThresholdCanny, { highThresholdCanny }))
579
580
  });
580
581
  const lis = this.globalListener({
581
582
  responseKey: "newPreProcessControlNet",
@@ -966,7 +967,9 @@ var RunwareBase = class {
966
967
  lora,
967
968
  seed,
968
969
  gScale,
969
- checkNsfw
970
+ checkNsfw,
971
+ returnBase64Image,
972
+ scheduler
970
973
  }) {
971
974
  let lis = void 0;
972
975
  let requestObject = void 0;
@@ -1002,7 +1005,8 @@ var RunwareBase = class {
1002
1005
  weight,
1003
1006
  guideImage,
1004
1007
  guideImageUnprocessed,
1005
- controlMode
1008
+ controlMode,
1009
+ returnBase64Image: returnBase64Image2
1006
1010
  } = controlData;
1007
1011
  const getCannyObject = () => {
1008
1012
  if (controlData.preprocessor === "canny") {
@@ -1013,13 +1017,15 @@ var RunwareBase = class {
1013
1017
  } else
1014
1018
  return {};
1015
1019
  };
1016
- const imageUploaded = await (guideImageUnprocessed ? this.uploadUnprocessedImage(__spreadValues({
1020
+ const imageUploaded = await (guideImageUnprocessed ? this.uploadUnprocessedImage(__spreadProps(__spreadValues({
1017
1021
  file: guideImageUnprocessed,
1018
1022
  preProcessorType: getPreprocessorType(
1019
1023
  preprocessor
1020
1024
  ),
1021
1025
  includeHandsAndFaceOpenPose: anyControlData.includeHandsAndFaceOpenPose
1022
- }, getCannyObject())) : this.uploadImage(guideImage));
1026
+ }, getCannyObject()), {
1027
+ returnBase64Image: returnBase64Image2
1028
+ })) : this.uploadImage(guideImage));
1023
1029
  if (!imageUploaded)
1024
1030
  return [];
1025
1031
  controlNetData.push(__spreadValues({
@@ -1034,7 +1040,7 @@ var RunwareBase = class {
1034
1040
  }
1035
1041
  const prompt = `${positivePrompt} ${negativePrompt ? `-no ${negativePrompt}` : ""}`.trim();
1036
1042
  gScale = gScale != null ? gScale : 7;
1037
- requestObject = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
1043
+ requestObject = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
1038
1044
  offset: 0,
1039
1045
  modelId,
1040
1046
  promptText: prompt,
@@ -1046,9 +1052,8 @@ var RunwareBase = class {
1046
1052
  imageInitiator,
1047
1053
  imageMaskInitiator
1048
1054
  }),
1049
- useCache,
1050
- schedulerId: 22
1051
- }, evaluateNonTrue({ key: "checkNsfw", value: checkNsfw })), evaluateNonTrue({ key: "gScale", value: gScale })), evaluateNonTrue({ key: "steps", value: steps })), imageInitiatorUUID ? { imageInitiatorUUID } : {}), imageMaskInitiatorUUID ? { imageMaskInitiatorUUID } : {}), controlNetData.length ? { controlNet: controlNetData } : {}), (lora == null ? void 0 : lora.length) ? { lora } : {}), seed ? { seed } : {});
1055
+ useCache
1056
+ }, scheduler ? { scheduler } : {}), returnBase64Image ? { returnBase64Image } : {}), evaluateNonTrue({ key: "checkNsfw", value: checkNsfw })), evaluateNonTrue({ key: "gScale", value: gScale })), evaluateNonTrue({ key: "steps", value: steps })), imageInitiatorUUID ? { imageInitiatorUUID } : {}), imageMaskInitiatorUUID ? { imageMaskInitiatorUUID } : {}), controlNetData.length ? { controlNet: controlNetData } : {}), (lora == null ? void 0 : lora.length) ? { lora } : {}), seed ? { seed } : {});
1052
1057
  return await asyncRetry(
1053
1058
  async () => {
1054
1059
  retryCount++;
package/dist/index.mjs CHANGED
@@ -542,7 +542,8 @@ var RunwareBase = class {
542
542
  height,
543
543
  lowThresholdCanny,
544
544
  highThresholdCanny,
545
- includeHandsAndFaceOpenPose = true
545
+ includeHandsAndFaceOpenPose = true,
546
+ returnBase64Image
546
547
  }) => {
547
548
  try {
548
549
  const image = await this.uploadImage(file);
@@ -550,12 +551,12 @@ var RunwareBase = class {
550
551
  return null;
551
552
  const taskUUID = getUUID();
552
553
  this.send({
553
- newPreProcessControlNet: __spreadValues(__spreadValues({
554
+ newPreProcessControlNet: __spreadValues(__spreadValues(__spreadValues({
554
555
  taskUUID,
555
556
  preProcessorType,
556
557
  guideImageUUID: image.newImageUUID,
557
558
  includeHandsAndFaceOpenPose
558
- }, compact(lowThresholdCanny, { lowThresholdCanny })), compact(highThresholdCanny, { highThresholdCanny }))
559
+ }, returnBase64Image ? { returnBase64Image } : {}), compact(lowThresholdCanny, { lowThresholdCanny })), compact(highThresholdCanny, { highThresholdCanny }))
559
560
  });
560
561
  const lis = this.globalListener({
561
562
  responseKey: "newPreProcessControlNet",
@@ -946,7 +947,9 @@ var RunwareBase = class {
946
947
  lora,
947
948
  seed,
948
949
  gScale,
949
- checkNsfw
950
+ checkNsfw,
951
+ returnBase64Image,
952
+ scheduler
950
953
  }) {
951
954
  let lis = void 0;
952
955
  let requestObject = void 0;
@@ -982,7 +985,8 @@ var RunwareBase = class {
982
985
  weight,
983
986
  guideImage,
984
987
  guideImageUnprocessed,
985
- controlMode
988
+ controlMode,
989
+ returnBase64Image: returnBase64Image2
986
990
  } = controlData;
987
991
  const getCannyObject = () => {
988
992
  if (controlData.preprocessor === "canny") {
@@ -993,13 +997,15 @@ var RunwareBase = class {
993
997
  } else
994
998
  return {};
995
999
  };
996
- const imageUploaded = await (guideImageUnprocessed ? this.uploadUnprocessedImage(__spreadValues({
1000
+ const imageUploaded = await (guideImageUnprocessed ? this.uploadUnprocessedImage(__spreadProps(__spreadValues({
997
1001
  file: guideImageUnprocessed,
998
1002
  preProcessorType: getPreprocessorType(
999
1003
  preprocessor
1000
1004
  ),
1001
1005
  includeHandsAndFaceOpenPose: anyControlData.includeHandsAndFaceOpenPose
1002
- }, getCannyObject())) : this.uploadImage(guideImage));
1006
+ }, getCannyObject()), {
1007
+ returnBase64Image: returnBase64Image2
1008
+ })) : this.uploadImage(guideImage));
1003
1009
  if (!imageUploaded)
1004
1010
  return [];
1005
1011
  controlNetData.push(__spreadValues({
@@ -1014,7 +1020,7 @@ var RunwareBase = class {
1014
1020
  }
1015
1021
  const prompt = `${positivePrompt} ${negativePrompt ? `-no ${negativePrompt}` : ""}`.trim();
1016
1022
  gScale = gScale != null ? gScale : 7;
1017
- requestObject = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
1023
+ requestObject = __spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({
1018
1024
  offset: 0,
1019
1025
  modelId,
1020
1026
  promptText: prompt,
@@ -1026,9 +1032,8 @@ var RunwareBase = class {
1026
1032
  imageInitiator,
1027
1033
  imageMaskInitiator
1028
1034
  }),
1029
- useCache,
1030
- schedulerId: 22
1031
- }, evaluateNonTrue({ key: "checkNsfw", value: checkNsfw })), evaluateNonTrue({ key: "gScale", value: gScale })), evaluateNonTrue({ key: "steps", value: steps })), imageInitiatorUUID ? { imageInitiatorUUID } : {}), imageMaskInitiatorUUID ? { imageMaskInitiatorUUID } : {}), controlNetData.length ? { controlNet: controlNetData } : {}), (lora == null ? void 0 : lora.length) ? { lora } : {}), seed ? { seed } : {});
1035
+ useCache
1036
+ }, scheduler ? { scheduler } : {}), returnBase64Image ? { returnBase64Image } : {}), evaluateNonTrue({ key: "checkNsfw", value: checkNsfw })), evaluateNonTrue({ key: "gScale", value: gScale })), evaluateNonTrue({ key: "steps", value: steps })), imageInitiatorUUID ? { imageInitiatorUUID } : {}), imageMaskInitiatorUUID ? { imageMaskInitiatorUUID } : {}), controlNetData.length ? { controlNet: controlNetData } : {}), (lora == null ? void 0 : lora.length) ? { lora } : {}), seed ? { seed } : {});
1032
1037
  return await asyncRetry(
1033
1038
  async () => {
1034
1039
  retryCount++;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runware/sdk-js",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "description": "The SDK is used to run image inference with the Runware API, powered by the RunWare inference platform. It can be used to generate imaged with text-to-image and image-to-image. It also allows the use of an existing gallery of models or selecting any model or LoRA from the CivitAI gallery. The API also supports upscaling, background removal, inpainting and outpainting, and a series of other ControlNet models.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/readme.md CHANGED
@@ -57,6 +57,7 @@ const images = await runware.requestImages({
57
57
  imageInitiator?: File | string;
58
58
  imageMaskInitiator?: File | string;
59
59
  steps?: number;
60
+ returnBase64Image?: boolean;
60
61
  onPartialImages?: (images: IImage[], error: IError) => void;
61
62
  })
62
63
  console.log(images)
@@ -66,6 +67,7 @@ return interface IImage {
66
67
  imageUUID: string;
67
68
  taskUUID: string;
68
69
  bNSFWContent: boolean;
70
+ cost: string;
69
71
  }[]
70
72
  ```
71
73
 
@@ -116,7 +118,7 @@ return interface IImage {
116
118
  | controlNet | IControlNet[]: `(Optional)` | If provided, should be an array of objects. Each object must have five attributes: |
117
119
  | imageInitiator | string or File: `(Optional)` | The image to be used as the seed image. It can be the UUID of previously generated image, or an image from a file. |
118
120
  | imageMaskInitiator | string or File: `(Optional)` | The image to be used as the mask image. It can be the UUID of previously generated image, or an image from a file. |
119
- | steps | number: `(Optional)` | The steps required to generate the image. |
121
+ | returnBase64Image | boolean: `(Optional)` | Returns base64 image. |
120
122
  | onPartialImages | function: `(Optional)` | If you want to receive the images as they are generated instead of waiting for the async request, you get the images as they are generated from this function. |
121
123
 
122
124
  ##### ControlNet Params
@@ -240,6 +242,13 @@ return interface IEnhancedPrompt {
240
242
 
241
243
  ## Changelog
242
244
 
245
+ ### - v1.0.28
246
+
247
+ **Added or Changed**
248
+
249
+ - Added cost to response.
250
+ - Added returnBase64Image as part of request object.
251
+
243
252
  ### - v1.0.27
244
253
 
245
254
  **Added or Changed**