@gammatech/aijsx 0.1.2 → 0.1.3
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/{createElement-Q_LxUYf8.d.mts → createElement-ms1wdmoH.d.mts} +2 -2
- package/dist/{createElement-Q_LxUYf8.d.ts → createElement-ms1wdmoH.d.ts} +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +46 -11
- package/dist/index.mjs +46 -11
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/package.json +1 -2
|
@@ -112,8 +112,8 @@ declare class CombinedLogger extends LogImplementation {
|
|
|
112
112
|
private readonly loggers;
|
|
113
113
|
constructor(loggers: LogImplementation[]);
|
|
114
114
|
log(...args: Parameters<LogImplementation['log']>): void;
|
|
115
|
-
chatCompletionRequest<
|
|
116
|
-
chatCompletionResponse<
|
|
115
|
+
chatCompletionRequest<_K extends keyof ChatCompletionRequestPayloads>(...args: Parameters<LogImplementation['chatCompletionRequest']>): void;
|
|
116
|
+
chatCompletionResponse<_K extends keyof ChatCompletionRequestPayloads>(...args: Parameters<LogImplementation['chatCompletionResponse']>): void;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
type ChatCompletionRole = 'user' | 'system' | 'assistant';
|
|
@@ -112,8 +112,8 @@ declare class CombinedLogger extends LogImplementation {
|
|
|
112
112
|
private readonly loggers;
|
|
113
113
|
constructor(loggers: LogImplementation[]);
|
|
114
114
|
log(...args: Parameters<LogImplementation['log']>): void;
|
|
115
|
-
chatCompletionRequest<
|
|
116
|
-
chatCompletionResponse<
|
|
115
|
+
chatCompletionRequest<_K extends keyof ChatCompletionRequestPayloads>(...args: Parameters<LogImplementation['chatCompletionRequest']>): void;
|
|
116
|
+
chatCompletionResponse<_K extends keyof ChatCompletionRequestPayloads>(...args: Parameters<LogImplementation['chatCompletionResponse']>): void;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
type ChatCompletionRole = 'user' | 'system' | 'assistant';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LogImplementation, R as RenderContext, C as Context, A as AIElement, a as RenderedConversationMessage } from './createElement-
|
|
2
|
-
export { u as AIComponent, b as AIFragment, w as AINode, f as AssistantMessage, B as BoundLogger, j as ChatCompletionError, k as ChatCompletionRequestPayloads, q as CombinedLogger, p as ConsoleLogger, g as ConversationMessage, r as Literal, l as LogChatCompletionRequest, m as LogChatCompletionResponse, n as LogLevel, o as Logger, d as LoggerContext, N as NoopLogImplementation, P as PropsOfAIComponent, t as RenderResult, x as Renderable, s as RenderableStream, S as SystemMessage, U as UserMessage, v as attachedContextSymbol, h as childrenToConversationMessage, i as computeUsage, c as createAIElement, e as createContext } from './createElement-
|
|
1
|
+
import { L as LogImplementation, R as RenderContext, C as Context, A as AIElement, a as RenderedConversationMessage } from './createElement-ms1wdmoH.mjs';
|
|
2
|
+
export { u as AIComponent, b as AIFragment, w as AINode, f as AssistantMessage, B as BoundLogger, j as ChatCompletionError, k as ChatCompletionRequestPayloads, q as CombinedLogger, p as ConsoleLogger, g as ConversationMessage, r as Literal, l as LogChatCompletionRequest, m as LogChatCompletionResponse, n as LogLevel, o as Logger, d as LoggerContext, N as NoopLogImplementation, P as PropsOfAIComponent, t as RenderResult, x as Renderable, s as RenderableStream, S as SystemMessage, U as UserMessage, v as attachedContextSymbol, h as childrenToConversationMessage, i as computeUsage, c as createAIElement, e as createContext } from './createElement-ms1wdmoH.mjs';
|
|
3
3
|
import { OpenAI } from 'openai';
|
|
4
4
|
export { OpenAI as OpenAIClient } from 'openai';
|
|
5
5
|
import AnthropicClient from '@anthropic-ai/sdk';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LogImplementation, R as RenderContext, C as Context, A as AIElement, a as RenderedConversationMessage } from './createElement-
|
|
2
|
-
export { u as AIComponent, b as AIFragment, w as AINode, f as AssistantMessage, B as BoundLogger, j as ChatCompletionError, k as ChatCompletionRequestPayloads, q as CombinedLogger, p as ConsoleLogger, g as ConversationMessage, r as Literal, l as LogChatCompletionRequest, m as LogChatCompletionResponse, n as LogLevel, o as Logger, d as LoggerContext, N as NoopLogImplementation, P as PropsOfAIComponent, t as RenderResult, x as Renderable, s as RenderableStream, S as SystemMessage, U as UserMessage, v as attachedContextSymbol, h as childrenToConversationMessage, i as computeUsage, c as createAIElement, e as createContext } from './createElement-
|
|
1
|
+
import { L as LogImplementation, R as RenderContext, C as Context, A as AIElement, a as RenderedConversationMessage } from './createElement-ms1wdmoH.js';
|
|
2
|
+
export { u as AIComponent, b as AIFragment, w as AINode, f as AssistantMessage, B as BoundLogger, j as ChatCompletionError, k as ChatCompletionRequestPayloads, q as CombinedLogger, p as ConsoleLogger, g as ConversationMessage, r as Literal, l as LogChatCompletionRequest, m as LogChatCompletionResponse, n as LogLevel, o as Logger, d as LoggerContext, N as NoopLogImplementation, P as PropsOfAIComponent, t as RenderResult, x as Renderable, s as RenderableStream, S as SystemMessage, U as UserMessage, v as attachedContextSymbol, h as childrenToConversationMessage, i as computeUsage, c as createAIElement, e as createContext } from './createElement-ms1wdmoH.js';
|
|
3
3
|
import { OpenAI } from 'openai';
|
|
4
4
|
export { OpenAI as OpenAIClient } from 'openai';
|
|
5
5
|
import AnthropicClient from '@anthropic-ai/sdk';
|
package/dist/index.js
CHANGED
|
@@ -346,6 +346,15 @@ var ParallelStreamIterator = class extends EventEmitter {
|
|
|
346
346
|
value
|
|
347
347
|
});
|
|
348
348
|
}
|
|
349
|
+
error(streamInd, error) {
|
|
350
|
+
const valInd = this.values[streamInd].length;
|
|
351
|
+
this.values[streamInd].push(error);
|
|
352
|
+
this.emit("error", {
|
|
353
|
+
streamInd,
|
|
354
|
+
valInd,
|
|
355
|
+
error
|
|
356
|
+
});
|
|
357
|
+
}
|
|
349
358
|
complete(streamInd) {
|
|
350
359
|
this.completedStreams[streamInd] = true;
|
|
351
360
|
this.emit("complete", {
|
|
@@ -364,6 +373,10 @@ var ParallelStreamIterator = class extends EventEmitter {
|
|
|
364
373
|
resolveAt(streamInd, valInd) {
|
|
365
374
|
return new Promise((resolve, reject) => {
|
|
366
375
|
const value = this.values[streamInd][valInd];
|
|
376
|
+
if (value instanceof Error) {
|
|
377
|
+
reject(value);
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
367
380
|
if (value !== void 0) {
|
|
368
381
|
resolve({ done: false, value });
|
|
369
382
|
return;
|
|
@@ -375,14 +388,27 @@ var ParallelStreamIterator = class extends EventEmitter {
|
|
|
375
388
|
reject("next");
|
|
376
389
|
return;
|
|
377
390
|
}
|
|
378
|
-
const
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
onCompleteUnsub();
|
|
391
|
+
const unsubData = this.on("data", (data) => {
|
|
392
|
+
const atCursor = data.streamInd === streamInd && data.valInd === valInd;
|
|
393
|
+
if (!atCursor) {
|
|
394
|
+
return;
|
|
383
395
|
}
|
|
396
|
+
resolve({ done: false, value: data.value });
|
|
397
|
+
unsubData();
|
|
398
|
+
unsubError();
|
|
399
|
+
unsubComplete();
|
|
384
400
|
});
|
|
385
|
-
const
|
|
401
|
+
const unsubError = this.on("error", (data) => {
|
|
402
|
+
const atCursor = data.streamInd === streamInd && data.valInd === valInd;
|
|
403
|
+
if (!atCursor) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
reject(data.error);
|
|
407
|
+
unsubData();
|
|
408
|
+
unsubError();
|
|
409
|
+
unsubComplete();
|
|
410
|
+
});
|
|
411
|
+
const unsubComplete = this.on("complete", (data) => {
|
|
386
412
|
if (streamInd !== data.streamInd) {
|
|
387
413
|
return;
|
|
388
414
|
}
|
|
@@ -392,8 +418,9 @@ var ParallelStreamIterator = class extends EventEmitter {
|
|
|
392
418
|
if (this.values[streamInd].length === valInd) {
|
|
393
419
|
reject("next");
|
|
394
420
|
}
|
|
395
|
-
|
|
396
|
-
|
|
421
|
+
unsubData();
|
|
422
|
+
unsubError();
|
|
423
|
+
unsubComplete();
|
|
397
424
|
});
|
|
398
425
|
});
|
|
399
426
|
}
|
|
@@ -419,10 +446,18 @@ var ParallelStreamIterator = class extends EventEmitter {
|
|
|
419
446
|
function coalesceParallelStreams(streams) {
|
|
420
447
|
const iter = new ParallelStreamIterator(streams.length);
|
|
421
448
|
streams.forEach(async (s, streamInd) => {
|
|
422
|
-
|
|
423
|
-
|
|
449
|
+
try {
|
|
450
|
+
for await (const value of s) {
|
|
451
|
+
iter.push(streamInd, value);
|
|
452
|
+
}
|
|
453
|
+
iter.complete(streamInd);
|
|
454
|
+
} catch (e) {
|
|
455
|
+
if (e instanceof Error) {
|
|
456
|
+
iter.error(streamInd, e);
|
|
457
|
+
} else {
|
|
458
|
+
iter.error(streamInd, new Error(e));
|
|
459
|
+
}
|
|
424
460
|
}
|
|
425
|
-
iter.complete(streamInd);
|
|
426
461
|
});
|
|
427
462
|
return iter;
|
|
428
463
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -267,6 +267,15 @@ var ParallelStreamIterator = class extends EventEmitter {
|
|
|
267
267
|
value
|
|
268
268
|
});
|
|
269
269
|
}
|
|
270
|
+
error(streamInd, error) {
|
|
271
|
+
const valInd = this.values[streamInd].length;
|
|
272
|
+
this.values[streamInd].push(error);
|
|
273
|
+
this.emit("error", {
|
|
274
|
+
streamInd,
|
|
275
|
+
valInd,
|
|
276
|
+
error
|
|
277
|
+
});
|
|
278
|
+
}
|
|
270
279
|
complete(streamInd) {
|
|
271
280
|
this.completedStreams[streamInd] = true;
|
|
272
281
|
this.emit("complete", {
|
|
@@ -285,6 +294,10 @@ var ParallelStreamIterator = class extends EventEmitter {
|
|
|
285
294
|
resolveAt(streamInd, valInd) {
|
|
286
295
|
return new Promise((resolve, reject) => {
|
|
287
296
|
const value = this.values[streamInd][valInd];
|
|
297
|
+
if (value instanceof Error) {
|
|
298
|
+
reject(value);
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
288
301
|
if (value !== void 0) {
|
|
289
302
|
resolve({ done: false, value });
|
|
290
303
|
return;
|
|
@@ -296,14 +309,27 @@ var ParallelStreamIterator = class extends EventEmitter {
|
|
|
296
309
|
reject("next");
|
|
297
310
|
return;
|
|
298
311
|
}
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
onCompleteUnsub();
|
|
312
|
+
const unsubData = this.on("data", (data) => {
|
|
313
|
+
const atCursor = data.streamInd === streamInd && data.valInd === valInd;
|
|
314
|
+
if (!atCursor) {
|
|
315
|
+
return;
|
|
304
316
|
}
|
|
317
|
+
resolve({ done: false, value: data.value });
|
|
318
|
+
unsubData();
|
|
319
|
+
unsubError();
|
|
320
|
+
unsubComplete();
|
|
305
321
|
});
|
|
306
|
-
const
|
|
322
|
+
const unsubError = this.on("error", (data) => {
|
|
323
|
+
const atCursor = data.streamInd === streamInd && data.valInd === valInd;
|
|
324
|
+
if (!atCursor) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
reject(data.error);
|
|
328
|
+
unsubData();
|
|
329
|
+
unsubError();
|
|
330
|
+
unsubComplete();
|
|
331
|
+
});
|
|
332
|
+
const unsubComplete = this.on("complete", (data) => {
|
|
307
333
|
if (streamInd !== data.streamInd) {
|
|
308
334
|
return;
|
|
309
335
|
}
|
|
@@ -313,8 +339,9 @@ var ParallelStreamIterator = class extends EventEmitter {
|
|
|
313
339
|
if (this.values[streamInd].length === valInd) {
|
|
314
340
|
reject("next");
|
|
315
341
|
}
|
|
316
|
-
|
|
317
|
-
|
|
342
|
+
unsubData();
|
|
343
|
+
unsubError();
|
|
344
|
+
unsubComplete();
|
|
318
345
|
});
|
|
319
346
|
});
|
|
320
347
|
}
|
|
@@ -340,10 +367,18 @@ var ParallelStreamIterator = class extends EventEmitter {
|
|
|
340
367
|
function coalesceParallelStreams(streams) {
|
|
341
368
|
const iter = new ParallelStreamIterator(streams.length);
|
|
342
369
|
streams.forEach(async (s, streamInd) => {
|
|
343
|
-
|
|
344
|
-
|
|
370
|
+
try {
|
|
371
|
+
for await (const value of s) {
|
|
372
|
+
iter.push(streamInd, value);
|
|
373
|
+
}
|
|
374
|
+
iter.complete(streamInd);
|
|
375
|
+
} catch (e) {
|
|
376
|
+
if (e instanceof Error) {
|
|
377
|
+
iter.error(streamInd, e);
|
|
378
|
+
} else {
|
|
379
|
+
iter.error(streamInd, new Error(e));
|
|
380
|
+
}
|
|
345
381
|
}
|
|
346
|
-
iter.complete(streamInd);
|
|
347
382
|
});
|
|
348
383
|
return iter;
|
|
349
384
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Fragment, JSX, jsx, jsxDEV, jsxs } from './jsx-runtime.mjs';
|
|
2
|
-
import './createElement-
|
|
2
|
+
import './createElement-ms1wdmoH.mjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { Fragment, JSX, jsx, jsxDEV, jsxs } from './jsx-runtime.js';
|
|
2
|
-
import './createElement-
|
|
2
|
+
import './createElement-ms1wdmoH.js';
|
package/dist/jsx-runtime.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { u as AIComponent, A as AIElement, b as AIFragment } from './createElement-
|
|
1
|
+
import { u as AIComponent, A as AIElement, b as AIFragment } from './createElement-ms1wdmoH.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The is used as an import source for ts/js files as the JSX transpile functinos
|
package/dist/jsx-runtime.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { u as AIComponent, A as AIElement, b as AIFragment } from './createElement-
|
|
1
|
+
import { u as AIComponent, A as AIElement, b as AIFragment } from './createElement-ms1wdmoH.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The is used as an import source for ts/js files as the JSX transpile functinos
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gammatech/aijsx",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Rewrite of aijsx",
|
|
5
5
|
"author": "Jordan Garcia",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"test:watch": "jest --watch --verbose",
|
|
14
14
|
"build": "yarn check-types && yarn clean-symlinks && tsup",
|
|
15
15
|
"clean-symlinks": "rm ./jsx-* || true",
|
|
16
|
-
"symlink": "ln -s ./dist/jsx-runtime.js . && ln -s ./dist/jsx-runtime.d.ts && ln -s ./dist/jsx-runtime.js ./jsx-dev-runtime.js && ln -s ./dist/jsx-runtime.d.ts ./jsx-dev-runtime.d.ts",
|
|
17
16
|
"prepublishOnly": "yarn build",
|
|
18
17
|
"lint": "eslint \"{src,test}/**/*.ts\" && yarn check-types",
|
|
19
18
|
"check-types": "tsc --skipLibCheck --noEmit"
|