@celljs/ai-core 3.8.0 → 4.0.0

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.
Files changed (128) hide show
  1. package/esm/common/chat/index.d.ts +5 -0
  2. package/esm/common/chat/index.js +6 -0
  3. package/esm/common/chat/index.js.map +1 -0
  4. package/esm/common/chat/message/abstract-message.d.ts +9 -0
  5. package/esm/common/chat/message/abstract-message.js +11 -0
  6. package/esm/common/chat/message/abstract-message.js.map +1 -0
  7. package/esm/common/chat/message/assistant-message.d.ts +9 -0
  8. package/esm/common/chat/message/assistant-message.js +12 -0
  9. package/esm/common/chat/message/assistant-message.js.map +1 -0
  10. package/esm/common/chat/message/function-message.d.ts +8 -0
  11. package/esm/common/chat/message/function-message.js +11 -0
  12. package/esm/common/chat/message/function-message.js.map +1 -0
  13. package/esm/common/chat/message/index.d.ts +7 -0
  14. package/esm/common/chat/message/index.js +8 -0
  15. package/esm/common/chat/message/index.js.map +1 -0
  16. package/esm/common/chat/message/message-protocol.d.ts +87 -0
  17. package/esm/common/chat/message/message-protocol.js +20 -0
  18. package/esm/common/chat/message/message-protocol.js.map +1 -0
  19. package/esm/common/chat/message/system-message.d.ts +8 -0
  20. package/esm/common/chat/message/system-message.js +11 -0
  21. package/esm/common/chat/message/system-message.js.map +1 -0
  22. package/esm/common/chat/message/tool-response-message.d.ts +31 -0
  23. package/esm/common/chat/message/tool-response-message.js +19 -0
  24. package/esm/common/chat/message/tool-response-message.js.map +1 -0
  25. package/esm/common/chat/message/user-message.d.ts +8 -0
  26. package/esm/common/chat/message/user-message.js +11 -0
  27. package/esm/common/chat/message/user-message.js.map +1 -0
  28. package/esm/common/chat/metadata/chat-generation-metadata.d.ts +27 -0
  29. package/esm/common/chat/metadata/chat-generation-metadata.js +16 -0
  30. package/esm/common/chat/metadata/chat-generation-metadata.js.map +1 -0
  31. package/esm/common/chat/metadata/index.d.ts +2 -0
  32. package/esm/common/chat/metadata/index.js +3 -0
  33. package/esm/common/chat/metadata/index.js.map +1 -0
  34. package/esm/common/chat/metadata/metadata-protocol.d.ts +127 -0
  35. package/esm/common/chat/metadata/metadata-protocol.js +92 -0
  36. package/esm/common/chat/metadata/metadata-protocol.js.map +1 -0
  37. package/esm/common/chat/model/chat-protocol.d.ts +26 -0
  38. package/esm/common/chat/model/chat-protocol.js +35 -0
  39. package/esm/common/chat/model/chat-protocol.js.map +1 -0
  40. package/esm/common/chat/model/index.d.ts +2 -0
  41. package/esm/common/chat/model/index.js +3 -0
  42. package/esm/common/chat/model/index.js.map +1 -0
  43. package/esm/common/chat/model/proxy-chat-model.d.ts +11 -0
  44. package/esm/common/chat/model/proxy-chat-model.js +67 -0
  45. package/esm/common/chat/model/proxy-chat-model.js.map +1 -0
  46. package/esm/common/chat/prompt/el-prompt-template.d.ts +8 -0
  47. package/esm/common/chat/prompt/el-prompt-template.js +47 -0
  48. package/esm/common/chat/prompt/el-prompt-template.js.map +1 -0
  49. package/esm/common/chat/prompt/index.d.ts +4 -0
  50. package/esm/common/chat/prompt/index.js +5 -0
  51. package/esm/common/chat/prompt/index.js.map +1 -0
  52. package/esm/common/chat/prompt/prompt-protocol.d.ts +49 -0
  53. package/esm/common/chat/prompt/prompt-protocol.js +2 -0
  54. package/esm/common/chat/prompt/prompt-protocol.js.map +1 -0
  55. package/esm/common/chat/prompt/prompt-template.d.ts +6 -0
  56. package/esm/common/chat/prompt/prompt-template.js +44 -0
  57. package/esm/common/chat/prompt/prompt-template.js.map +1 -0
  58. package/esm/common/chat/prompt/prompt.d.ts +13 -0
  59. package/esm/common/chat/prompt/prompt.js +52 -0
  60. package/esm/common/chat/prompt/prompt.js.map +1 -0
  61. package/esm/common/chat/tool/index.d.ts +2 -0
  62. package/esm/common/chat/tool/index.js +3 -0
  63. package/esm/common/chat/tool/index.js.map +1 -0
  64. package/esm/common/chat/tool/tool-handler.d.ts +11 -0
  65. package/esm/common/chat/tool/tool-handler.js +59 -0
  66. package/esm/common/chat/tool/tool-handler.js.map +1 -0
  67. package/esm/common/chat/tool/tool-protocol.d.ts +7 -0
  68. package/esm/common/chat/tool/tool-protocol.js +2 -0
  69. package/esm/common/chat/tool/tool-protocol.js.map +1 -0
  70. package/esm/common/embedding/embedding-protocol.d.ts +120 -0
  71. package/esm/common/embedding/embedding-protocol.js +56 -0
  72. package/esm/common/embedding/embedding-protocol.js.map +1 -0
  73. package/esm/common/embedding/index.d.ts +1 -0
  74. package/esm/common/embedding/index.js +2 -0
  75. package/esm/common/embedding/index.js.map +1 -0
  76. package/esm/common/error/error.d.ts +7 -0
  77. package/esm/common/error/error.js +12 -0
  78. package/esm/common/error/error.js.map +1 -0
  79. package/esm/common/error/index.d.ts +1 -0
  80. package/esm/common/error/index.js +2 -0
  81. package/esm/common/error/index.js.map +1 -0
  82. package/esm/common/index.d.ts +6 -0
  83. package/esm/common/index.js +7 -0
  84. package/esm/common/index.js.map +1 -0
  85. package/esm/common/model/function/function-callback-register.d.ts +8 -0
  86. package/esm/common/model/function/function-callback-register.js +45 -0
  87. package/esm/common/model/function/function-callback-register.js.map +1 -0
  88. package/esm/common/model/function/function-protocol.d.ts +75 -0
  89. package/esm/common/model/function/function-protocol.js +49 -0
  90. package/esm/common/model/function/function-protocol.js.map +1 -0
  91. package/esm/common/model/function/index.d.ts +2 -0
  92. package/esm/common/model/function/index.js +3 -0
  93. package/esm/common/model/function/index.js.map +1 -0
  94. package/esm/common/model/index.d.ts +2 -0
  95. package/esm/common/model/index.js +3 -0
  96. package/esm/common/model/index.js.map +1 -0
  97. package/esm/common/model/model-protocol.d.ts +164 -0
  98. package/esm/common/model/model-protocol.js +12 -0
  99. package/esm/common/model/model-protocol.js.map +1 -0
  100. package/esm/common/module.d.ts +3 -0
  101. package/esm/common/module.js +4 -0
  102. package/esm/common/module.js.map +1 -0
  103. package/esm/common/sse/index.d.ts +3 -0
  104. package/esm/common/sse/index.js +4 -0
  105. package/esm/common/sse/index.js.map +1 -0
  106. package/esm/common/sse/line-decoder.d.ts +14 -0
  107. package/esm/common/sse/line-decoder.js +51 -0
  108. package/esm/common/sse/line-decoder.js.map +1 -0
  109. package/esm/common/sse/sse-decoder.d.ts +26 -0
  110. package/esm/common/sse/sse-decoder.js +70 -0
  111. package/esm/common/sse/sse-decoder.js.map +1 -0
  112. package/esm/common/sse/sse-protocol.d.ts +22 -0
  113. package/esm/common/sse/sse-protocol.js +2 -0
  114. package/esm/common/sse/sse-protocol.js.map +1 -0
  115. package/esm/common/utils/index.d.ts +3 -0
  116. package/esm/common/utils/index.js +4 -0
  117. package/esm/common/utils/index.js.map +1 -0
  118. package/esm/common/utils/prompt-util.d.ts +4 -0
  119. package/esm/common/utils/prompt-util.js +7 -0
  120. package/esm/common/utils/prompt-util.js.map +1 -0
  121. package/esm/common/utils/sse-util.d.ts +10 -0
  122. package/esm/common/utils/sse-util.js +109 -0
  123. package/esm/common/utils/sse-util.js.map +1 -0
  124. package/esm/common/utils/usage-util.d.ts +16 -0
  125. package/esm/common/utils/usage-util.js +59 -0
  126. package/esm/common/utils/usage-util.js.map +1 -0
  127. package/esm/package.json +3 -0
  128. package/package.json +84 -5
