@gammatech/aijsx 0.4.0-beta.3 → 0.4.0-beta.5
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-1-_m1v-4.d.mts → createElement-gT2wWwEd.d.mts} +17 -17
- package/dist/{createElement-1-_m1v-4.d.ts → createElement-gT2wWwEd.d.ts} +17 -17
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -3
- package/dist/index.mjs +8 -3
- 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 -1
|
@@ -90,16 +90,16 @@ type RenderOptions = {
|
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
|
-
type
|
|
93
|
+
type RenderTraceInfo = {
|
|
94
94
|
traceId: string;
|
|
95
95
|
spanId: string;
|
|
96
96
|
parentSpanId: string | null;
|
|
97
97
|
renderType: 'element' | 'chain' | 'prompt' | 'root';
|
|
98
98
|
key: string;
|
|
99
|
-
parent:
|
|
99
|
+
parent: RenderTraceInfo | null;
|
|
100
100
|
};
|
|
101
101
|
interface RenderContext {
|
|
102
|
-
traceInfo:
|
|
102
|
+
traceInfo: RenderTraceInfo;
|
|
103
103
|
logger: Logger;
|
|
104
104
|
getContext<T>(context: Context<T>): T;
|
|
105
105
|
render(renderable: Renderable, opts?: RenderOptions): RenderResult;
|
|
@@ -218,24 +218,24 @@ declare abstract class LogImplementation {
|
|
|
218
218
|
* @param level The log level, e.g. 'error', 'warn', 'info', 'debug'
|
|
219
219
|
* @param message
|
|
220
220
|
*/
|
|
221
|
-
abstract log(ctx:
|
|
221
|
+
abstract log(ctx: RenderTraceInfo, level: LogLevel, message: string): void;
|
|
222
222
|
/**
|
|
223
223
|
* Logs exceptions thrown during an element's render.
|
|
224
224
|
*/
|
|
225
|
-
logException(ctx:
|
|
226
|
-
chainStart(_ctx:
|
|
227
|
-
chainComplete(_ctx:
|
|
228
|
-
chainError(_ctx:
|
|
229
|
-
promptStart(_ctx:
|
|
230
|
-
promptComplete(_ctx:
|
|
231
|
-
promptError(_ctx:
|
|
232
|
-
chatCompletionRequest<K extends keyof ChatCompletionRequestPayloads>(_ctx:
|
|
233
|
-
chatCompletionResponse<K extends keyof ChatCompletionRequestPayloads>(_ctx:
|
|
225
|
+
logException(ctx: RenderTraceInfo, exception: unknown): void;
|
|
226
|
+
chainStart(_ctx: RenderTraceInfo, _payload: LogChainStart): void;
|
|
227
|
+
chainComplete(_ctx: RenderTraceInfo, _payload: LogChainComplete): void;
|
|
228
|
+
chainError(_ctx: RenderTraceInfo, _payload: LogChainError): void;
|
|
229
|
+
promptStart(_ctx: RenderTraceInfo, _payload: LogPromptStart): void;
|
|
230
|
+
promptComplete(_ctx: RenderTraceInfo, _payload: LogPromptComplete): void;
|
|
231
|
+
promptError(_ctx: RenderTraceInfo, _payload: LogPromptError): void;
|
|
232
|
+
chatCompletionRequest<K extends keyof ChatCompletionRequestPayloads>(_ctx: RenderTraceInfo, _provider: K, _payload: LogChatCompletionRequest<ChatCompletionRequestPayloads[K]>): void;
|
|
233
|
+
chatCompletionResponse<K extends keyof ChatCompletionRequestPayloads>(_ctx: RenderTraceInfo, _provider: K, _payload: LogChatCompletionResponse<ChatCompletionRequestPayloads[K]>): void;
|
|
234
234
|
}
|
|
235
235
|
declare class BoundLogger implements Logger {
|
|
236
236
|
private readonly impl;
|
|
237
237
|
private readonly ctx;
|
|
238
|
-
constructor(impl: LogImplementation, ctx:
|
|
238
|
+
constructor(impl: LogImplementation, ctx: RenderTraceInfo);
|
|
239
239
|
chainStart(payload: LogChainStart): void;
|
|
240
240
|
chainComplete(payload: LogChainComplete): void;
|
|
241
241
|
chainError(payload: LogChainError): void;
|
|
@@ -252,10 +252,10 @@ declare class BoundLogger implements Logger {
|
|
|
252
252
|
chatCompletionResponse: <K extends keyof ChatCompletionRequestPayloads>(provider: K, payload: LogChatCompletionResponse<ChatCompletionRequestPayloads[K]>) => void;
|
|
253
253
|
}
|
|
254
254
|
declare class NoopLogImplementation extends LogImplementation {
|
|
255
|
-
log(_ctx:
|
|
255
|
+
log(_ctx: RenderTraceInfo, _level: LogLevel, _message: string): void;
|
|
256
256
|
}
|
|
257
257
|
declare class ConsoleLogger extends LogImplementation {
|
|
258
|
-
log(ctx:
|
|
258
|
+
log(ctx: RenderTraceInfo, level: LogLevel, message: string): void;
|
|
259
259
|
}
|
|
260
260
|
declare class CombinedLogger extends LogImplementation {
|
|
261
261
|
private readonly loggers;
|
|
@@ -306,4 +306,4 @@ declare function AIFragment({ children }: {
|
|
|
306
306
|
children: AINode;
|
|
307
307
|
}): Renderable;
|
|
308
308
|
|
|
309
|
-
export { type AIComponent as A, BoundLogger as B, type ContextValues as C,
|
|
309
|
+
export { type AIComponent as A, BoundLogger as B, type ContextValues as C, NoopLogImplementation as D, type EvaluatorFn as E, type FunctionChain as F, ConsoleLogger as G, CombinedLogger as H, type Literal as I, type RenderableStream as J, type RenderResult as K, LogImplementation as L, attachedContextSymbol as M, type NotAsyncGenerator as N, type AIElement as O, type PromptParsed as P, type Renderable as Q, type RenderContext as R, type StreamChain as S, type PropsOfAIComponent as T, UserMessage as U, type EvaluatorResult as V, type OutputParser as W, type PromptRenderResult as X, type Prompt as a, type Context as b, type AINode as c, createAIElement as d, AIFragment as e, LoggerContext as f, createContext as g, type RenderTraceInfo as h, type ChatCompletionRole as i, SystemMessage as j, AssistantMessage as k, type RenderedConversationMessage as l, computeUsage as m, ChatCompletionError as n, type LogChainStart as o, type LogChainComplete as p, type LogChainError as q, type LogPromptStart as r, type LogPromptComplete as s, type LogPromptError as t, type ChatCompletionRequestPayloads as u, type LogChatCompletionRequest as v, type LogChatCompletionResponse as w, type LogLevel as x, type LogContext as y, type Logger as z };
|
|
@@ -90,16 +90,16 @@ type RenderOptions = {
|
|
|
90
90
|
};
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
|
-
type
|
|
93
|
+
type RenderTraceInfo = {
|
|
94
94
|
traceId: string;
|
|
95
95
|
spanId: string;
|
|
96
96
|
parentSpanId: string | null;
|
|
97
97
|
renderType: 'element' | 'chain' | 'prompt' | 'root';
|
|
98
98
|
key: string;
|
|
99
|
-
parent:
|
|
99
|
+
parent: RenderTraceInfo | null;
|
|
100
100
|
};
|
|
101
101
|
interface RenderContext {
|
|
102
|
-
traceInfo:
|
|
102
|
+
traceInfo: RenderTraceInfo;
|
|
103
103
|
logger: Logger;
|
|
104
104
|
getContext<T>(context: Context<T>): T;
|
|
105
105
|
render(renderable: Renderable, opts?: RenderOptions): RenderResult;
|
|
@@ -218,24 +218,24 @@ declare abstract class LogImplementation {
|
|
|
218
218
|
* @param level The log level, e.g. 'error', 'warn', 'info', 'debug'
|
|
219
219
|
* @param message
|
|
220
220
|
*/
|
|
221
|
-
abstract log(ctx:
|
|
221
|
+
abstract log(ctx: RenderTraceInfo, level: LogLevel, message: string): void;
|
|
222
222
|
/**
|
|
223
223
|
* Logs exceptions thrown during an element's render.
|
|
224
224
|
*/
|
|
225
|
-
logException(ctx:
|
|
226
|
-
chainStart(_ctx:
|
|
227
|
-
chainComplete(_ctx:
|
|
228
|
-
chainError(_ctx:
|
|
229
|
-
promptStart(_ctx:
|
|
230
|
-
promptComplete(_ctx:
|
|
231
|
-
promptError(_ctx:
|
|
232
|
-
chatCompletionRequest<K extends keyof ChatCompletionRequestPayloads>(_ctx:
|
|
233
|
-
chatCompletionResponse<K extends keyof ChatCompletionRequestPayloads>(_ctx:
|
|
225
|
+
logException(ctx: RenderTraceInfo, exception: unknown): void;
|
|
226
|
+
chainStart(_ctx: RenderTraceInfo, _payload: LogChainStart): void;
|
|
227
|
+
chainComplete(_ctx: RenderTraceInfo, _payload: LogChainComplete): void;
|
|
228
|
+
chainError(_ctx: RenderTraceInfo, _payload: LogChainError): void;
|
|
229
|
+
promptStart(_ctx: RenderTraceInfo, _payload: LogPromptStart): void;
|
|
230
|
+
promptComplete(_ctx: RenderTraceInfo, _payload: LogPromptComplete): void;
|
|
231
|
+
promptError(_ctx: RenderTraceInfo, _payload: LogPromptError): void;
|
|
232
|
+
chatCompletionRequest<K extends keyof ChatCompletionRequestPayloads>(_ctx: RenderTraceInfo, _provider: K, _payload: LogChatCompletionRequest<ChatCompletionRequestPayloads[K]>): void;
|
|
233
|
+
chatCompletionResponse<K extends keyof ChatCompletionRequestPayloads>(_ctx: RenderTraceInfo, _provider: K, _payload: LogChatCompletionResponse<ChatCompletionRequestPayloads[K]>): void;
|
|
234
234
|
}
|
|
235
235
|
declare class BoundLogger implements Logger {
|
|
236
236
|
private readonly impl;
|
|
237
237
|
private readonly ctx;
|
|
238
|
-
constructor(impl: LogImplementation, ctx:
|
|
238
|
+
constructor(impl: LogImplementation, ctx: RenderTraceInfo);
|
|
239
239
|
chainStart(payload: LogChainStart): void;
|
|
240
240
|
chainComplete(payload: LogChainComplete): void;
|
|
241
241
|
chainError(payload: LogChainError): void;
|
|
@@ -252,10 +252,10 @@ declare class BoundLogger implements Logger {
|
|
|
252
252
|
chatCompletionResponse: <K extends keyof ChatCompletionRequestPayloads>(provider: K, payload: LogChatCompletionResponse<ChatCompletionRequestPayloads[K]>) => void;
|
|
253
253
|
}
|
|
254
254
|
declare class NoopLogImplementation extends LogImplementation {
|
|
255
|
-
log(_ctx:
|
|
255
|
+
log(_ctx: RenderTraceInfo, _level: LogLevel, _message: string): void;
|
|
256
256
|
}
|
|
257
257
|
declare class ConsoleLogger extends LogImplementation {
|
|
258
|
-
log(ctx:
|
|
258
|
+
log(ctx: RenderTraceInfo, level: LogLevel, message: string): void;
|
|
259
259
|
}
|
|
260
260
|
declare class CombinedLogger extends LogImplementation {
|
|
261
261
|
private readonly loggers;
|
|
@@ -306,4 +306,4 @@ declare function AIFragment({ children }: {
|
|
|
306
306
|
children: AINode;
|
|
307
307
|
}): Renderable;
|
|
308
308
|
|
|
309
|
-
export { type AIComponent as A, BoundLogger as B, type ContextValues as C,
|
|
309
|
+
export { type AIComponent as A, BoundLogger as B, type ContextValues as C, NoopLogImplementation as D, type EvaluatorFn as E, type FunctionChain as F, ConsoleLogger as G, CombinedLogger as H, type Literal as I, type RenderableStream as J, type RenderResult as K, LogImplementation as L, attachedContextSymbol as M, type NotAsyncGenerator as N, type AIElement as O, type PromptParsed as P, type Renderable as Q, type RenderContext as R, type StreamChain as S, type PropsOfAIComponent as T, UserMessage as U, type EvaluatorResult as V, type OutputParser as W, type PromptRenderResult as X, type Prompt as a, type Context as b, type AINode as c, createAIElement as d, AIFragment as e, LoggerContext as f, createContext as g, type RenderTraceInfo as h, type ChatCompletionRole as i, SystemMessage as j, AssistantMessage as k, type RenderedConversationMessage as l, computeUsage as m, ChatCompletionError as n, type LogChainStart as o, type LogChainComplete as p, type LogChainError as q, type LogPromptStart as r, type LogPromptComplete as s, type LogPromptError as t, type ChatCompletionRequestPayloads as u, type LogChatCompletionRequest as v, type LogChatCompletionResponse as w, type LogLevel as x, type LogContext as y, type Logger as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RenderContext, L as LogImplementation, C as ContextValues, A as AIComponent, E as EvaluatorFn, P as PromptParsed, a as Prompt, N as NotAsyncGenerator, F as FunctionChain, S as StreamChain, b as Context, c as AINode } from './createElement-
|
|
2
|
-
export {
|
|
1
|
+
import { R as RenderContext, L as LogImplementation, C as ContextValues, A as AIComponent, E as EvaluatorFn, P as PromptParsed, a as Prompt, N as NotAsyncGenerator, F as FunctionChain, S as StreamChain, b as Context, c as AINode } from './createElement-gT2wWwEd.mjs';
|
|
2
|
+
export { O as AIElement, e as AIFragment, k as AssistantMessage, B as BoundLogger, n as ChatCompletionError, u as ChatCompletionRequestPayloads, i as ChatCompletionRole, H as CombinedLogger, G as ConsoleLogger, V as EvaluatorResult, I as Literal, p as LogChainComplete, q as LogChainError, o as LogChainStart, v as LogChatCompletionRequest, w as LogChatCompletionResponse, y as LogContext, x as LogLevel, s as LogPromptComplete, t as LogPromptError, r as LogPromptStart, z as Logger, f as LoggerContext, D as NoopLogImplementation, W as OutputParser, X as PromptRenderResult, T as PropsOfAIComponent, K as RenderResult, h as RenderTraceInfo, Q as Renderable, J as RenderableStream, l as RenderedConversationMessage, j as SystemMessage, U as UserMessage, M as attachedContextSymbol, m as computeUsage, d as createAIElement, g as createContext } from './createElement-gT2wWwEd.mjs';
|
|
3
3
|
import { ZodObject, ZodRawShape, ZodTypeAny, ZodString, z } from 'zod';
|
|
4
4
|
import { OpenAI } from 'openai';
|
|
5
5
|
export { OpenAI as OpenAIClient } from 'openai';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RenderContext, L as LogImplementation, C as ContextValues, A as AIComponent, E as EvaluatorFn, P as PromptParsed, a as Prompt, N as NotAsyncGenerator, F as FunctionChain, S as StreamChain, b as Context, c as AINode } from './createElement-
|
|
2
|
-
export {
|
|
1
|
+
import { R as RenderContext, L as LogImplementation, C as ContextValues, A as AIComponent, E as EvaluatorFn, P as PromptParsed, a as Prompt, N as NotAsyncGenerator, F as FunctionChain, S as StreamChain, b as Context, c as AINode } from './createElement-gT2wWwEd.js';
|
|
2
|
+
export { O as AIElement, e as AIFragment, k as AssistantMessage, B as BoundLogger, n as ChatCompletionError, u as ChatCompletionRequestPayloads, i as ChatCompletionRole, H as CombinedLogger, G as ConsoleLogger, V as EvaluatorResult, I as Literal, p as LogChainComplete, q as LogChainError, o as LogChainStart, v as LogChatCompletionRequest, w as LogChatCompletionResponse, y as LogContext, x as LogLevel, s as LogPromptComplete, t as LogPromptError, r as LogPromptStart, z as Logger, f as LoggerContext, D as NoopLogImplementation, W as OutputParser, X as PromptRenderResult, T as PropsOfAIComponent, K as RenderResult, h as RenderTraceInfo, Q as Renderable, J as RenderableStream, l as RenderedConversationMessage, j as SystemMessage, U as UserMessage, M as attachedContextSymbol, m as computeUsage, d as createAIElement, g as createContext } from './createElement-gT2wWwEd.js';
|
|
3
3
|
import { ZodObject, ZodRawShape, ZodTypeAny, ZodString, z } from 'zod';
|
|
4
4
|
import { OpenAI } from 'openai';
|
|
5
5
|
export { OpenAI as OpenAIClient } from 'openai';
|
package/dist/index.js
CHANGED
|
@@ -482,11 +482,16 @@ function createRenderContext({
|
|
|
482
482
|
traceId = uuid.traceId(),
|
|
483
483
|
contextValues = {}
|
|
484
484
|
} = {}) {
|
|
485
|
-
const spanId = uuid.spanId();
|
|
486
485
|
const traceInfo = {
|
|
487
486
|
traceId,
|
|
488
|
-
spanId,
|
|
489
|
-
|
|
487
|
+
// assign parentSpanId to spanId, because we dont count
|
|
488
|
+
// the root span. we want the first invoked Span to point to
|
|
489
|
+
// the supplied parentSpanId here
|
|
490
|
+
//
|
|
491
|
+
// We can think of the Root span as a "symlink" to the current
|
|
492
|
+
// application trace span
|
|
493
|
+
spanId: parentSpanId || uuid.spanId(),
|
|
494
|
+
parentSpanId: null,
|
|
490
495
|
key: "Root",
|
|
491
496
|
renderType: "root",
|
|
492
497
|
parent: null
|
package/dist/index.mjs
CHANGED
|
@@ -393,11 +393,16 @@ function createRenderContext({
|
|
|
393
393
|
traceId = uuid.traceId(),
|
|
394
394
|
contextValues = {}
|
|
395
395
|
} = {}) {
|
|
396
|
-
const spanId = uuid.spanId();
|
|
397
396
|
const traceInfo = {
|
|
398
397
|
traceId,
|
|
399
|
-
spanId,
|
|
400
|
-
|
|
398
|
+
// assign parentSpanId to spanId, because we dont count
|
|
399
|
+
// the root span. we want the first invoked Span to point to
|
|
400
|
+
// the supplied parentSpanId here
|
|
401
|
+
//
|
|
402
|
+
// We can think of the Root span as a "symlink" to the current
|
|
403
|
+
// application trace span
|
|
404
|
+
spanId: parentSpanId || uuid.spanId(),
|
|
405
|
+
parentSpanId: null,
|
|
401
406
|
key: "Root",
|
|
402
407
|
renderType: "root",
|
|
403
408
|
parent: null
|
package/dist/jsx-runtime.d.mts
CHANGED
package/dist/jsx-runtime.d.ts
CHANGED