@gammatech/aijsx 0.3.0-beta.3 → 0.3.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-1aVf4hY2.d.mts → createElement-_dIoXoIE.d.mts} +3 -1
- package/dist/{createElement-1aVf4hY2.d.ts → createElement-_dIoXoIE.d.ts} +3 -1
- package/dist/index.d.mts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +15 -4
- package/dist/index.mjs +15 -4
- 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
|
@@ -55,6 +55,7 @@ interface Prompt<V extends Record<string, any> = Record<string, any>> {
|
|
|
55
55
|
component: AIComponent<V>;
|
|
56
56
|
schema: ZodObject<ZodRawShape>;
|
|
57
57
|
evaluators: EvaluatorFn[];
|
|
58
|
+
metadata?: Record<string, any>;
|
|
58
59
|
}
|
|
59
60
|
interface PromptParsed<V extends Record<string, any> = Record<string, any>, O = any> extends Prompt<V> {
|
|
60
61
|
outputParser: OutputParser<O>;
|
|
@@ -65,6 +66,7 @@ type Chain<V extends Record<string, any> = Record<string, any>, R = any> = {
|
|
|
65
66
|
};
|
|
66
67
|
|
|
67
68
|
declare const LoggerContext: Context<LogImplementation>;
|
|
69
|
+
type ContextValues = Record<symbol, any>;
|
|
68
70
|
type RenderOptions = {
|
|
69
71
|
preserveTags?: boolean;
|
|
70
72
|
renderedProps?: {
|
|
@@ -200,4 +202,4 @@ declare function AIFragment({ children }: {
|
|
|
200
202
|
children: AINode;
|
|
201
203
|
}): Renderable;
|
|
202
204
|
|
|
203
|
-
export { type AINode as A, BoundLogger as B, type
|
|
205
|
+
export { type AINode as A, BoundLogger as B, type ContextValues as C, type PropsOfAIComponent as D, type EvaluatorFn as E, type EvaluatorResult as F, type PromptRenderResult as G, LogImplementation as L, NoopLogImplementation as N, type OutputParser as O, type PromptParsed as P, type RenderContext as R, SystemMessage as S, UserMessage as U, type Context as a, type AIComponent as b, type Prompt as c, type Chain as d, createAIElement as e, AIFragment as f, LoggerContext as g, createContext as h, type ChatCompletionRole as i, AssistantMessage as j, type RenderedConversationMessage as k, computeUsage as l, ChatCompletionError as m, type ChatCompletionRequestPayloads as n, type LogChatCompletionRequest as o, type LogChatCompletionResponse as p, type LogLevel as q, type Logger as r, ConsoleLogger as s, CombinedLogger as t, type Literal as u, type RenderableStream as v, type RenderResult as w, attachedContextSymbol as x, type AIElement as y, type Renderable as z };
|
|
@@ -55,6 +55,7 @@ interface Prompt<V extends Record<string, any> = Record<string, any>> {
|
|
|
55
55
|
component: AIComponent<V>;
|
|
56
56
|
schema: ZodObject<ZodRawShape>;
|
|
57
57
|
evaluators: EvaluatorFn[];
|
|
58
|
+
metadata?: Record<string, any>;
|
|
58
59
|
}
|
|
59
60
|
interface PromptParsed<V extends Record<string, any> = Record<string, any>, O = any> extends Prompt<V> {
|
|
60
61
|
outputParser: OutputParser<O>;
|
|
@@ -65,6 +66,7 @@ type Chain<V extends Record<string, any> = Record<string, any>, R = any> = {
|
|
|
65
66
|
};
|
|
66
67
|
|
|
67
68
|
declare const LoggerContext: Context<LogImplementation>;
|
|
69
|
+
type ContextValues = Record<symbol, any>;
|
|
68
70
|
type RenderOptions = {
|
|
69
71
|
preserveTags?: boolean;
|
|
70
72
|
renderedProps?: {
|
|
@@ -200,4 +202,4 @@ declare function AIFragment({ children }: {
|
|
|
200
202
|
children: AINode;
|
|
201
203
|
}): Renderable;
|
|
202
204
|
|
|
203
|
-
export { type AINode as A, BoundLogger as B, type
|
|
205
|
+
export { type AINode as A, BoundLogger as B, type ContextValues as C, type PropsOfAIComponent as D, type EvaluatorFn as E, type EvaluatorResult as F, type PromptRenderResult as G, LogImplementation as L, NoopLogImplementation as N, type OutputParser as O, type PromptParsed as P, type RenderContext as R, SystemMessage as S, UserMessage as U, type Context as a, type AIComponent as b, type Prompt as c, type Chain as d, createAIElement as e, AIFragment as f, LoggerContext as g, createContext as h, type ChatCompletionRole as i, AssistantMessage as j, type RenderedConversationMessage as k, computeUsage as l, ChatCompletionError as m, type ChatCompletionRequestPayloads as n, type LogChatCompletionRequest as o, type LogChatCompletionResponse as p, type LogLevel as q, type Logger as r, ConsoleLogger as s, CombinedLogger as t, type Literal as u, type RenderableStream as v, type RenderResult as w, attachedContextSymbol as x, type AIElement as y, type Renderable as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RenderContext, L as LogImplementation, C as Context, A as AINode,
|
|
2
|
-
export {
|
|
1
|
+
import { R as RenderContext, L as LogImplementation, C as ContextValues, a as Context, A as AINode, b as AIComponent, E as EvaluatorFn, P as PromptParsed, c as Prompt, d as Chain } from './createElement-_dIoXoIE.mjs';
|
|
2
|
+
export { y as AIElement, f as AIFragment, j as AssistantMessage, B as BoundLogger, m as ChatCompletionError, n as ChatCompletionRequestPayloads, i as ChatCompletionRole, t as CombinedLogger, s as ConsoleLogger, F as EvaluatorResult, u as Literal, o as LogChatCompletionRequest, p as LogChatCompletionResponse, q as LogLevel, r as Logger, g as LoggerContext, N as NoopLogImplementation, O as OutputParser, G as PromptRenderResult, D as PropsOfAIComponent, w as RenderResult, z as Renderable, v as RenderableStream, k as RenderedConversationMessage, S as SystemMessage, U as UserMessage, x as attachedContextSymbol, l as computeUsage, e as createAIElement, h as createContext } from './createElement-_dIoXoIE.mjs';
|
|
3
3
|
import { OpenAI } from 'openai';
|
|
4
4
|
export { OpenAI as OpenAIClient } from 'openai';
|
|
5
5
|
import { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam, ChatCompletionAssistantMessageParam, ChatCompletionCreateParams } from 'openai/resources';
|
|
@@ -11,8 +11,9 @@ import { ZodObject, ZodRawShape, ZodTypeAny, ZodString, z } from 'zod';
|
|
|
11
11
|
type CreateRenderContextOptions = {
|
|
12
12
|
logger?: LogImplementation;
|
|
13
13
|
rootRenderId?: string;
|
|
14
|
+
contextValues?: ContextValues;
|
|
14
15
|
};
|
|
15
|
-
declare function createRenderContext({ logger, rootRenderId, }?: CreateRenderContextOptions): RenderContext;
|
|
16
|
+
declare function createRenderContext({ logger, rootRenderId, contextValues, }?: CreateRenderContextOptions): RenderContext;
|
|
16
17
|
|
|
17
18
|
type OpenAIChatCompletionRequest = OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming;
|
|
18
19
|
type OpenAIChatMessage = ChatCompletionSystemMessageParam | ChatCompletionUserMessageParam | ChatCompletionAssistantMessageParam;
|
|
@@ -102,6 +103,7 @@ declare function createPrompt<K extends string, I extends ZodObject<ZodRawShape>
|
|
|
102
103
|
schema: I;
|
|
103
104
|
component: AIComponent<z.infer<I>>;
|
|
104
105
|
evaluators?: EvaluatorFn<z.infer<I>, z.infer<O>>[];
|
|
106
|
+
metadata?: Record<string, any>;
|
|
105
107
|
outputParser: {
|
|
106
108
|
schema: O;
|
|
107
109
|
parse: (result: string) => z.infer<O>;
|
|
@@ -112,6 +114,7 @@ declare function createPrompt<K extends string, I extends ZodObject<ZodRawShape>
|
|
|
112
114
|
schema: I;
|
|
113
115
|
component: AIComponent<z.infer<I>>;
|
|
114
116
|
evaluators?: EvaluatorFn<z.infer<I>, string>[];
|
|
117
|
+
metadata?: Record<string, any>;
|
|
115
118
|
}): Prompt<z.infer<I>>;
|
|
116
119
|
declare function createChain<I extends ZodObject<ZodRawShape>, R>(config: {
|
|
117
120
|
run: (vars: z.infer<I>, context: RenderContext) => R;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RenderContext, L as LogImplementation, C as Context, A as AINode,
|
|
2
|
-
export {
|
|
1
|
+
import { R as RenderContext, L as LogImplementation, C as ContextValues, a as Context, A as AINode, b as AIComponent, E as EvaluatorFn, P as PromptParsed, c as Prompt, d as Chain } from './createElement-_dIoXoIE.js';
|
|
2
|
+
export { y as AIElement, f as AIFragment, j as AssistantMessage, B as BoundLogger, m as ChatCompletionError, n as ChatCompletionRequestPayloads, i as ChatCompletionRole, t as CombinedLogger, s as ConsoleLogger, F as EvaluatorResult, u as Literal, o as LogChatCompletionRequest, p as LogChatCompletionResponse, q as LogLevel, r as Logger, g as LoggerContext, N as NoopLogImplementation, O as OutputParser, G as PromptRenderResult, D as PropsOfAIComponent, w as RenderResult, z as Renderable, v as RenderableStream, k as RenderedConversationMessage, S as SystemMessage, U as UserMessage, x as attachedContextSymbol, l as computeUsage, e as createAIElement, h as createContext } from './createElement-_dIoXoIE.js';
|
|
3
3
|
import { OpenAI } from 'openai';
|
|
4
4
|
export { OpenAI as OpenAIClient } from 'openai';
|
|
5
5
|
import { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam, ChatCompletionAssistantMessageParam, ChatCompletionCreateParams } from 'openai/resources';
|
|
@@ -11,8 +11,9 @@ import { ZodObject, ZodRawShape, ZodTypeAny, ZodString, z } from 'zod';
|
|
|
11
11
|
type CreateRenderContextOptions = {
|
|
12
12
|
logger?: LogImplementation;
|
|
13
13
|
rootRenderId?: string;
|
|
14
|
+
contextValues?: ContextValues;
|
|
14
15
|
};
|
|
15
|
-
declare function createRenderContext({ logger, rootRenderId, }?: CreateRenderContextOptions): RenderContext;
|
|
16
|
+
declare function createRenderContext({ logger, rootRenderId, contextValues, }?: CreateRenderContextOptions): RenderContext;
|
|
16
17
|
|
|
17
18
|
type OpenAIChatCompletionRequest = OpenAI.Chat.Completions.ChatCompletionCreateParamsStreaming;
|
|
18
19
|
type OpenAIChatMessage = ChatCompletionSystemMessageParam | ChatCompletionUserMessageParam | ChatCompletionAssistantMessageParam;
|
|
@@ -102,6 +103,7 @@ declare function createPrompt<K extends string, I extends ZodObject<ZodRawShape>
|
|
|
102
103
|
schema: I;
|
|
103
104
|
component: AIComponent<z.infer<I>>;
|
|
104
105
|
evaluators?: EvaluatorFn<z.infer<I>, z.infer<O>>[];
|
|
106
|
+
metadata?: Record<string, any>;
|
|
105
107
|
outputParser: {
|
|
106
108
|
schema: O;
|
|
107
109
|
parse: (result: string) => z.infer<O>;
|
|
@@ -112,6 +114,7 @@ declare function createPrompt<K extends string, I extends ZodObject<ZodRawShape>
|
|
|
112
114
|
schema: I;
|
|
113
115
|
component: AIComponent<z.infer<I>>;
|
|
114
116
|
evaluators?: EvaluatorFn<z.infer<I>, string>[];
|
|
117
|
+
metadata?: Record<string, any>;
|
|
115
118
|
}): Prompt<z.infer<I>>;
|
|
116
119
|
declare function createChain<I extends ZodObject<ZodRawShape>, R>(config: {
|
|
117
120
|
run: (vars: z.infer<I>, context: RenderContext) => R;
|
package/dist/index.js
CHANGED
|
@@ -428,14 +428,16 @@ function Root() {
|
|
|
428
428
|
}
|
|
429
429
|
function createRenderContext({
|
|
430
430
|
logger = new NoopLogImplementation(),
|
|
431
|
-
rootRenderId = uuidv4()
|
|
431
|
+
rootRenderId = uuidv4(),
|
|
432
|
+
contextValues = {}
|
|
432
433
|
} = {}) {
|
|
433
434
|
return new StreamRenderContext(
|
|
434
435
|
null,
|
|
435
436
|
createAIElement(Root, {}),
|
|
436
437
|
rootRenderId,
|
|
437
438
|
{
|
|
438
|
-
[LoggerContext.key]: logger || LoggerContext.defaultValue
|
|
439
|
+
[LoggerContext.key]: logger || LoggerContext.defaultValue,
|
|
440
|
+
...contextValues
|
|
439
441
|
}
|
|
440
442
|
);
|
|
441
443
|
}
|
|
@@ -1331,20 +1333,29 @@ var import_tokenizer4 = require("@anthropic-ai/tokenizer");
|
|
|
1331
1333
|
// src/prompt/createPrompt.tsx
|
|
1332
1334
|
function createPrompt(config) {
|
|
1333
1335
|
if (config.outputParser) {
|
|
1334
|
-
const {
|
|
1336
|
+
const {
|
|
1337
|
+
key: key2,
|
|
1338
|
+
schema: schema2,
|
|
1339
|
+
outputParser,
|
|
1340
|
+
component: component2,
|
|
1341
|
+
evaluators: evaluators2 = [],
|
|
1342
|
+
metadata: metadata2 = {}
|
|
1343
|
+
} = config;
|
|
1335
1344
|
return {
|
|
1336
1345
|
key: key2,
|
|
1337
1346
|
component: component2,
|
|
1338
1347
|
outputParser,
|
|
1339
1348
|
schema: schema2,
|
|
1349
|
+
metadata: metadata2,
|
|
1340
1350
|
evaluators: evaluators2
|
|
1341
1351
|
};
|
|
1342
1352
|
}
|
|
1343
|
-
const { key, schema, component, evaluators = [] } = config;
|
|
1353
|
+
const { key, schema, component, evaluators = [], metadata = {} } = config;
|
|
1344
1354
|
return {
|
|
1345
1355
|
key,
|
|
1346
1356
|
component,
|
|
1347
1357
|
schema,
|
|
1358
|
+
metadata,
|
|
1348
1359
|
evaluators
|
|
1349
1360
|
};
|
|
1350
1361
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -341,14 +341,16 @@ function Root() {
|
|
|
341
341
|
}
|
|
342
342
|
function createRenderContext({
|
|
343
343
|
logger = new NoopLogImplementation(),
|
|
344
|
-
rootRenderId = uuidv4()
|
|
344
|
+
rootRenderId = uuidv4(),
|
|
345
|
+
contextValues = {}
|
|
345
346
|
} = {}) {
|
|
346
347
|
return new StreamRenderContext(
|
|
347
348
|
null,
|
|
348
349
|
createAIElement(Root, {}),
|
|
349
350
|
rootRenderId,
|
|
350
351
|
{
|
|
351
|
-
[LoggerContext.key]: logger || LoggerContext.defaultValue
|
|
352
|
+
[LoggerContext.key]: logger || LoggerContext.defaultValue,
|
|
353
|
+
...contextValues
|
|
352
354
|
}
|
|
353
355
|
);
|
|
354
356
|
}
|
|
@@ -1237,20 +1239,29 @@ import { countTokens as countAnthropicTokens } from "@anthropic-ai/tokenizer";
|
|
|
1237
1239
|
// src/prompt/createPrompt.tsx
|
|
1238
1240
|
function createPrompt(config) {
|
|
1239
1241
|
if (config.outputParser) {
|
|
1240
|
-
const {
|
|
1242
|
+
const {
|
|
1243
|
+
key: key2,
|
|
1244
|
+
schema: schema2,
|
|
1245
|
+
outputParser,
|
|
1246
|
+
component: component2,
|
|
1247
|
+
evaluators: evaluators2 = [],
|
|
1248
|
+
metadata: metadata2 = {}
|
|
1249
|
+
} = config;
|
|
1241
1250
|
return {
|
|
1242
1251
|
key: key2,
|
|
1243
1252
|
component: component2,
|
|
1244
1253
|
outputParser,
|
|
1245
1254
|
schema: schema2,
|
|
1255
|
+
metadata: metadata2,
|
|
1246
1256
|
evaluators: evaluators2
|
|
1247
1257
|
};
|
|
1248
1258
|
}
|
|
1249
|
-
const { key, schema, component, evaluators = [] } = config;
|
|
1259
|
+
const { key, schema, component, evaluators = [], metadata = {} } = config;
|
|
1250
1260
|
return {
|
|
1251
1261
|
key,
|
|
1252
1262
|
component,
|
|
1253
1263
|
schema,
|
|
1264
|
+
metadata,
|
|
1254
1265
|
evaluators
|
|
1255
1266
|
};
|
|
1256
1267
|
}
|
package/dist/jsx-runtime.d.mts
CHANGED
package/dist/jsx-runtime.d.ts
CHANGED