@gammatech/aijsx 0.3.0-beta.10 → 0.3.0-beta.12
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-1mt9x5TT.d.mts → createElement-SURWK7y8.d.mts} +2 -2
- package/dist/{createElement-1mt9x5TT.d.ts → createElement-SURWK7y8.d.ts} +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -8
- package/dist/index.mjs +4 -8
- 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
|
@@ -100,8 +100,8 @@ interface RenderContext {
|
|
|
100
100
|
render<V extends Record<string, any>, O>(prompt: PromptParsed<V, O>, variables: V, options?: RenderPromptOptions): Promise<O>;
|
|
101
101
|
render<V extends Record<string, any>>(prompt: Prompt<V>, variables: V): RenderResult;
|
|
102
102
|
render<V extends Record<string, any>, O extends AsyncGenerator<any>>(chain: StreamChain<V, O>, variables: V): AsyncGenerator<O, void>;
|
|
103
|
-
render<V extends Record<string, any>, O>(chain: FunctionChain<V, O>, variables: V):
|
|
104
|
-
runChain<V extends Record<string, any>, R>(chain: FunctionChain<V, R>, variables: V):
|
|
103
|
+
render<V extends Record<string, any>, O>(chain: FunctionChain<V, O>, variables: V): O;
|
|
104
|
+
runChain<V extends Record<string, any>, R>(chain: FunctionChain<V, R>, variables: V): R;
|
|
105
105
|
runChain<V extends Record<string, any>, R extends AsyncGenerator<any>>(chain: StreamChain<V, R>, variables: V): R;
|
|
106
106
|
}
|
|
107
107
|
type RenderPromptOptions = {
|
|
@@ -100,8 +100,8 @@ interface RenderContext {
|
|
|
100
100
|
render<V extends Record<string, any>, O>(prompt: PromptParsed<V, O>, variables: V, options?: RenderPromptOptions): Promise<O>;
|
|
101
101
|
render<V extends Record<string, any>>(prompt: Prompt<V>, variables: V): RenderResult;
|
|
102
102
|
render<V extends Record<string, any>, O extends AsyncGenerator<any>>(chain: StreamChain<V, O>, variables: V): AsyncGenerator<O, void>;
|
|
103
|
-
render<V extends Record<string, any>, O>(chain: FunctionChain<V, O>, variables: V):
|
|
104
|
-
runChain<V extends Record<string, any>, R>(chain: FunctionChain<V, R>, variables: V):
|
|
103
|
+
render<V extends Record<string, any>, O>(chain: FunctionChain<V, O>, variables: V): O;
|
|
104
|
+
runChain<V extends Record<string, any>, R>(chain: FunctionChain<V, R>, variables: V): R;
|
|
105
105
|
runChain<V extends Record<string, any>, R extends AsyncGenerator<any>>(chain: StreamChain<V, R>, variables: V): R;
|
|
106
106
|
}
|
|
107
107
|
type RenderPromptOptions = {
|
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 { z as AIElement, e as AIFragment, j as AssistantMessage, B as BoundLogger, m as ChatCompletionError, n as ChatCompletionRequestPayloads, h as ChatCompletionRole, u as CombinedLogger, t as ConsoleLogger, H as EvaluatorResult, v as Literal, o as LogChatCompletionRequest, p as LogChatCompletionResponse, q as LogLevel, r as Logger, f as LoggerContext, s as NoopLogImplementation, O as OutputParser, I as PromptRenderResult, G as PropsOfAIComponent, x as RenderResult, D as Renderable, w as RenderableStream, k as RenderedConversationMessage, i as SystemMessage, U as UserMessage, y as attachedContextSymbol, l as computeUsage, d as createAIElement, g as createContext } from './createElement-
|
|
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-SURWK7y8.mjs';
|
|
2
|
+
export { z as AIElement, e as AIFragment, j as AssistantMessage, B as BoundLogger, m as ChatCompletionError, n as ChatCompletionRequestPayloads, h as ChatCompletionRole, u as CombinedLogger, t as ConsoleLogger, H as EvaluatorResult, v as Literal, o as LogChatCompletionRequest, p as LogChatCompletionResponse, q as LogLevel, r as Logger, f as LoggerContext, s as NoopLogImplementation, O as OutputParser, I as PromptRenderResult, G as PropsOfAIComponent, x as RenderResult, D as Renderable, w as RenderableStream, k as RenderedConversationMessage, i as SystemMessage, U as UserMessage, y as attachedContextSymbol, l as computeUsage, d as createAIElement, g as createContext } from './createElement-SURWK7y8.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 { z as AIElement, e as AIFragment, j as AssistantMessage, B as BoundLogger, m as ChatCompletionError, n as ChatCompletionRequestPayloads, h as ChatCompletionRole, u as CombinedLogger, t as ConsoleLogger, H as EvaluatorResult, v as Literal, o as LogChatCompletionRequest, p as LogChatCompletionResponse, q as LogLevel, r as Logger, f as LoggerContext, s as NoopLogImplementation, O as OutputParser, I as PromptRenderResult, G as PropsOfAIComponent, x as RenderResult, D as Renderable, w as RenderableStream, k as RenderedConversationMessage, i as SystemMessage, U as UserMessage, y as attachedContextSymbol, l as computeUsage, d as createAIElement, g as createContext } from './createElement-
|
|
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-SURWK7y8.js';
|
|
2
|
+
export { z as AIElement, e as AIFragment, j as AssistantMessage, B as BoundLogger, m as ChatCompletionError, n as ChatCompletionRequestPayloads, h as ChatCompletionRole, u as CombinedLogger, t as ConsoleLogger, H as EvaluatorResult, v as Literal, o as LogChatCompletionRequest, p as LogChatCompletionResponse, q as LogLevel, r as Logger, f as LoggerContext, s as NoopLogImplementation, O as OutputParser, I as PromptRenderResult, G as PropsOfAIComponent, x as RenderResult, D as Renderable, w as RenderableStream, k as RenderedConversationMessage, i as SystemMessage, U as UserMessage, y as attachedContextSymbol, l as computeUsage, d as createAIElement, g as createContext } from './createElement-SURWK7y8.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
|
@@ -576,6 +576,8 @@ var StreamRenderContext = class _StreamRenderContext {
|
|
|
576
576
|
const self = this;
|
|
577
577
|
const logImpl = this.getContext(LoggerContext);
|
|
578
578
|
this.logger = new BoundLogger(logImpl, this);
|
|
579
|
+
this.render = this.render.bind(this);
|
|
580
|
+
this.runChain = this.runChain.bind(this);
|
|
579
581
|
this.renderStream = async function* (renderable, opts) {
|
|
580
582
|
const preserveTags = opts.preserveTags ?? false;
|
|
581
583
|
const renderedProps = opts.renderedProps || {};
|
|
@@ -717,7 +719,6 @@ var StreamRenderContext = class _StreamRenderContext {
|
|
|
717
719
|
try {
|
|
718
720
|
parsedVariables = chain.schema.parse(variables);
|
|
719
721
|
} catch (e) {
|
|
720
|
-
console.log(e);
|
|
721
722
|
const err = e;
|
|
722
723
|
const errors = JSON.stringify(err.flatten());
|
|
723
724
|
throw new ChainParseVariablesError("Invalid input variables: " + errors);
|
|
@@ -735,12 +736,10 @@ var StreamRenderContext = class _StreamRenderContext {
|
|
|
735
736
|
};
|
|
736
737
|
// @internal
|
|
737
738
|
enter(element, renderId, newCtx) {
|
|
738
|
-
|
|
739
|
+
return new _StreamRenderContext(this, element, renderId, {
|
|
739
740
|
...this.contextValues,
|
|
740
741
|
...newCtx
|
|
741
742
|
});
|
|
742
|
-
context.render = context.render.bind(context);
|
|
743
|
-
return context;
|
|
744
743
|
}
|
|
745
744
|
};
|
|
746
745
|
function ContextValueProvider({ children }) {
|
|
@@ -830,9 +829,6 @@ function createPrompt(config) {
|
|
|
830
829
|
var import_zod2 = require("zod");
|
|
831
830
|
function createFunctionChain(chain) {
|
|
832
831
|
const { key, run, schema, outputSchema = import_zod2.z.any() } = chain;
|
|
833
|
-
const asyncRun = async (vars, context) => {
|
|
834
|
-
return run(vars, context);
|
|
835
|
-
};
|
|
836
832
|
return {
|
|
837
833
|
type: "function",
|
|
838
834
|
key,
|
|
@@ -840,7 +836,7 @@ function createFunctionChain(chain) {
|
|
|
840
836
|
messageSchema: null,
|
|
841
837
|
outputSchema,
|
|
842
838
|
// always make it async so RenderContext doesnt have a to guess
|
|
843
|
-
run
|
|
839
|
+
run
|
|
844
840
|
};
|
|
845
841
|
}
|
|
846
842
|
function createStreamChain(chain) {
|
package/dist/index.mjs
CHANGED
|
@@ -481,6 +481,8 @@ var StreamRenderContext = class _StreamRenderContext {
|
|
|
481
481
|
const self = this;
|
|
482
482
|
const logImpl = this.getContext(LoggerContext);
|
|
483
483
|
this.logger = new BoundLogger(logImpl, this);
|
|
484
|
+
this.render = this.render.bind(this);
|
|
485
|
+
this.runChain = this.runChain.bind(this);
|
|
484
486
|
this.renderStream = async function* (renderable, opts) {
|
|
485
487
|
const preserveTags = opts.preserveTags ?? false;
|
|
486
488
|
const renderedProps = opts.renderedProps || {};
|
|
@@ -622,7 +624,6 @@ var StreamRenderContext = class _StreamRenderContext {
|
|
|
622
624
|
try {
|
|
623
625
|
parsedVariables = chain.schema.parse(variables);
|
|
624
626
|
} catch (e) {
|
|
625
|
-
console.log(e);
|
|
626
627
|
const err = e;
|
|
627
628
|
const errors = JSON.stringify(err.flatten());
|
|
628
629
|
throw new ChainParseVariablesError("Invalid input variables: " + errors);
|
|
@@ -640,12 +641,10 @@ var StreamRenderContext = class _StreamRenderContext {
|
|
|
640
641
|
};
|
|
641
642
|
// @internal
|
|
642
643
|
enter(element, renderId, newCtx) {
|
|
643
|
-
|
|
644
|
+
return new _StreamRenderContext(this, element, renderId, {
|
|
644
645
|
...this.contextValues,
|
|
645
646
|
...newCtx
|
|
646
647
|
});
|
|
647
|
-
context.render = context.render.bind(context);
|
|
648
|
-
return context;
|
|
649
648
|
}
|
|
650
649
|
};
|
|
651
650
|
function ContextValueProvider({ children }) {
|
|
@@ -735,9 +734,6 @@ function createPrompt(config) {
|
|
|
735
734
|
import { z as z2 } from "zod";
|
|
736
735
|
function createFunctionChain(chain) {
|
|
737
736
|
const { key, run, schema, outputSchema = z2.any() } = chain;
|
|
738
|
-
const asyncRun = async (vars, context) => {
|
|
739
|
-
return run(vars, context);
|
|
740
|
-
};
|
|
741
737
|
return {
|
|
742
738
|
type: "function",
|
|
743
739
|
key,
|
|
@@ -745,7 +741,7 @@ function createFunctionChain(chain) {
|
|
|
745
741
|
messageSchema: null,
|
|
746
742
|
outputSchema,
|
|
747
743
|
// always make it async so RenderContext doesnt have a to guess
|
|
748
|
-
run
|
|
744
|
+
run
|
|
749
745
|
};
|
|
750
746
|
}
|
|
751
747
|
function createStreamChain(chain) {
|
package/dist/jsx-runtime.d.mts
CHANGED
package/dist/jsx-runtime.d.ts
CHANGED