@squidcloud/client 1.0.173 → 1.0.174

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_.concatMap)(({ value, complete }) => {
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(char => ({ value: char, complete: false })));
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({ value: token[i], complete: complete && i === token.length - 1 });
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
  }
@@ -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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@squidcloud/client",
3
- "version": "1.0.173",
3
+ "version": "1.0.174",
4
4
  "description": "A typescript implementation of the Squid client",
5
5
  "main": "dist/cjs/index.js",
6
6
  "types": "dist/typescript-client/src/index.d.ts",