@fluid-topics/public-api 1.0.99 → 1.0.100-alpha
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 +4 -0
- package/dist/cjs/types/ft-common/public.js +133 -73
- package/dist/cjs/types/ft-server/public.js +111 -4
- package/dist/fluidtopics.min.js +1 -1
- package/dist/mjs/index.d.ts +3 -1
- package/dist/mjs/index.js +4 -0
- package/dist/mjs/types/ft-common/public.d.ts +107 -59
- package/dist/mjs/types/ft-common/public.js +116 -63
- package/dist/mjs/types/ft-server/public.d.ts +90 -3
- package/dist/mjs/types/ft-server/public.js +94 -2
- package/package.json +1 -1
- package/.npmignore +0 -14
- package/dist/cjs/helpers/GenAIChunkReader.js +0 -66
- package/dist/mjs/helpers/GenAIChunkReader.d.ts +0 -19
- package/dist/mjs/helpers/GenAIChunkReader.js +0 -37
- package/yarn.lock +0 -4323
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
3
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
4
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
5
|
-
var m = o[Symbol.asyncIterator], i;
|
|
6
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
7
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
8
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
9
|
-
};
|
|
10
|
-
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
|
11
|
-
var i, p;
|
|
12
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
13
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
|
|
14
|
-
};
|
|
15
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
16
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
17
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
18
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
19
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
20
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
21
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
22
|
-
function fulfill(value) { resume("next", value); }
|
|
23
|
-
function reject(value) { resume("throw", value); }
|
|
24
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.GenAIChunkReader = void 0;
|
|
28
|
-
class GenAIChunkReader {
|
|
29
|
-
constructor(reader) {
|
|
30
|
-
this.reader = reader;
|
|
31
|
-
this.decoder = new TextDecoder();
|
|
32
|
-
this.partialChunk = "";
|
|
33
|
-
}
|
|
34
|
-
read() {
|
|
35
|
-
return __asyncGenerator(this, arguments, function* read_1() {
|
|
36
|
-
while (true) {
|
|
37
|
-
const { done, value } = yield __await(this.reader.read());
|
|
38
|
-
if (done) {
|
|
39
|
-
yield __await(yield* __asyncDelegator(__asyncValues(this.readRemainingChunks())));
|
|
40
|
-
return yield __await(void 0);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
yield __await(yield* __asyncDelegator(__asyncValues(this.readChunksFromValue(value))));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
*readRemainingChunks() {
|
|
49
|
-
yield* this.parseLine(this.partialChunk);
|
|
50
|
-
}
|
|
51
|
-
*readChunksFromValue(value) {
|
|
52
|
-
const text = this.partialChunk + this.decoder.decode(value);
|
|
53
|
-
const lines = text.split("\n");
|
|
54
|
-
this.partialChunk = lines.pop();
|
|
55
|
-
for (let line of lines) {
|
|
56
|
-
yield* this.parseLine(line);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
*parseLine(line) {
|
|
60
|
-
const [type, content] = line.split(/:(.*)/);
|
|
61
|
-
if (type == "data" && content.length > 0) {
|
|
62
|
-
yield JSON.parse(content);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
exports.GenAIChunkReader = GenAIChunkReader;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface GenAIChunk {
|
|
2
|
-
id?: string;
|
|
3
|
-
message?: string;
|
|
4
|
-
error?: {
|
|
5
|
-
code: number;
|
|
6
|
-
name: string;
|
|
7
|
-
message: string;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export declare class GenAIChunkReader {
|
|
11
|
-
private readonly reader;
|
|
12
|
-
private decoder;
|
|
13
|
-
private partialChunk;
|
|
14
|
-
constructor(reader: ReadableStreamDefaultReader<Uint8Array>);
|
|
15
|
-
read(): AsyncGenerator<GenAIChunk>;
|
|
16
|
-
private readRemainingChunks;
|
|
17
|
-
private readChunksFromValue;
|
|
18
|
-
private parseLine;
|
|
19
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export class GenAIChunkReader {
|
|
2
|
-
reader;
|
|
3
|
-
decoder = new TextDecoder();
|
|
4
|
-
partialChunk = "";
|
|
5
|
-
constructor(reader) {
|
|
6
|
-
this.reader = reader;
|
|
7
|
-
}
|
|
8
|
-
async *read() {
|
|
9
|
-
while (true) {
|
|
10
|
-
const { done, value } = await this.reader.read();
|
|
11
|
-
if (done) {
|
|
12
|
-
yield* this.readRemainingChunks();
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
yield* this.readChunksFromValue(value);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
*readRemainingChunks() {
|
|
21
|
-
yield* this.parseLine(this.partialChunk);
|
|
22
|
-
}
|
|
23
|
-
*readChunksFromValue(value) {
|
|
24
|
-
const text = this.partialChunk + this.decoder.decode(value);
|
|
25
|
-
const lines = text.split("\n");
|
|
26
|
-
this.partialChunk = lines.pop();
|
|
27
|
-
for (let line of lines) {
|
|
28
|
-
yield* this.parseLine(line);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
*parseLine(line) {
|
|
32
|
-
const [type, content] = line.split(/:(.*)/);
|
|
33
|
-
if (type == "data" && content.length > 0) {
|
|
34
|
-
yield JSON.parse(content);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|