@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.
@@ -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 Context as C, type EvaluatorResult as D, type EvaluatorFn as E, type PromptRenderResult as F, 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 AIComponent as a, type Prompt as b, type Chain as c, createAIElement as d, AIFragment as e, LoggerContext as f, createContext as g, type ChatCompletionRole as h, AssistantMessage as i, type RenderedConversationMessage as j, computeUsage as k, ChatCompletionError as l, type ChatCompletionRequestPayloads as m, type LogChatCompletionRequest as n, type LogChatCompletionResponse as o, type LogLevel as p, type Logger as q, ConsoleLogger as r, CombinedLogger as s, type Literal as t, type RenderableStream as u, type RenderResult as v, attachedContextSymbol as w, type AIElement as x, type Renderable as y, type PropsOfAIComponent as z };
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 Context as C, type EvaluatorResult as D, type EvaluatorFn as E, type PromptRenderResult as F, 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 AIComponent as a, type Prompt as b, type Chain as c, createAIElement as d, AIFragment as e, LoggerContext as f, createContext as g, type ChatCompletionRole as h, AssistantMessage as i, type RenderedConversationMessage as j, computeUsage as k, ChatCompletionError as l, type ChatCompletionRequestPayloads as m, type LogChatCompletionRequest as n, type LogChatCompletionResponse as o, type LogLevel as p, type Logger as q, ConsoleLogger as r, CombinedLogger as s, type Literal as t, type RenderableStream as u, type RenderResult as v, attachedContextSymbol as w, type AIElement as x, type Renderable as y, type PropsOfAIComponent as z };
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, a as AIComponent, E as EvaluatorFn, P as PromptParsed, b as Prompt, c as Chain } from './createElement-1aVf4hY2.mjs';
2
- export { x as AIElement, e as AIFragment, i as AssistantMessage, B as BoundLogger, l as ChatCompletionError, m as ChatCompletionRequestPayloads, h as ChatCompletionRole, s as CombinedLogger, r as ConsoleLogger, D as EvaluatorResult, t as Literal, n as LogChatCompletionRequest, o as LogChatCompletionResponse, p as LogLevel, q as Logger, f as LoggerContext, N as NoopLogImplementation, O as OutputParser, F as PromptRenderResult, z as PropsOfAIComponent, v as RenderResult, y as Renderable, u as RenderableStream, j as RenderedConversationMessage, S as SystemMessage, U as UserMessage, w as attachedContextSymbol, k as computeUsage, d as createAIElement, g as createContext } from './createElement-1aVf4hY2.mjs';
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, a as AIComponent, E as EvaluatorFn, P as PromptParsed, b as Prompt, c as Chain } from './createElement-1aVf4hY2.js';
2
- export { x as AIElement, e as AIFragment, i as AssistantMessage, B as BoundLogger, l as ChatCompletionError, m as ChatCompletionRequestPayloads, h as ChatCompletionRole, s as CombinedLogger, r as ConsoleLogger, D as EvaluatorResult, t as Literal, n as LogChatCompletionRequest, o as LogChatCompletionResponse, p as LogLevel, q as Logger, f as LoggerContext, N as NoopLogImplementation, O as OutputParser, F as PromptRenderResult, z as PropsOfAIComponent, v as RenderResult, y as Renderable, u as RenderableStream, j as RenderedConversationMessage, S as SystemMessage, U as UserMessage, w as attachedContextSymbol, k as computeUsage, d as createAIElement, g as createContext } from './createElement-1aVf4hY2.js';
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 { key: key2, schema: schema2, outputParser, component: component2, evaluators: evaluators2 = [] } = config;
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 { key: key2, schema: schema2, outputParser, component: component2, evaluators: evaluators2 = [] } = config;
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
  }
@@ -1,3 +1,3 @@
1
1
  export { Fragment, JSX, jsx, jsxDEV, jsxs } from './jsx-runtime.mjs';
2
- import './createElement-1aVf4hY2.mjs';
2
+ import './createElement-_dIoXoIE.mjs';
3
3
  import 'zod';
@@ -1,3 +1,3 @@
1
1
  export { Fragment, JSX, jsx, jsxDEV, jsxs } from './jsx-runtime.js';
2
- import './createElement-1aVf4hY2.js';
2
+ import './createElement-_dIoXoIE.js';
3
3
  import 'zod';
@@ -1,4 +1,4 @@
1
- import { a as AIComponent, x as AIElement, e as AIFragment } from './createElement-1aVf4hY2.mjs';
1
+ import { b as AIComponent, y as AIElement, f as AIFragment } from './createElement-_dIoXoIE.mjs';
2
2
  import 'zod';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { a as AIComponent, x as AIElement, e as AIFragment } from './createElement-1aVf4hY2.js';
1
+ import { b as AIComponent, y as AIElement, f as AIFragment } from './createElement-_dIoXoIE.js';
2
2
  import 'zod';
3
3
 
4
4
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gammatech/aijsx",
3
- "version": "0.3.0-beta.3",
3
+ "version": "0.3.0-beta.5",
4
4
  "description": "Rewrite of aijsx",
5
5
  "author": "Jordan Garcia",
6
6
  "license": "MIT",