@squidcloud/client 1.0.173 → 1.0.175
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/cjs/index.js
CHANGED
|
@@ -28523,16 +28523,23 @@ class AiChatbotClient {
|
|
|
28523
28523
|
*/
|
|
28524
28524
|
chat(profileId, prompt, options) {
|
|
28525
28525
|
const clientRequestId = generateId();
|
|
28526
|
+
const smoothTyping = (options === null || options === void 0 ? void 0 : options.smoothTyping) === undefined ? true : options.smoothTyping;
|
|
28526
28527
|
let accumulatedValue = '';
|
|
28527
28528
|
const subject = new external_rxjs_.Subject();
|
|
28528
28529
|
const tokenSequence = new external_rxjs_.Subject();
|
|
28529
28530
|
this.ongoingChatSequences[clientRequestId] = tokenSequence;
|
|
28531
|
+
let lastTokenIndex = -1;
|
|
28530
28532
|
tokenSequence
|
|
28531
|
-
.pipe((0,external_rxjs_.
|
|
28533
|
+
.pipe((0,external_rxjs_.tap)(({ tokenIndex }) => {
|
|
28534
|
+
if (tokenIndex !== undefined && tokenIndex < lastTokenIndex) {
|
|
28535
|
+
console.warn('Received token index out of order', tokenIndex, lastTokenIndex);
|
|
28536
|
+
}
|
|
28537
|
+
tokenIndex !== undefined && (lastTokenIndex = tokenIndex);
|
|
28538
|
+
}), (0,external_rxjs_.concatMap)(({ value, complete }) => {
|
|
28532
28539
|
if (complete) {
|
|
28533
28540
|
return (0,external_rxjs_.of)({ value, complete });
|
|
28534
28541
|
}
|
|
28535
|
-
return (0,external_rxjs_.of)(value).pipe((0,external_rxjs_.delay)(5), map(
|
|
28542
|
+
return (0,external_rxjs_.of)(value).pipe(smoothTyping ? (0,external_rxjs_.delay)(5) : (0,external_rxjs_.tap)(), map(str => ({ value: str, complete: false })));
|
|
28536
28543
|
}), (0,external_rxjs_.takeWhile)(({ complete }) => !complete, true))
|
|
28537
28544
|
.subscribe({
|
|
28538
28545
|
next: ({ value }) => {
|
|
@@ -28566,13 +28573,17 @@ class AiChatbotClient {
|
|
|
28566
28573
|
if (!tokenSequence) {
|
|
28567
28574
|
return;
|
|
28568
28575
|
}
|
|
28569
|
-
const { token, complete } = message.payload;
|
|
28576
|
+
const { token, complete, tokenIndex } = message.payload;
|
|
28570
28577
|
if (complete && !token.length) {
|
|
28571
|
-
tokenSequence.next({ value: '', complete: true });
|
|
28578
|
+
tokenSequence.next({ value: '', complete: true, tokenIndex: undefined });
|
|
28572
28579
|
}
|
|
28573
28580
|
else {
|
|
28574
28581
|
for (let i = 0; i < token.length; i++) {
|
|
28575
|
-
tokenSequence.next({
|
|
28582
|
+
tokenSequence.next({
|
|
28583
|
+
value: token[i],
|
|
28584
|
+
complete: complete && i === token.length - 1,
|
|
28585
|
+
tokenIndex: tokenIndex === undefined ? undefined : tokenIndex,
|
|
28586
|
+
});
|
|
28576
28587
|
}
|
|
28577
28588
|
}
|
|
28578
28589
|
}
|
|
@@ -47740,7 +47751,7 @@ class ApiManager {
|
|
|
47740
47751
|
return parsedPayload;
|
|
47741
47752
|
}
|
|
47742
47753
|
else {
|
|
47743
|
-
throw new Error(`Got error while calling API (HTTP Status ${response.httpStatus}). Message: ${
|
|
47754
|
+
throw new Error(`Got error while calling API (HTTP Status ${response.httpStatus}). Message: ${response.payload}`);
|
|
47744
47755
|
}
|
|
47745
47756
|
})), this.clientIdService.observeClientTooOld().pipe(map(() => {
|
|
47746
47757
|
throw new Error('CLIENT_NOT_CONNECTED');
|
|
@@ -10,6 +10,7 @@ export interface AiChatbotChatOptions {
|
|
|
10
10
|
disableHistory?: boolean;
|
|
11
11
|
includeReference?: boolean;
|
|
12
12
|
responseFormat?: OpenAiResponseFormat;
|
|
13
|
+
smoothTyping?: boolean;
|
|
13
14
|
}
|
|
14
15
|
export type AiChatbotMutationType = 'insert' | 'update' | 'delete';
|
|
15
16
|
export type AiChatbotResourceType = 'instruction' | 'context' | 'profile';
|