@runware/sdk-js 1.2.4 → 1.2.5-beta.2
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 +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +127 -14
- package/dist/index.d.ts +127 -14
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/readme.md +5 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runware SDK Telemetry Logger
|
|
3
|
+
*
|
|
4
|
+
* Beautiful colored console output for debugging SDK internals.
|
|
5
|
+
* Only active when `enableLogging: true` is passed during instantiation.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const runware = new RunwareServer({ apiKey: "...", enableLogging: true });
|
|
9
|
+
*/
|
|
10
|
+
declare enum LogLevel {
|
|
11
|
+
CONNECTION = "CONNECTION",
|
|
12
|
+
AUTH = "AUTH",
|
|
13
|
+
HEARTBEAT = "HEARTBEAT",
|
|
14
|
+
SEND = "SEND",
|
|
15
|
+
RECEIVE = "RECEIVE",
|
|
16
|
+
RETRY = "RETRY",
|
|
17
|
+
REQUEST = "REQUEST",
|
|
18
|
+
ERROR = "ERROR",
|
|
19
|
+
WARN = "WARN",
|
|
20
|
+
INFO = "INFO"
|
|
21
|
+
}
|
|
22
|
+
declare class RunwareLogger {
|
|
23
|
+
private enabled;
|
|
24
|
+
constructor(enabled?: boolean);
|
|
25
|
+
private log;
|
|
26
|
+
connecting(url: string): void;
|
|
27
|
+
connected(sessionUUID: string): void;
|
|
28
|
+
reconnecting(attempt: number): void;
|
|
29
|
+
reconnectScheduled(delayMs: number): void;
|
|
30
|
+
disconnected(reason?: string): void;
|
|
31
|
+
connectionClosed(code?: number): void;
|
|
32
|
+
connectionError(error?: any): void;
|
|
33
|
+
ensureConnectionStart(): void;
|
|
34
|
+
ensureConnectionSuccess(): void;
|
|
35
|
+
ensureConnectionTimeout(): void;
|
|
36
|
+
authenticating(hasSession: boolean): void;
|
|
37
|
+
authenticated(sessionUUID: string): void;
|
|
38
|
+
authError(error: any): void;
|
|
39
|
+
heartbeatStarted(intervalMs: number): void;
|
|
40
|
+
heartbeatPingSent(): void;
|
|
41
|
+
heartbeatPongReceived(): void;
|
|
42
|
+
heartbeatPongMissed(count: number, max: number): void;
|
|
43
|
+
heartbeatStopped(): void;
|
|
44
|
+
messageSent(taskType: string, taskUUID?: string): void;
|
|
45
|
+
messageReceived(taskType?: string, taskUUID?: string): void;
|
|
46
|
+
sendReconnecting(): void;
|
|
47
|
+
sendFailed(error: string): void;
|
|
48
|
+
requestStart(taskType: string, taskUUID: string): void;
|
|
49
|
+
requestComplete(taskType: string, taskUUID: string, durationMs: number): void;
|
|
50
|
+
requestTimeout(taskUUID: string, timeoutMs: number): void;
|
|
51
|
+
requestError(taskUUID: string, error: any): void;
|
|
52
|
+
retryAttempt(attempt: number, maxRetries: number, delayMs: number): void;
|
|
53
|
+
retrySuccess(attempt: number): void;
|
|
54
|
+
retryExhausted(maxRetries: number): void;
|
|
55
|
+
retrySkippedApiError(code: string): void;
|
|
56
|
+
info(message: string, data?: any): void;
|
|
57
|
+
warn(message: string, data?: any): void;
|
|
58
|
+
error(message: string, data?: any): void;
|
|
59
|
+
}
|
|
60
|
+
declare function createLogger(enabled: boolean): RunwareLogger;
|
|
61
|
+
|
|
1
62
|
declare enum Environment {
|
|
2
63
|
PRODUCTION = "PRODUCTION",
|
|
3
64
|
DEVELOPMENT = "DEVELOPMENT",
|
|
@@ -25,7 +86,8 @@ declare enum ETaskType {
|
|
|
25
86
|
MODEL_UPLOAD = "modelUpload",
|
|
26
87
|
MODEL_SEARCH = "modelSearch",
|
|
27
88
|
MEDIA_STORAGE = "mediaStorage",
|
|
28
|
-
VECTORIZE = "vectorize"
|
|
89
|
+
VECTORIZE = "vectorize",
|
|
90
|
+
TEXT_INFERENCE = "textInference"
|
|
29
91
|
}
|
|
30
92
|
type RunwareBaseType = {
|
|
31
93
|
apiKey: string;
|
|
@@ -33,6 +95,8 @@ type RunwareBaseType = {
|
|
|
33
95
|
shouldReconnect?: boolean;
|
|
34
96
|
globalMaxRetries?: number;
|
|
35
97
|
timeoutDuration?: number;
|
|
98
|
+
heartbeatInterval?: number;
|
|
99
|
+
enableLogging?: boolean;
|
|
36
100
|
};
|
|
37
101
|
type IOutputType = "base64Data" | "dataURI" | "URL";
|
|
38
102
|
type IOutputFormat = "JPG" | "PNG" | "WEBP";
|
|
@@ -136,9 +200,7 @@ type IControlNetWithUUID = Omit<IControlNet, "guideImage"> & {
|
|
|
136
200
|
guideImage?: string;
|
|
137
201
|
};
|
|
138
202
|
interface IError {
|
|
139
|
-
error:
|
|
140
|
-
errorMessage: string;
|
|
141
|
-
taskUUID: string;
|
|
203
|
+
error: IErrorResponse;
|
|
142
204
|
}
|
|
143
205
|
type TPromptWeighting = "compel" | "sdEmbeds";
|
|
144
206
|
interface IRequestImage extends IAdditionalResponsePayload {
|
|
@@ -303,6 +365,8 @@ interface IRequestVideo extends IRequestImageToText {
|
|
|
303
365
|
speech?: {
|
|
304
366
|
voice: string;
|
|
305
367
|
text: string;
|
|
368
|
+
} & {
|
|
369
|
+
[key: string]: unknown;
|
|
306
370
|
};
|
|
307
371
|
skipResponse?: boolean;
|
|
308
372
|
customTaskUUID?: string;
|
|
@@ -368,6 +432,45 @@ interface IRequestThreeD {
|
|
|
368
432
|
retry?: number;
|
|
369
433
|
[key: string]: unknown;
|
|
370
434
|
}
|
|
435
|
+
interface ITextMessage {
|
|
436
|
+
role: "user" | "assistant";
|
|
437
|
+
content: string;
|
|
438
|
+
}
|
|
439
|
+
interface IRequestTextInference extends IAdditionalResponsePayload {
|
|
440
|
+
model: string;
|
|
441
|
+
messages: ITextMessage[];
|
|
442
|
+
maxTokens?: number;
|
|
443
|
+
temperature?: number;
|
|
444
|
+
topP?: number;
|
|
445
|
+
topK?: number;
|
|
446
|
+
seed?: number;
|
|
447
|
+
stopSequences?: string[];
|
|
448
|
+
systemPrompt?: string;
|
|
449
|
+
outputFormat?: string;
|
|
450
|
+
numberResults?: number;
|
|
451
|
+
includeCost?: boolean;
|
|
452
|
+
onPartialResponse?: (results: IThreeDImage[], error?: IError) => void;
|
|
453
|
+
deliveryMethod?: string;
|
|
454
|
+
taskUUID?: string;
|
|
455
|
+
customTaskUUID?: string;
|
|
456
|
+
skipResponse?: boolean;
|
|
457
|
+
retry?: number;
|
|
458
|
+
[key: string]: unknown;
|
|
459
|
+
}
|
|
460
|
+
interface ITextResponse {
|
|
461
|
+
text: string;
|
|
462
|
+
finishReason: string;
|
|
463
|
+
usage: {
|
|
464
|
+
promptTokens: number;
|
|
465
|
+
completionTokens: number;
|
|
466
|
+
totalTokens: number;
|
|
467
|
+
thinkingTokens: number;
|
|
468
|
+
};
|
|
469
|
+
thoughtSignature: string;
|
|
470
|
+
cost: number;
|
|
471
|
+
taskUUID: string;
|
|
472
|
+
status: string;
|
|
473
|
+
}
|
|
371
474
|
interface IAsyncResults {
|
|
372
475
|
taskUUID: string;
|
|
373
476
|
onPartialImages?: (images: IImage[], error?: IError) => void;
|
|
@@ -777,10 +880,12 @@ type MediaUUID = {
|
|
|
777
880
|
imageUUID?: string;
|
|
778
881
|
videoUUID?: string;
|
|
779
882
|
outputs?: TOutputFiles;
|
|
883
|
+
text?: string;
|
|
780
884
|
};
|
|
781
885
|
|
|
782
886
|
declare enum LISTEN_TO_MEDIA_KEY {
|
|
783
887
|
REQUEST_IMAGES = "REQUEST_IMAGES",
|
|
888
|
+
REQUEST_TEXT = "REQUEST_TEXT",
|
|
784
889
|
REQUEST_AUDIO = "REQUEST_AUDIO"
|
|
785
890
|
}
|
|
786
891
|
|
|
@@ -791,15 +896,21 @@ declare class RunwareBase {
|
|
|
791
896
|
_url?: string;
|
|
792
897
|
_globalMessages: Record<string, any>;
|
|
793
898
|
_globalImages: IImage[];
|
|
794
|
-
|
|
899
|
+
_globalErrors: IError[];
|
|
795
900
|
_connectionSessionUUID: string | undefined;
|
|
796
901
|
_connectionError: TServerError | undefined;
|
|
797
902
|
_sdkType: SdkType;
|
|
798
903
|
_shouldReconnect: boolean;
|
|
799
904
|
_globalMaxRetries: number;
|
|
800
905
|
_timeoutDuration: number;
|
|
906
|
+
_heartbeatIntervalId: any;
|
|
907
|
+
_pongTimeoutId: any;
|
|
908
|
+
_heartbeatInterval: number;
|
|
909
|
+
_missedPongCount: number;
|
|
910
|
+
_maxMissedPongs: number;
|
|
801
911
|
ensureConnectionUUID: string | null;
|
|
802
|
-
|
|
912
|
+
_logger: RunwareLogger;
|
|
913
|
+
constructor({ apiKey, url, shouldReconnect, globalMaxRetries, timeoutDuration, heartbeatInterval, enableLogging, }: RunwareBaseType);
|
|
803
914
|
private getUniqueUUID;
|
|
804
915
|
/**
|
|
805
916
|
* Shared polling logic for async results.
|
|
@@ -811,6 +922,9 @@ declare class RunwareBase {
|
|
|
811
922
|
static initialize(props: RunwareBaseType): Promise<RunwareBase>;
|
|
812
923
|
protected isWebsocketReadyState: () => boolean;
|
|
813
924
|
protected isInvalidAPIKey: () => boolean;
|
|
925
|
+
protected startHeartbeat(): void;
|
|
926
|
+
protected stopHeartbeat(): void;
|
|
927
|
+
protected handlePongMessage(data: any): boolean;
|
|
814
928
|
protected addListener({ lis, groupKey, taskUUID, }: {
|
|
815
929
|
lis: (v: any) => any;
|
|
816
930
|
groupKey?: string;
|
|
@@ -819,7 +933,7 @@ declare class RunwareBase {
|
|
|
819
933
|
destroy: () => void;
|
|
820
934
|
};
|
|
821
935
|
protected connect(): void;
|
|
822
|
-
protected send: (msg: Object) => void
|
|
936
|
+
protected send: (msg: Object) => Promise<void>;
|
|
823
937
|
private destroy;
|
|
824
938
|
private uploadImage;
|
|
825
939
|
private listenToResponse;
|
|
@@ -846,6 +960,7 @@ declare class RunwareBase {
|
|
|
846
960
|
videoInference: (payload: IRequestVideo) => Promise<IVideoToImage[] | IVideoToImage>;
|
|
847
961
|
audioInference: (payload: IRequestAudio) => Promise<IAudio[] | IAudio>;
|
|
848
962
|
threeDInference: (payload: IRequestThreeD) => Promise<IThreeDImage[] | IThreeDImage>;
|
|
963
|
+
textInference: (payload: IRequestTextInference) => Promise<ITextResponse[] | ITextResponse>;
|
|
849
964
|
getResponse: <T>(payload: IAsyncResults) => Promise<T[]>;
|
|
850
965
|
/**
|
|
851
966
|
* Upscale an image or video
|
|
@@ -856,7 +971,7 @@ declare class RunwareBase {
|
|
|
856
971
|
* @since 1.2.0
|
|
857
972
|
* @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).
|
|
858
973
|
*/
|
|
859
|
-
upscaleGan: ({ inputImage, inputs, model, upscaleFactor, outputType, outputFormat, includeCost, outputQuality, customTaskUUID, taskUUID: _taskUUID, retry, includeGenerationTime, includePayload, skipResponse, deliveryMethod }: IUpscaleGan) => Promise<IImage>;
|
|
974
|
+
upscaleGan: ({ inputImage, inputs, model, upscaleFactor, outputType, outputFormat, includeCost, outputQuality, customTaskUUID, taskUUID: _taskUUID, retry, includeGenerationTime, includePayload, skipResponse, deliveryMethod, }: IUpscaleGan) => Promise<IImage>;
|
|
860
975
|
upscale: (params: IUpscaleGan) => Promise<IImage>;
|
|
861
976
|
enhancePrompt: ({ prompt, promptMaxLength, promptVersions, includeCost, customTaskUUID, taskUUID: _taskUUID, retry, includeGenerationTime, includePayload, }: IPromptEnhancer) => Promise<IEnhancedPrompt[]>;
|
|
862
977
|
promptEnhance: (params: IPromptEnhancer) => Promise<IEnhancedPrompt[]>;
|
|
@@ -871,7 +986,7 @@ declare class RunwareBase {
|
|
|
871
986
|
debugKey: string;
|
|
872
987
|
isMultiple?: boolean | undefined;
|
|
873
988
|
}) => Promise<T>;
|
|
874
|
-
protected baseSyncRequest: <T>({ payload, groupKey, skipResponse }: {
|
|
989
|
+
protected baseSyncRequest: <T>({ payload, groupKey, skipResponse, }: {
|
|
875
990
|
payload: Record<string, any>;
|
|
876
991
|
groupKey: LISTEN_TO_MEDIA_KEY;
|
|
877
992
|
skipResponse?: boolean | undefined;
|
|
@@ -894,16 +1009,14 @@ declare class RunwareServer extends RunwareBase {
|
|
|
894
1009
|
_instantiated: boolean;
|
|
895
1010
|
_listeners: any[];
|
|
896
1011
|
_reconnectingIntervalId: null | any;
|
|
897
|
-
|
|
898
|
-
_pongListener: any;
|
|
1012
|
+
private _connecting;
|
|
899
1013
|
constructor(props: RunwareBaseType);
|
|
900
1014
|
protected connect(): Promise<void>;
|
|
901
|
-
protected send: (msg: Object) => void
|
|
1015
|
+
protected send: (msg: Object) => Promise<void>;
|
|
902
1016
|
protected handleClose(): void;
|
|
903
1017
|
protected resetConnection: () => void;
|
|
904
|
-
protected heartBeat(): void;
|
|
905
1018
|
}
|
|
906
1019
|
|
|
907
1020
|
declare let Runware: typeof RunwareClient | typeof RunwareServer;
|
|
908
1021
|
|
|
909
|
-
export { EControlMode, EModelArchitecture, EModelConditioning, EModelFormat, EModelType, EOpenPosePreProcessor, EPhotoMakerEnum, EPreProcessor, EPreProcessorGroup, ETaskType, Environment, type GetWithPromiseAsyncCallBackType, type GetWithPromiseCallBackType, type IAddModelResponse, type IAdditionalResponsePayload, type IAsyncResults, type IAudio, type IAudioOutputFormat, 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 IRequestAudio, type IRequestImage, type IRequestImageToText, type IRequestThreeD, type IRequestVideo, type ITextToImage, type IThreeDImage, type IThreeDOutputFormat, type IUpscaleGan, type IVideoOutputFormat, type IVideoToImage, type IipAdapter, type ListenerType, type MediaUUID, 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 };
|
|
1022
|
+
export { EControlMode, EModelArchitecture, EModelConditioning, EModelFormat, EModelType, EOpenPosePreProcessor, EPhotoMakerEnum, EPreProcessor, EPreProcessorGroup, ETaskType, Environment, type GetWithPromiseAsyncCallBackType, type GetWithPromiseCallBackType, type IAddModelResponse, type IAdditionalResponsePayload, type IAsyncResults, type IAudio, type IAudioOutputFormat, 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 IRequestAudio, type IRequestImage, type IRequestImageToText, type IRequestTextInference, type IRequestThreeD, type IRequestVideo, type ITextMessage, type ITextResponse, type ITextToImage, type IThreeDImage, type IThreeDOutputFormat, type IUpscaleGan, type IVideoOutputFormat, type IVideoToImage, type IipAdapter, type ListenerType, LogLevel, type MediaUUID, type ProviderSettings, type ReconnectingWebsocketProps, type RequireAtLeastOne, type RequireOnlyOne, Runware, type RunwareBaseType, RunwareClient, RunwareLogger, 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, createLogger };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runware SDK Telemetry Logger
|
|
3
|
+
*
|
|
4
|
+
* Beautiful colored console output for debugging SDK internals.
|
|
5
|
+
* Only active when `enableLogging: true` is passed during instantiation.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* const runware = new RunwareServer({ apiKey: "...", enableLogging: true });
|
|
9
|
+
*/
|
|
10
|
+
declare enum LogLevel {
|
|
11
|
+
CONNECTION = "CONNECTION",
|
|
12
|
+
AUTH = "AUTH",
|
|
13
|
+
HEARTBEAT = "HEARTBEAT",
|
|
14
|
+
SEND = "SEND",
|
|
15
|
+
RECEIVE = "RECEIVE",
|
|
16
|
+
RETRY = "RETRY",
|
|
17
|
+
REQUEST = "REQUEST",
|
|
18
|
+
ERROR = "ERROR",
|
|
19
|
+
WARN = "WARN",
|
|
20
|
+
INFO = "INFO"
|
|
21
|
+
}
|
|
22
|
+
declare class RunwareLogger {
|
|
23
|
+
private enabled;
|
|
24
|
+
constructor(enabled?: boolean);
|
|
25
|
+
private log;
|
|
26
|
+
connecting(url: string): void;
|
|
27
|
+
connected(sessionUUID: string): void;
|
|
28
|
+
reconnecting(attempt: number): void;
|
|
29
|
+
reconnectScheduled(delayMs: number): void;
|
|
30
|
+
disconnected(reason?: string): void;
|
|
31
|
+
connectionClosed(code?: number): void;
|
|
32
|
+
connectionError(error?: any): void;
|
|
33
|
+
ensureConnectionStart(): void;
|
|
34
|
+
ensureConnectionSuccess(): void;
|
|
35
|
+
ensureConnectionTimeout(): void;
|
|
36
|
+
authenticating(hasSession: boolean): void;
|
|
37
|
+
authenticated(sessionUUID: string): void;
|
|
38
|
+
authError(error: any): void;
|
|
39
|
+
heartbeatStarted(intervalMs: number): void;
|
|
40
|
+
heartbeatPingSent(): void;
|
|
41
|
+
heartbeatPongReceived(): void;
|
|
42
|
+
heartbeatPongMissed(count: number, max: number): void;
|
|
43
|
+
heartbeatStopped(): void;
|
|
44
|
+
messageSent(taskType: string, taskUUID?: string): void;
|
|
45
|
+
messageReceived(taskType?: string, taskUUID?: string): void;
|
|
46
|
+
sendReconnecting(): void;
|
|
47
|
+
sendFailed(error: string): void;
|
|
48
|
+
requestStart(taskType: string, taskUUID: string): void;
|
|
49
|
+
requestComplete(taskType: string, taskUUID: string, durationMs: number): void;
|
|
50
|
+
requestTimeout(taskUUID: string, timeoutMs: number): void;
|
|
51
|
+
requestError(taskUUID: string, error: any): void;
|
|
52
|
+
retryAttempt(attempt: number, maxRetries: number, delayMs: number): void;
|
|
53
|
+
retrySuccess(attempt: number): void;
|
|
54
|
+
retryExhausted(maxRetries: number): void;
|
|
55
|
+
retrySkippedApiError(code: string): void;
|
|
56
|
+
info(message: string, data?: any): void;
|
|
57
|
+
warn(message: string, data?: any): void;
|
|
58
|
+
error(message: string, data?: any): void;
|
|
59
|
+
}
|
|
60
|
+
declare function createLogger(enabled: boolean): RunwareLogger;
|
|
61
|
+
|
|
1
62
|
declare enum Environment {
|
|
2
63
|
PRODUCTION = "PRODUCTION",
|
|
3
64
|
DEVELOPMENT = "DEVELOPMENT",
|
|
@@ -25,7 +86,8 @@ declare enum ETaskType {
|
|
|
25
86
|
MODEL_UPLOAD = "modelUpload",
|
|
26
87
|
MODEL_SEARCH = "modelSearch",
|
|
27
88
|
MEDIA_STORAGE = "mediaStorage",
|
|
28
|
-
VECTORIZE = "vectorize"
|
|
89
|
+
VECTORIZE = "vectorize",
|
|
90
|
+
TEXT_INFERENCE = "textInference"
|
|
29
91
|
}
|
|
30
92
|
type RunwareBaseType = {
|
|
31
93
|
apiKey: string;
|
|
@@ -33,6 +95,8 @@ type RunwareBaseType = {
|
|
|
33
95
|
shouldReconnect?: boolean;
|
|
34
96
|
globalMaxRetries?: number;
|
|
35
97
|
timeoutDuration?: number;
|
|
98
|
+
heartbeatInterval?: number;
|
|
99
|
+
enableLogging?: boolean;
|
|
36
100
|
};
|
|
37
101
|
type IOutputType = "base64Data" | "dataURI" | "URL";
|
|
38
102
|
type IOutputFormat = "JPG" | "PNG" | "WEBP";
|
|
@@ -136,9 +200,7 @@ type IControlNetWithUUID = Omit<IControlNet, "guideImage"> & {
|
|
|
136
200
|
guideImage?: string;
|
|
137
201
|
};
|
|
138
202
|
interface IError {
|
|
139
|
-
error:
|
|
140
|
-
errorMessage: string;
|
|
141
|
-
taskUUID: string;
|
|
203
|
+
error: IErrorResponse;
|
|
142
204
|
}
|
|
143
205
|
type TPromptWeighting = "compel" | "sdEmbeds";
|
|
144
206
|
interface IRequestImage extends IAdditionalResponsePayload {
|
|
@@ -303,6 +365,8 @@ interface IRequestVideo extends IRequestImageToText {
|
|
|
303
365
|
speech?: {
|
|
304
366
|
voice: string;
|
|
305
367
|
text: string;
|
|
368
|
+
} & {
|
|
369
|
+
[key: string]: unknown;
|
|
306
370
|
};
|
|
307
371
|
skipResponse?: boolean;
|
|
308
372
|
customTaskUUID?: string;
|
|
@@ -368,6 +432,45 @@ interface IRequestThreeD {
|
|
|
368
432
|
retry?: number;
|
|
369
433
|
[key: string]: unknown;
|
|
370
434
|
}
|
|
435
|
+
interface ITextMessage {
|
|
436
|
+
role: "user" | "assistant";
|
|
437
|
+
content: string;
|
|
438
|
+
}
|
|
439
|
+
interface IRequestTextInference extends IAdditionalResponsePayload {
|
|
440
|
+
model: string;
|
|
441
|
+
messages: ITextMessage[];
|
|
442
|
+
maxTokens?: number;
|
|
443
|
+
temperature?: number;
|
|
444
|
+
topP?: number;
|
|
445
|
+
topK?: number;
|
|
446
|
+
seed?: number;
|
|
447
|
+
stopSequences?: string[];
|
|
448
|
+
systemPrompt?: string;
|
|
449
|
+
outputFormat?: string;
|
|
450
|
+
numberResults?: number;
|
|
451
|
+
includeCost?: boolean;
|
|
452
|
+
onPartialResponse?: (results: IThreeDImage[], error?: IError) => void;
|
|
453
|
+
deliveryMethod?: string;
|
|
454
|
+
taskUUID?: string;
|
|
455
|
+
customTaskUUID?: string;
|
|
456
|
+
skipResponse?: boolean;
|
|
457
|
+
retry?: number;
|
|
458
|
+
[key: string]: unknown;
|
|
459
|
+
}
|
|
460
|
+
interface ITextResponse {
|
|
461
|
+
text: string;
|
|
462
|
+
finishReason: string;
|
|
463
|
+
usage: {
|
|
464
|
+
promptTokens: number;
|
|
465
|
+
completionTokens: number;
|
|
466
|
+
totalTokens: number;
|
|
467
|
+
thinkingTokens: number;
|
|
468
|
+
};
|
|
469
|
+
thoughtSignature: string;
|
|
470
|
+
cost: number;
|
|
471
|
+
taskUUID: string;
|
|
472
|
+
status: string;
|
|
473
|
+
}
|
|
371
474
|
interface IAsyncResults {
|
|
372
475
|
taskUUID: string;
|
|
373
476
|
onPartialImages?: (images: IImage[], error?: IError) => void;
|
|
@@ -777,10 +880,12 @@ type MediaUUID = {
|
|
|
777
880
|
imageUUID?: string;
|
|
778
881
|
videoUUID?: string;
|
|
779
882
|
outputs?: TOutputFiles;
|
|
883
|
+
text?: string;
|
|
780
884
|
};
|
|
781
885
|
|
|
782
886
|
declare enum LISTEN_TO_MEDIA_KEY {
|
|
783
887
|
REQUEST_IMAGES = "REQUEST_IMAGES",
|
|
888
|
+
REQUEST_TEXT = "REQUEST_TEXT",
|
|
784
889
|
REQUEST_AUDIO = "REQUEST_AUDIO"
|
|
785
890
|
}
|
|
786
891
|
|
|
@@ -791,15 +896,21 @@ declare class RunwareBase {
|
|
|
791
896
|
_url?: string;
|
|
792
897
|
_globalMessages: Record<string, any>;
|
|
793
898
|
_globalImages: IImage[];
|
|
794
|
-
|
|
899
|
+
_globalErrors: IError[];
|
|
795
900
|
_connectionSessionUUID: string | undefined;
|
|
796
901
|
_connectionError: TServerError | undefined;
|
|
797
902
|
_sdkType: SdkType;
|
|
798
903
|
_shouldReconnect: boolean;
|
|
799
904
|
_globalMaxRetries: number;
|
|
800
905
|
_timeoutDuration: number;
|
|
906
|
+
_heartbeatIntervalId: any;
|
|
907
|
+
_pongTimeoutId: any;
|
|
908
|
+
_heartbeatInterval: number;
|
|
909
|
+
_missedPongCount: number;
|
|
910
|
+
_maxMissedPongs: number;
|
|
801
911
|
ensureConnectionUUID: string | null;
|
|
802
|
-
|
|
912
|
+
_logger: RunwareLogger;
|
|
913
|
+
constructor({ apiKey, url, shouldReconnect, globalMaxRetries, timeoutDuration, heartbeatInterval, enableLogging, }: RunwareBaseType);
|
|
803
914
|
private getUniqueUUID;
|
|
804
915
|
/**
|
|
805
916
|
* Shared polling logic for async results.
|
|
@@ -811,6 +922,9 @@ declare class RunwareBase {
|
|
|
811
922
|
static initialize(props: RunwareBaseType): Promise<RunwareBase>;
|
|
812
923
|
protected isWebsocketReadyState: () => boolean;
|
|
813
924
|
protected isInvalidAPIKey: () => boolean;
|
|
925
|
+
protected startHeartbeat(): void;
|
|
926
|
+
protected stopHeartbeat(): void;
|
|
927
|
+
protected handlePongMessage(data: any): boolean;
|
|
814
928
|
protected addListener({ lis, groupKey, taskUUID, }: {
|
|
815
929
|
lis: (v: any) => any;
|
|
816
930
|
groupKey?: string;
|
|
@@ -819,7 +933,7 @@ declare class RunwareBase {
|
|
|
819
933
|
destroy: () => void;
|
|
820
934
|
};
|
|
821
935
|
protected connect(): void;
|
|
822
|
-
protected send: (msg: Object) => void
|
|
936
|
+
protected send: (msg: Object) => Promise<void>;
|
|
823
937
|
private destroy;
|
|
824
938
|
private uploadImage;
|
|
825
939
|
private listenToResponse;
|
|
@@ -846,6 +960,7 @@ declare class RunwareBase {
|
|
|
846
960
|
videoInference: (payload: IRequestVideo) => Promise<IVideoToImage[] | IVideoToImage>;
|
|
847
961
|
audioInference: (payload: IRequestAudio) => Promise<IAudio[] | IAudio>;
|
|
848
962
|
threeDInference: (payload: IRequestThreeD) => Promise<IThreeDImage[] | IThreeDImage>;
|
|
963
|
+
textInference: (payload: IRequestTextInference) => Promise<ITextResponse[] | ITextResponse>;
|
|
849
964
|
getResponse: <T>(payload: IAsyncResults) => Promise<T[]>;
|
|
850
965
|
/**
|
|
851
966
|
* Upscale an image or video
|
|
@@ -856,7 +971,7 @@ declare class RunwareBase {
|
|
|
856
971
|
* @since 1.2.0
|
|
857
972
|
* @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).
|
|
858
973
|
*/
|
|
859
|
-
upscaleGan: ({ inputImage, inputs, model, upscaleFactor, outputType, outputFormat, includeCost, outputQuality, customTaskUUID, taskUUID: _taskUUID, retry, includeGenerationTime, includePayload, skipResponse, deliveryMethod }: IUpscaleGan) => Promise<IImage>;
|
|
974
|
+
upscaleGan: ({ inputImage, inputs, model, upscaleFactor, outputType, outputFormat, includeCost, outputQuality, customTaskUUID, taskUUID: _taskUUID, retry, includeGenerationTime, includePayload, skipResponse, deliveryMethod, }: IUpscaleGan) => Promise<IImage>;
|
|
860
975
|
upscale: (params: IUpscaleGan) => Promise<IImage>;
|
|
861
976
|
enhancePrompt: ({ prompt, promptMaxLength, promptVersions, includeCost, customTaskUUID, taskUUID: _taskUUID, retry, includeGenerationTime, includePayload, }: IPromptEnhancer) => Promise<IEnhancedPrompt[]>;
|
|
862
977
|
promptEnhance: (params: IPromptEnhancer) => Promise<IEnhancedPrompt[]>;
|
|
@@ -871,7 +986,7 @@ declare class RunwareBase {
|
|
|
871
986
|
debugKey: string;
|
|
872
987
|
isMultiple?: boolean | undefined;
|
|
873
988
|
}) => Promise<T>;
|
|
874
|
-
protected baseSyncRequest: <T>({ payload, groupKey, skipResponse }: {
|
|
989
|
+
protected baseSyncRequest: <T>({ payload, groupKey, skipResponse, }: {
|
|
875
990
|
payload: Record<string, any>;
|
|
876
991
|
groupKey: LISTEN_TO_MEDIA_KEY;
|
|
877
992
|
skipResponse?: boolean | undefined;
|
|
@@ -894,16 +1009,14 @@ declare class RunwareServer extends RunwareBase {
|
|
|
894
1009
|
_instantiated: boolean;
|
|
895
1010
|
_listeners: any[];
|
|
896
1011
|
_reconnectingIntervalId: null | any;
|
|
897
|
-
|
|
898
|
-
_pongListener: any;
|
|
1012
|
+
private _connecting;
|
|
899
1013
|
constructor(props: RunwareBaseType);
|
|
900
1014
|
protected connect(): Promise<void>;
|
|
901
|
-
protected send: (msg: Object) => void
|
|
1015
|
+
protected send: (msg: Object) => Promise<void>;
|
|
902
1016
|
protected handleClose(): void;
|
|
903
1017
|
protected resetConnection: () => void;
|
|
904
|
-
protected heartBeat(): void;
|
|
905
1018
|
}
|
|
906
1019
|
|
|
907
1020
|
declare let Runware: typeof RunwareClient | typeof RunwareServer;
|
|
908
1021
|
|
|
909
|
-
export { EControlMode, EModelArchitecture, EModelConditioning, EModelFormat, EModelType, EOpenPosePreProcessor, EPhotoMakerEnum, EPreProcessor, EPreProcessorGroup, ETaskType, Environment, type GetWithPromiseAsyncCallBackType, type GetWithPromiseCallBackType, type IAddModelResponse, type IAdditionalResponsePayload, type IAsyncResults, type IAudio, type IAudioOutputFormat, 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 IRequestAudio, type IRequestImage, type IRequestImageToText, type IRequestThreeD, type IRequestVideo, type ITextToImage, type IThreeDImage, type IThreeDOutputFormat, type IUpscaleGan, type IVideoOutputFormat, type IVideoToImage, type IipAdapter, type ListenerType, type MediaUUID, 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 };
|
|
1022
|
+
export { EControlMode, EModelArchitecture, EModelConditioning, EModelFormat, EModelType, EOpenPosePreProcessor, EPhotoMakerEnum, EPreProcessor, EPreProcessorGroup, ETaskType, Environment, type GetWithPromiseAsyncCallBackType, type GetWithPromiseCallBackType, type IAddModelResponse, type IAdditionalResponsePayload, type IAsyncResults, type IAudio, type IAudioOutputFormat, 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 IRequestAudio, type IRequestImage, type IRequestImageToText, type IRequestTextInference, type IRequestThreeD, type IRequestVideo, type ITextMessage, type ITextResponse, type ITextToImage, type IThreeDImage, type IThreeDOutputFormat, type IUpscaleGan, type IVideoOutputFormat, type IVideoToImage, type IipAdapter, type ListenerType, LogLevel, type MediaUUID, type ProviderSettings, type ReconnectingWebsocketProps, type RequireAtLeastOne, type RequireOnlyOne, Runware, type RunwareBaseType, RunwareClient, RunwareLogger, 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, createLogger };
|