@decartai/sdk 0.0.37 → 0.0.39
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.
|
@@ -54,7 +54,10 @@ type RealTimeClient = {
|
|
|
54
54
|
on: <K extends keyof Events>(event: K, listener: (data: Events[K]) => void) => void;
|
|
55
55
|
off: <K extends keyof Events>(event: K, listener: (data: Events[K]) => void) => void;
|
|
56
56
|
sessionId: string;
|
|
57
|
-
setImage: (image: Blob | File | string | null
|
|
57
|
+
setImage: (image: Blob | File | string | null, options?: {
|
|
58
|
+
prompt?: string;
|
|
59
|
+
enhance?: boolean;
|
|
60
|
+
}) => Promise<void>;
|
|
58
61
|
playAudio?: (audio: Blob | File | ArrayBuffer) => Promise<void>;
|
|
59
62
|
};
|
|
60
63
|
//#endregion
|
package/dist/realtime/client.js
CHANGED
|
@@ -99,8 +99,8 @@ const createRealTimeClient = (opts) => {
|
|
|
99
99
|
on: eventEmitter.on,
|
|
100
100
|
off: eventEmitter.off,
|
|
101
101
|
sessionId,
|
|
102
|
-
setImage: async (image) => {
|
|
103
|
-
if (image === null) return webrtcManager.setImage(null);
|
|
102
|
+
setImage: async (image, options$1) => {
|
|
103
|
+
if (image === null) return webrtcManager.setImage(null, options$1);
|
|
104
104
|
let imageBase64;
|
|
105
105
|
if (typeof image === "string") {
|
|
106
106
|
let url = null;
|
|
@@ -111,7 +111,7 @@ const createRealTimeClient = (opts) => {
|
|
|
111
111
|
else if (url?.protocol === "http:" || url?.protocol === "https:") imageBase64 = await blobToBase64(await (await fetch(image)).blob());
|
|
112
112
|
else imageBase64 = image;
|
|
113
113
|
} else imageBase64 = await blobToBase64(image);
|
|
114
|
-
return webrtcManager.setImage(imageBase64);
|
|
114
|
+
return webrtcManager.setImage(imageBase64, options$1);
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
117
|
if (isAvatarLive && audioStreamManager) {
|
|
@@ -132,9 +132,10 @@ var WebRTCConnection = class {
|
|
|
132
132
|
/**
|
|
133
133
|
* Send an image to the server (e.g., as a reference for inference).
|
|
134
134
|
* Can be called after connection is established.
|
|
135
|
-
* Pass null to clear the reference image.
|
|
135
|
+
* Pass null to clear the reference image or use a placeholder.
|
|
136
|
+
* Optionally include a prompt to send with the image.
|
|
136
137
|
*/
|
|
137
|
-
async setImageBase64(imageBase64) {
|
|
138
|
+
async setImageBase64(imageBase64, options) {
|
|
138
139
|
return new Promise((resolve, reject) => {
|
|
139
140
|
const timeoutId = setTimeout(() => {
|
|
140
141
|
this.websocketMessagesEmitter.off("setImageAck", listener);
|
|
@@ -147,10 +148,13 @@ var WebRTCConnection = class {
|
|
|
147
148
|
else reject(new Error(msg.error ?? "Failed to send image"));
|
|
148
149
|
};
|
|
149
150
|
this.websocketMessagesEmitter.on("setImageAck", listener);
|
|
150
|
-
|
|
151
|
+
const message = {
|
|
151
152
|
type: "set_image",
|
|
152
153
|
image_data: imageBase64
|
|
153
|
-
}
|
|
154
|
+
};
|
|
155
|
+
if (options?.prompt !== void 0) message.prompt = options.prompt;
|
|
156
|
+
if (options?.enhance !== void 0) message.enhance_prompt = options.enhance;
|
|
157
|
+
this.send(message);
|
|
154
158
|
});
|
|
155
159
|
}
|
|
156
160
|
/**
|
|
@@ -221,9 +225,6 @@ var WebRTCConnection = class {
|
|
|
221
225
|
this.handleSignalingMessage({ type: "ready" });
|
|
222
226
|
}
|
|
223
227
|
cleanup() {
|
|
224
|
-
this.pc?.getSenders().forEach((s) => {
|
|
225
|
-
s.track?.stop();
|
|
226
|
-
});
|
|
227
228
|
this.pc?.close();
|
|
228
229
|
this.pc = null;
|
|
229
230
|
this.ws?.close();
|
|
@@ -61,8 +61,8 @@ var WebRTCManager = class {
|
|
|
61
61
|
getWebsocketMessageEmitter() {
|
|
62
62
|
return this.connection.websocketMessagesEmitter;
|
|
63
63
|
}
|
|
64
|
-
setImage(imageBase64) {
|
|
65
|
-
return this.connection.setImageBase64(imageBase64);
|
|
64
|
+
setImage(imageBase64, options) {
|
|
65
|
+
return this.connection.setImageBase64(imageBase64, options);
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
|