@@ -0,0 +1,4 @@
1
+ import { autoBind } from '@celljs/core';
2
+ import './index.js';
3
+ export default autoBind();
4
+ //# sourceMappingURL=module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/common/module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,SAAS,CAAC;AAEjB,eAAe,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './line-decoder.js';
2
+ export * from './sse-protocol.js';
3
+ export * from './sse-decoder.js';
@@ -0,0 +1,4 @@
1
+ export * from './line-decoder.js';
2
+ export * from './sse-protocol.js';
3
+ export * from './sse-decoder.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/sse/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { Bytes } from '@celljs/core';
2
+ import { LineDecoder } from './sse-protocol.js';
3
+ /**
4
+ * Line decoder.
5
+ */
6
+ export declare class LineDecoderImpl implements LineDecoder {
7
+ private buffer;
8
+ private trailingCR;
9
+ static readonly NEWLINE_CHARS: Set<string>;
10
+ static readonly NEWLINE_REGEXP: RegExp;
11
+ constructor();
12
+ decode(chunk: Bytes): string[];
13
+ flush(): string[];
14
+ }
@@ -0,0 +1,51 @@
1
+ import { ByteUtil } from '@celljs/core';
2
+ /**
3
+ * Line decoder.
4
+ */
5
+ export class LineDecoderImpl {
6
+ constructor() {
7
+ this.buffer = [];
8
+ this.trailingCR = false;
9
+ }
10
+ decode(chunk) {
11
+ let text = ByteUtil.decode(chunk);
12
+ if (this.trailingCR) {
13
+ text = '\r' + text;
14
+ this.trailingCR = false;
15
+ }
16
+ if (text.endsWith('\r')) {
17
+ this.trailingCR = true;
18
+ text = text.slice(0, -1);
19
+ }
20
+ if (!text) {
21
+ return [];
22
+ }
23
+ const trailingNewline = LineDecoderImpl.NEWLINE_CHARS.has(text[text.length - 1] || '');
24
+ let lines = text.split(LineDecoderImpl.NEWLINE_REGEXP);
25
+ if (lines.length === 1 && !trailingNewline) {
26
+ this.buffer.push(lines[0]);
27
+ return [];
28
+ }
29
+ if (this.buffer.length > 0) {
30
+ lines = [this.buffer.join('') + lines[0], ...lines.slice(1)];
31
+ this.buffer = [];
32
+ }
33
+ if (!trailingNewline) {
34
+ this.buffer = [lines.pop() || ''];
35
+ }
36
+ return lines;
37
+ }
38
+ flush() {
39
+ if (this.buffer.length === 0 && !this.trailingCR) {
40
+ return [];
41
+ }
42
+ const lines = [this.buffer.join('')];
43
+ this.buffer = [];
44
+ this.trailingCR = false;
45
+ return lines;
46
+ }
47
+ }
48
+ LineDecoderImpl.NEWLINE_CHARS = new Set(['\n', '\r', '\x0b', '\x0c', '\x1c', '\x1d', '\x1e', '\x85', '\u2028', '\u2029']);
49
+ /* eslint-disable-next-line no-control-regex */
50
+ LineDecoderImpl.NEWLINE_REGEXP = /\r\n|[\n\r\x0b\x0c\x1c\x1d\x1e\x85\u2028\u2029]/g;
51
+ //# sourceMappingURL=line-decoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"line-decoder.js","sourceRoot":"","sources":["../../../src/common/sse/line-decoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAE,MAAM,cAAc,CAAC;AAG/C;;GAEG;AACH,MAAM,OAAO,eAAe;IAQxB;QACI,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,MAAM,CAAC,KAAY;QACf,IAAI,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAElC,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;YACnB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QAC5B,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;YACvB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC7B,CAAC;QAED,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,OAAO,EAAE,CAAC;QACd,CAAC;QAED,MAAM,eAAe,GAAG,eAAe,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QACvF,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;QA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0 +1,26 @@
1
+ import { EventDecoder, StreamEvent } from './sse-protocol.js';
2
+ /**
3
+ * Server-sent event.
4
+ */
5
+ export declare class SSEDecoder implements EventDecoder {
6
+ private event?;
7
+ private data;
8
+ private chunks;
9
+ constructor();
10
+ protected buildServerSentEvent(): StreamEvent<string>;
11
+ decode(line: string): StreamEvent<string> | undefined;
12
+ /**
13
+ * Partitions a string into three parts based on a delimiter.
14
+ * @param str The string to partition.
15
+ * @param delimiter The delimiter to partition the string by.
16
+ * @returns A tuple containing the three parts of the partitioned string.
17
+ * The first part is the string before the delimiter, the second part is the delimiter itself,
18
+ * and the third part is the string after the delimiter.
19
+ * If the delimiter is not found in the string, the first part is the entire string, the second part is an empty string, and the third part is an empty string.
20
+ * @example
21
+ * partition('hello,world', ',') // ['hello', ',', 'world']
22
+ * partition('hello,world', '.') // ['hello,world', '', '']
23
+ * partition('hello,world', 'l') // ['he', 'l', 'lo,world']
24
+ */
25
+ protected partition(str: string, delimiter: string): [string, string, string];
26
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Server-sent event.
3
+ */
4
+ export class SSEDecoder {
5
+ constructor() {
6
+ this.event = undefined;
7
+ this.data = [];
8
+ this.chunks = [];
9
+ }
10
+ buildServerSentEvent() {
11
+ const sse = {
12
+ event: this.event,
13
+ data: this.data.join('\n'),
14
+ raw: this.chunks,
15
+ };
16
+ this.event = undefined;
17
+ this.data = [];
18
+ this.chunks = [];
19
+ return sse;
20
+ }
21
+ decode(line) {
22
+ if (line.endsWith('\r')) {
23
+ line = line.substring(0, line.length - 1);
24
+ }
25
+ if (!line) {
26
+ if (!this.event && this.data.length === 0) {
27
+ return;
28
+ }
29
+ return this.buildServerSentEvent();
30
+ }
31
+ this.chunks.push(line);
32
+ if (line.startsWith(':')) {
33
+ return;
34
+ }
35
+ if (line.startsWith('{') && line.endsWith('}')) {
36
+ this.data.push(line);
37
+ return this.buildServerSentEvent();
38
+ }
39
+ const [fieldName, , value] = this.partition(line, ':');
40
+ const trimmedValue = value.startsWith(' ') ? value.substring(1) : value;
41
+ if (fieldName === 'event') {
42
+ this.event = trimmedValue;
43
+ }
44
+ else if (fieldName === 'data') {
45
+ this.data.push(trimmedValue);
46
+ }
47
+ return;
48
+ }
49
+ /**
50
+ * Partitions a string into three parts based on a delimiter.
51
+ * @param str The string to partition.
52
+ * @param delimiter The delimiter to partition the string by.
53
+ * @returns A tuple containing the three parts of the partitioned string.
54
+ * The first part is the string before the delimiter, the second part is the delimiter itself,
55
+ * and the third part is the string after the delimiter.
56
+ * If the delimiter is not found in the string, the first part is the entire string, the second part is an empty string, and the third part is an empty string.
57
+ * @example
58
+ * partition('hello,world', ',') // ['hello', ',', 'world']
59
+ * partition('hello,world', '.') // ['hello,world', '', '']
60
+ * partition('hello,world', 'l') // ['he', 'l', 'lo,world']
61
+ */
62
+ partition(str, delimiter) {
63
+ const index = str.indexOf(delimiter);
64
+ if (index !== -1) {
65
+ return [str.substring(0, index), delimiter, str.substring(index + delimiter.length)];
66
+ }
67
+ return [str, '', ''];
68
+ }
69
+ }
70
+ //# sourceMappingURL=sse-decoder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sse-decoder.js","sourceRoot":"","sources":["../../../src/common/sse/sse-decoder.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,UAAU;IAKnB;QACI,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACrB,CAAC;IAES,oBAAoB;QAC1B,MAAM,GAAG,GAAwB;YAC7B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1B,GAAG,EAAE,IAAI,CAAC,MAAM;SACnB,CAAC;QAEF,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,EAA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AAM,EAAE,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACjC,CAAC;QAED,OAAO;IACX,CAAC;IAED;;;;;;;;;;;;OAYG;IACO,SAAS,CAAC,GAAW,EAAE,SAAiB;QAC9C,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACrC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QACzF,CAAC;QACD,OAAO,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IACzB,CAAC;CACJ"}
@@ -0,0 +1,22 @@
1
+ import { Bytes } from '@celljs/core';
2
+ /**
3
+ * Server-sent event.
4
+ */
5
+ export interface StreamEvent<Data> {
6
+ event?: string;
7
+ data: Data;
8
+ raw: string[];
9
+ }
10
+ /**
11
+ * Decoder for server-sent events.
12
+ */
13
+ export interface EventDecoder {
14
+ decode(line: string): StreamEvent<string> | undefined;
15
+ }
16
+ /**
17
+ * Decoder for line-based protocols.
18
+ */
19
+ export interface LineDecoder {
20
+ decode(chunk: Bytes): string[];
21
+ flush(): string[];
22
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sse-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sse-protocol.js","sourceRoot":"","sources":["../../../src/common/sse/sse-protocol.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from './prompt-util.js';
2
+ export * from './sse-util.js';
3
+ export * from './usage-util.js';
@@ -0,0 +1,4 @@
1
+ export * from './prompt-util.js';
2
+ export * from './sse-util.js';
3
+ export * from './usage-util.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ChatOptions, Message, Prompt } from '../chat/index.js';
2
+ export declare abstract class PromptUtil {
3
+ static create(messages: Message[] | Message | string, options?: ChatOptions): Prompt;
4
+ }
@@ -0,0 +1,7 @@
1
+ import { PromptImpl } from '../chat/index.js';
2
+ export class PromptUtil {
3
+ static create(messages, options = {}) {
4
+ return new PromptImpl(messages, options);
5
+ }
6
+ }
7
+ //# sourceMappingURL=prompt-util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-util.js","sourceRoot":"","sources":["../../../src/common/utils/prompt-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,UAAU,EAAE,MAAM,SAAS,CAAC;AAEnE,MAAM,OAAgB,UAAU;IACrB,MAAM,CAAC,MAAM,CAAC,QAAsC,EAAE,OAAO,GAAgB,EAAE;QAClF,OAAO,IAAI,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;CACJ"}
@@ -0,0 +1,10 @@
1
+ import { Observable } from 'rxjs';
2
+ import { StreamEvent } from '../sse/index.js';
3
+ /**
4
+ * SSE utility class.
5
+ */
6
+ export declare abstract class SSEUtil {
7
+ static toObservable<Data>(readableStream: ReadableStream, controller?: AbortController): Observable<StreamEvent<Data>>;
8
+ private static handleSSE;
9
+ private static readableStreamAsyncIterable;
10
+ }
@@ -0,0 +1,109 @@
1
+ import { Observable } from 'rxjs';
2
+ import { SSEDecoder, LineDecoderImpl } from '../sse/index.js';
3
+ /**
4
+ * SSE utility class.
5
+ */
6
+ export class SSEUtil {
7
+ static toObservable(readableStream, controller) {
8
+ return new Observable(subscriber => {
9
+ (async () => {
10
+ const decoder = new SSEDecoder();
11
+ const lineDecoder = new LineDecoderImpl();
12
+ try {
13
+ const iterable = this.readableStreamAsyncIterable(readableStream);
14
+ for await (const chunk of iterable) {
15
+ const lines = lineDecoder.decode(chunk);
16
+ for (const line of lines) {
17
+ const sse = decoder.decode(line);
18
+ this.handleSSE(sse, subscriber, controller);
19
+ }
20
+ }
21
+ const remainingLines = lineDecoder.flush();
22
+ for (const line of remainingLines) {
23
+ const sse = decoder.decode(line);
24
+ if (sse) {
25
+ this.handleSSE(sse, subscriber, controller);
26
+ }
27
+ }
28
+ subscriber.complete();
29
+ }
30
+ catch (e) {
31
+ if (e instanceof Error && e.name === 'AbortError') {
32
+ subscriber.complete();
33
+ }
34
+ else {
35
+ subscriber.error(e);
36
+ }
37
+ }
38
+ finally {
39
+ controller === null || controller === void 0 ? void 0 : controller.abort();
40
+ }
41
+ })();
42
+ });
43
+ }
44
+ static handleSSE(sse, subscriber, controller) {
45
+ if (sse) {
46
+ if (sse.data.startsWith('[DONE]')) {
47
+ subscriber.complete();
48
+ controller === null || controller === void 0 ? void 0 : controller.abort();
49
+ return;
50
+ }
51
+ if (!sse.event || sse.event === 'error') {
52
+ let data;
53
+ try {
54
+ data = JSON.parse(sse.data);
55
+ }
56
+ catch (e) {
57
+ console.error('Could not parse message into JSON:', sse.data);
58
+ console.error('From chunk:', sse.raw);
59
+ subscriber.error(e);
60
+ return;
61
+ }
62
+ if (data && data.error) {
63
+ subscriber.error(data.error);
64
+ return;
65
+ }
66
+ subscriber.next({
67
+ event: sse.event,
68
+ data,
69
+ raw: sse.raw
70
+ });
71
+ if (data.done === true) {
72
+ subscriber.complete();
73
+ controller === null || controller === void 0 ? void 0 : controller.abort();
74
+ }
75
+ }
76
+ }
77
+ }
78
+ static readableStreamAsyncIterable(stream) {
79
+ if (stream[Symbol.asyncIterator]) {
80
+ return stream;
81
+ }
82
+ const reader = stream.getReader();
83
+ return {
84
+ async next() {
85
+ try {
86
+ const result = await reader.read();
87
+ if (result === null || result === void 0 ? void 0 : result.done) {
88
+ reader.releaseLock();
89
+ }
90
+ return result;
91
+ }
92
+ catch (e) {
93
+ reader.releaseLock();
94
+ throw e;
95
+ }
96
+ },
97
+ async return() {
98
+ const cancelPromise = reader.cancel();
99
+ reader.releaseLock();
100
+ await cancelPromise;
101
+ return { done: true, value: undefined };
102
+ },
103
+ [Symbol.asyncIterator]() {
104
+ return this;
105
+ },
106
+ };
107
+ }
108
+ }
109
+ //# sourceMappingURL=sse-util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sse-util.js","sourceRoot":"","sources":["../../../src/common/utils/sse-util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAe,UAAU,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAGlE;;GAEG;AACH,MAAM,OAAgB,OAAO;IAEzB,MAAM,CAAC,YAAY,CAAO,cAA8B,EAAE,UAA4B;QAClF,OAAO,IAAI,UAAU,CAAoB,UAAU,CAAC,EAAE;YAClD,CAAC,KAAK,IAAI,EAAE;gBACR,MAAM,OAAO,GAAG,IAAI,UAAU,EAAE,CAAC;gBACjC,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC;gBAE1C,IAAI,CAAC;oBACD,MAAM,QAAQ,GAAG,IAAI,CAAC,2BAA2B,CAAQ,cAAc,CAAC,CAAC;oBACzE,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;wBACjC,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;wBACxC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;4BACvB,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;4BACjC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;wBAChD,CAAC;oBACL,CAAC;oBAED,MAAM,cAAc,GAAG,WAAW,CAAC,KAAK,EAAE,CAAC;oBAC3C,KAAK,MAAM,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,CAAC;gBACZ,CAAC;YACL,CAAC;YACD,KAAK,CAAC,MAAM;gBACR,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;gBACtC,MAAM,CAAC,WAAW,EAAE,CAAC;gBACrB,MAAM,aAAa,CAAC;gBACpB,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;YAC5C,CAAC;YACD,CAAC,MAAM,CAAC,aAAa,CAAC;gBAClB,OAAO,IAAI,CAAC;YAChB,CAAC;SACJ,CAAC;IACN,CAAC;CACJ"}
@@ -0,0 +1,16 @@
1
+ import { ChatResponse } from '../chat/index.js';
2
+ import { Usage } from '../chat/metadata/index.js';
3
+ /**
4
+ * An utility class to provide support methods handling {@link Usage}.
5
+ */
6
+ export declare abstract class UsageUtil {
7
+ /**
8
+ * Accumulate usage tokens from the previous chat response to the current usage
9
+ * tokens.
10
+ * @param currentUsage the current usage.
11
+ * @param previousChatResponse the previous chat response.
12
+ * @return accumulated usage.
13
+ */
14
+ static getCumulativeUsage(currentUsage: Usage, previousChatResponse?: ChatResponse): Usage;
15
+ static isEmpty(usage: Usage | null): boolean;
16
+ }
@@ -0,0 +1,59 @@
1
+ import { Usage } from '../chat/metadata/index.js';
2
+ /**
3
+ * An utility class to provide support methods handling {@link Usage}.
4
+ */
5
+ export class UsageUtil {
6
+ /**
7
+ * Accumulate usage tokens from the previous chat response to the current usage
8
+ * tokens.
9
+ * @param currentUsage the current usage.
10
+ * @param previousChatResponse the previous chat response.
11
+ * @return accumulated usage.
12
+ */
13
+ static getCumulativeUsage(currentUsage, previousChatResponse) {
14
+ var _a;
15
+ var _b, _c, _d, _e, _f, _g;
16
+ let usageFromPreviousChatResponse = undefined;
17
+ if ((_a = previousChatResponse === null || previousChatResponse === void 0 ? void 0 : previousChatResponse.metadata) === null || _a === void 0 ? void 0 : _a.usage) {
18
+ usageFromPreviousChatResponse = previousChatResponse.metadata.usage;
19
+ }
20
+ else {
21
+ return currentUsage;
22
+ }
23
+ // For a valid usage from previous chat response, accumulate it to the current
24
+ // usage.
25
+ if (!this.isEmpty(currentUsage)) {
26
+ let promptTokens = (_b = currentUsage.promptTokens) !== null && _b !== void 0 ? _b : 0;
27
+ let generationTokens = (_c = currentUsage.generationTokens) !== null && _c !== void 0 ? _c : 0;
28
+ let totalTokens = (_d = currentUsage.totalTokens) !== null && _d !== void 0 ? _d : 0;
29
+ // Make sure to accumulate the usage from the previous chat response.
30
+ promptTokens += (_e = usageFromPreviousChatResponse.promptTokens) !== null && _e !== void 0 ? _e : 0;
31
+ generationTokens += (_f = usageFromPreviousChatResponse.generationTokens) !== null && _f !== void 0 ? _f : 0;
32
+ totalTokens += (_g = usageFromPreviousChatResponse.totalTokens) !== null && _g !== void 0 ? _g : 0;
33
+ return Usage.from(promptTokens, generationTokens, totalTokens);
34
+ }
35
+ // When current usage is empty, return the usage from the previous chat response.
36
+ return usageFromPreviousChatResponse;
37
+ }
38
+ // /**
39
+ // * Check if the {@link Usage} is empty. Returns true when the {@link Usage} is null.
40
+ // * Returns true when the {@link Usage} has zero tokens.
41
+ // * @param usage the usage to check against.
42
+ // * @return the boolean value to represent if it is empty.
43
+ // */
44
+ // static isEmpty(usage: Usage | null): boolean {
45
+ // if (!usage) {
46
+ // return true;
47
+ // } else if (usage != null && usage.totalTokens === 0) {
48
+ // return true;
49
+ // }
50
+ // return false;
51
+ // }
52
+ static isEmpty(usage) {
53
+ if (!usage) {
54
+ return true;
55
+ }
56
+ return false;
57
+ }
58
+ }
59
+ //# sourceMappingURL=usage-util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage-util.js","sourceRoot":"","sources":["../../../src/common/utils/usage-util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC;;GAEG;AACH,MAAM,OAAgB,SAAS;IAE3B;;;;;;OAMG;IACI,MAAM,CAAC,kBAAkB,CAAC,YAAmB,EAAE,oBAAmC;;;QAC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,3 @@
1
+ {
2
+ "type": "module"
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ai-core",
3
- "version": "3.8.0",
3
+ "version": "4.0.0",
4
4
  "description": "Core domain for AI programming",
5
5
  "keywords": [
6
6
  "cell-component"
@@ -18,22 +18,101 @@
18
18
  "typings": "lib/common/index.d.ts",
19
19
  "files": [
20
20
  "lib",
21
+ "esm",
21
22
  "src",
22
23
  "cell.yml"
23
24
  ],
24
25
  "scripts": {
25
- "build": "tsc -b",
26
- "clean": "rm -rf lib *.tsbuildinfo",
26
+ "build": "tsc -b && bun ../../scripts/build-esm.ts",
27
+ "clean": "rm -rf lib esm *.tsbuildinfo",
27
28
  "test": "bun test --preload reflect-metadata ./lib",
28
29
  "watch": "tsc -b -w --preserveWatchOutput"
29
30
  },
30
31
  "dependencies": {
31
- "@celljs/core": "3.8.0",
32
- "@celljs/http": "3.8.0",
32
+ "@celljs/core": "4.0.0",
33
+ "@celljs/http": "4.0.0",
33
34
  "rxjs": "^6.6.0",
34
35
  "tslib": "^2.8.0"
35
36
  },
36
37
  "publishConfig": {
37
38
  "access": "public"
39
+ },
40
+ "exports": {
41
+ ".": {
42
+ "import": "./esm/common/index.js",
43
+ "default": "./lib/common/index.js"
44
+ },
45
+ "./package.json": "./package.json",
46
+ "./lib/common": {
47
+ "import": "./esm/common/index.js",
48
+ "default": "./lib/common/index.js"
49
+ },
50
+ "./lib/common/chat": {
51
+ "import": "./esm/common/chat/index.js",
52
+ "default": "./lib/common/chat/index.js"
53
+ },
54
+ "./lib/common/chat/message": {
55
+ "import": "./esm/common/chat/message/index.js",
56
+ "default": "./lib/common/chat/message/index.js"
57
+ },
58
+ "./lib/common/chat/metadata": {
59
+ "import": "./esm/common/chat/metadata/index.js",
60
+ "default": "./lib/common/chat/metadata/index.js"
61
+ },
62
+ "./lib/common/chat/model": {
63
+ "import": "./esm/common/chat/model/index.js",
64
+ "default": "./lib/common/chat/model/index.js"
65
+ },
66
+ "./lib/common/chat/prompt": {
67
+ "import": "./esm/common/chat/prompt/index.js",
68
+ "default": "./lib/common/chat/prompt/index.js"
69
+ },
70
+ "./lib/common/chat/tool": {
71
+ "import": "./esm/common/chat/tool/index.js",
72
+ "default": "./lib/common/chat/tool/index.js"
73
+ },
74
+ "./lib/common/embedding": {
75
+ "import": "./esm/common/embedding/index.js",
76
+ "default": "./lib/common/embedding/index.js"
77
+ },
78
+ "./lib/common/error": {
79
+ "import": "./esm/common/error/index.js",
80
+ "default": "./lib/common/error/index.js"
81
+ },
82
+ "./lib/common/model": {
83
+ "import": "./esm/common/model/index.js",
84
+ "default": "./lib/common/model/index.js"
85
+ },
86
+ "./lib/common/model/function": {
87
+ "import": "./esm/common/model/function/index.js",
88
+ "default": "./lib/common/model/function/index.js"
89
+ },
90
+ "./lib/common/sse": {
91
+ "import": "./esm/common/sse/index.js",
92
+ "default": "./lib/common/sse/index.js"
93
+ },
94
+ "./lib/common/utils": {
95
+ "import": "./esm/common/utils/index.js",
96
+ "default": "./lib/common/utils/index.js"
97
+ },
98
+ "./lib/*.js": {
99
+ "import": "./esm/*.js",
100
+ "default": "./lib/*.js"
101
+ },
102
+ "./lib/*": {
103
+ "import": "./esm/*.js",
104
+ "default": "./lib/*.js"
105
+ },
106
+ "./*": "./*"
107
+ },
108
+ "cell": {
109
+ "modules": {
110
+ "frontend": [
111
+ "lib/common/module"
112
+ ],
113
+ "backend": [
114
+ "lib/common/module"
115
+ ]
116
+ }
38
117
  }
39
118
  }