@gammatech/aijsx 0.8.1-dev.2024-05-24 → 0.9.0-dev.2024-05-28
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/index.d.mts +43 -52
- package/dist/index.d.ts +43 -52
- package/dist/index.js +422 -558
- package/dist/index.mjs +417 -547
- package/dist/{jsx-dev-runtime-Kh2H5_Cf.d.mts → jsx-dev-runtime-uCZBuaDe.d.mts} +60 -40
- package/dist/{jsx-dev-runtime-Kh2H5_Cf.d.ts → jsx-dev-runtime-uCZBuaDe.d.ts} +60 -40
- 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 +2 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,46 @@
|
|
|
1
|
-
import { R as RenderContext,
|
|
2
|
-
export {
|
|
1
|
+
import { L as LogChatCompletionRequest, A as AINode, C as ChatMessage, R as RenderContext, a as LogImplementation, S as SpanProcessor, b as ContextValues, c as Context, T as Tracer, d as ReadableSpan, e as SpanExporter, f as AIComponent, g as SpanAttributes, P as Prompt, h as ChatCompletionRequestPayloads, D as DebugMessage, E as EvaluatorResult, i as EvaluatorFn, j as PromptParsed, N as NotAsyncGenerator, F as FunctionChain, k as StreamChain, J as JSX } from './jsx-dev-runtime-uCZBuaDe.mjs';
|
|
2
|
+
export { G as AIElement, m as AIFragment, B as BoundLogger, o as ChatRole, w as CombinedLogger, v as ConsoleLogger, I as ImagePart, p as ImagePartProps, x as Literal, q as LogChatCompletionResponse, r as LogLevel, s as Logger, u as NoopLogImplementation, Y as OutputParser, K as PropsOfAIComponent, y as RenderResult, H as Renderable, Q as Span, M as SpanContext, U as SpanEvent, O as SpanStatus, W as TracingContext, V as TracingContextKey, X as TracingContextManager, z as attachedContextSymbol, l as createAIElement, n as createContext, t as toDebugMessage } from './jsx-dev-runtime-uCZBuaDe.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';
|
|
6
6
|
import { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam, ChatCompletionAssistantMessageParam, ChatCompletionCreateParams } from 'openai/resources';
|
|
7
7
|
import AnthropicClient from '@anthropic-ai/sdk';
|
|
8
8
|
export { default as AnthropicClient } from '@anthropic-ai/sdk';
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
declare class ChatCompletionError extends Error {
|
|
11
|
+
readonly chatCompletionRequest: LogChatCompletionRequest;
|
|
12
|
+
readonly status: number | undefined;
|
|
13
|
+
readonly shouldRetry: boolean;
|
|
14
|
+
readonly name = "ChatCompletionError";
|
|
15
|
+
constructor(message: string, chatCompletionRequest: LogChatCompletionRequest, status: number | undefined, shouldRetry?: boolean);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare const SystemMessage: (props: {
|
|
19
|
+
children: AINode;
|
|
20
|
+
}) => AINode;
|
|
21
|
+
declare const UserMessage: (props: {
|
|
22
|
+
children: AINode;
|
|
23
|
+
}) => AINode;
|
|
24
|
+
declare const AssistantMessage: (props: {
|
|
25
|
+
children: AINode;
|
|
26
|
+
}) => AINode;
|
|
27
|
+
|
|
28
|
+
type TokenizerFn = (message: ChatMessage) => number;
|
|
29
|
+
declare const computeUsage: (messages: ChatMessage[], tokenizer: TokenizerFn) => {
|
|
30
|
+
prompt: number;
|
|
31
|
+
completion: number;
|
|
32
|
+
total: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
type ChatCompletionClientAndProvider<K> = {
|
|
36
|
+
client: K;
|
|
37
|
+
provider?: string;
|
|
38
|
+
providerRegion?: string;
|
|
39
|
+
costFn?: (model: string, usage: {
|
|
40
|
+
prompt: number;
|
|
41
|
+
completion: number;
|
|
42
|
+
}) => number;
|
|
43
|
+
};
|
|
11
44
|
|
|
12
45
|
type CreateRenderContextOptions = {
|
|
13
46
|
logger?: LogImplementation;
|
|
@@ -129,7 +162,7 @@ declare namespace AISpanAttributes {
|
|
|
129
162
|
retryCount?: number;
|
|
130
163
|
requestType: K;
|
|
131
164
|
chatCompletionRequest: ChatCompletionRequestPayloads[K];
|
|
132
|
-
inputMessages:
|
|
165
|
+
inputMessages: DebugMessage[];
|
|
133
166
|
finishReason: string | null;
|
|
134
167
|
output: string;
|
|
135
168
|
tokensUsed: Usage;
|
|
@@ -138,7 +171,6 @@ declare namespace AISpanAttributes {
|
|
|
138
171
|
declare namespace ProcessedAISpanAttributes {
|
|
139
172
|
type Prompt = AISpanAttributes.Prompt & {
|
|
140
173
|
prompt: never;
|
|
141
|
-
evaluators: EvaluatorResult[];
|
|
142
174
|
evaluatorResults: Record<string, EvaluatorResult>;
|
|
143
175
|
evaluatorError?: string;
|
|
144
176
|
totalUsage?: Usage;
|
|
@@ -201,7 +233,8 @@ declare module '@gammatech/aijsx' {
|
|
|
201
233
|
openai: OpenAIChatCompletionRequest;
|
|
202
234
|
}
|
|
203
235
|
}
|
|
204
|
-
type
|
|
236
|
+
type ValidOpenAIVisionModel = 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo' | 'gpt-4-vision-preview';
|
|
237
|
+
type ValidOpenAIChatModel = ValidOpenAIVisionModel | 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-32k' | 'gpt-4-32k-0314' | 'gpt-4-32k-0613' | 'gpt-4-1106-preview' | 'gpt-4-0125-preview' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-0301' | 'gpt-3.5-turbo-0613' | 'gpt-3.5-turbo-16k' | 'gpt-3.5-turbo-16k-0613' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-0125';
|
|
205
238
|
declare const OpenAIClientContext: Context<() => ChatCompletionClientAndProvider<OpenAI>>;
|
|
206
239
|
type OpenAIChatCompletionProps = {
|
|
207
240
|
model: ValidOpenAIChatModel;
|
|
@@ -214,33 +247,7 @@ type OpenAIChatCompletionProps = {
|
|
|
214
247
|
};
|
|
215
248
|
declare function OpenAIChatCompletion(props: OpenAIChatCompletionProps, ctx: RenderContext): AINode;
|
|
216
249
|
|
|
217
|
-
|
|
218
|
-
declare const ContentTypeImage: (_props: {
|
|
219
|
-
url: string;
|
|
220
|
-
dimensions?: {
|
|
221
|
-
width: number;
|
|
222
|
-
height: number;
|
|
223
|
-
};
|
|
224
|
-
detail?: 'auto' | 'high' | 'low';
|
|
225
|
-
}) => null;
|
|
226
|
-
type OpenAIVisionChatCompletionProps = {
|
|
227
|
-
model?: ValidOpenAIVisionModel;
|
|
228
|
-
maxTokens?: number;
|
|
229
|
-
stop?: string | string[];
|
|
230
|
-
temperature?: number;
|
|
231
|
-
maxRetries?: number;
|
|
232
|
-
children: AINode;
|
|
233
|
-
};
|
|
234
|
-
declare function OpenAIVisionChatCompletion(props: OpenAIVisionChatCompletionProps, ctx: RenderContext): AINode;
|
|
235
|
-
declare function OpenAIVisionChatCompletionInner(props: OpenAIVisionChatCompletionProps, { logger, render, tracer, getContext }: RenderContext): AsyncGenerator<string, void, unknown>;
|
|
236
|
-
|
|
237
|
-
declare const tokenizer: {
|
|
238
|
-
encode: (text: string) => number[];
|
|
239
|
-
decode: (tokens: number[]) => string;
|
|
240
|
-
};
|
|
241
|
-
declare function tokenLimitForChatModel(model: ValidOpenAIChatModel): number | undefined;
|
|
242
|
-
declare function tokenCountForOpenAIMessage(message: OpenAIChatMessage): number;
|
|
243
|
-
declare function tokenCountForOpenAIVisionMessage(message: OpenAIChatMessage): number;
|
|
250
|
+
declare const openaiTokenizer: TokenizerFn;
|
|
244
251
|
|
|
245
252
|
type AnthropicChatCompletionRequest = AnthropicClient.Messages.MessageStreamParams;
|
|
246
253
|
declare module '@gammatech/aijsx' {
|
|
@@ -263,23 +270,7 @@ type AnthropicChatCompletionProps = {
|
|
|
263
270
|
children: AINode;
|
|
264
271
|
};
|
|
265
272
|
declare function AnthropicChatCompletion(props: AnthropicChatCompletionProps, ctx: RenderContext): JSX.Element;
|
|
266
|
-
/**
|
|
267
|
-
* An AI.JSX component that invokes an Anthropic Large Language Model.
|
|
268
|
-
* @param children The children to render.
|
|
269
|
-
* @param chatModel The chat model to use.
|
|
270
|
-
* @param completionModel The completion model to use.
|
|
271
|
-
* @param client The Anthropic client.
|
|
272
|
-
*/
|
|
273
|
-
declare function AnthropicChatCompletionInner(props: AnthropicChatCompletionProps, { render, logger, tracer, getContext }: RenderContext): AsyncGenerator<string, void, unknown>;
|
|
274
273
|
|
|
275
|
-
|
|
276
|
-
data: string;
|
|
277
|
-
mediaType: ImageBlockParam.Source['media_type'];
|
|
278
|
-
};
|
|
279
|
-
type ClaudeImageBlockUrl = {
|
|
280
|
-
url: string;
|
|
281
|
-
};
|
|
282
|
-
type ClaudeImageBlockProps = ClaudeImageBlockBase64 | ClaudeImageBlockUrl;
|
|
283
|
-
declare const ClaudeImageBlock: (props: ClaudeImageBlockProps) => Promise<JSX.Element>;
|
|
274
|
+
declare const anthropicTokenizer: TokenizerFn;
|
|
284
275
|
|
|
285
|
-
export { AIComponent, AINode, AISpanAttributes, AISpanProcessor, AnthropicChatCompletion,
|
|
276
|
+
export { AIComponent, AINode, AISpanAttributes, AISpanProcessor, AnthropicChatCompletion, type AnthropicChatCompletionRequest, AnthropicClientContext, AssistantMessage, type ChatCompletionClientAndProvider, ChatCompletionError, type ChatCompletionRequestPayloads, ChatMessage, Context, type CostFn, DebugMessage, DefaultMaxRetriesContext, EnrichingSpanProcessor, EvaluatorFn, EvaluatorResult, Fallback, FunctionChain, LogChatCompletionRequest, LogImplementation, NotAsyncGenerator, OpenAIChatCompletion, type OpenAIChatCompletionRequest, type OpenAIChatMessage, OpenAIClientContext, ParseVariablesError, ProcessedAISpanAttributes, type Prompt, PromptInvalidOutputError, PromptParsed, ReadableSpan, RenderContext, Retry, RetryCountContext, SpanAttributes, SpanExporter, SpanProcessor, StreamChain, SystemMessage, type TokenizerFn, Trace, Tracer, UserMessage, type ValidAnthropicChatModel, type ValidOpenAIChatModel, type ValidOpenAIVisionModel, anthropicTokenizer, computeUsage, createFunctionChain, createPrompt, createRenderContext, createStreamChain, evaluatePrompt, openaiTokenizer, tracing };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,46 @@
|
|
|
1
|
-
import { R as RenderContext,
|
|
2
|
-
export {
|
|
1
|
+
import { L as LogChatCompletionRequest, A as AINode, C as ChatMessage, R as RenderContext, a as LogImplementation, S as SpanProcessor, b as ContextValues, c as Context, T as Tracer, d as ReadableSpan, e as SpanExporter, f as AIComponent, g as SpanAttributes, P as Prompt, h as ChatCompletionRequestPayloads, D as DebugMessage, E as EvaluatorResult, i as EvaluatorFn, j as PromptParsed, N as NotAsyncGenerator, F as FunctionChain, k as StreamChain, J as JSX } from './jsx-dev-runtime-uCZBuaDe.js';
|
|
2
|
+
export { G as AIElement, m as AIFragment, B as BoundLogger, o as ChatRole, w as CombinedLogger, v as ConsoleLogger, I as ImagePart, p as ImagePartProps, x as Literal, q as LogChatCompletionResponse, r as LogLevel, s as Logger, u as NoopLogImplementation, Y as OutputParser, K as PropsOfAIComponent, y as RenderResult, H as Renderable, Q as Span, M as SpanContext, U as SpanEvent, O as SpanStatus, W as TracingContext, V as TracingContextKey, X as TracingContextManager, z as attachedContextSymbol, l as createAIElement, n as createContext, t as toDebugMessage } from './jsx-dev-runtime-uCZBuaDe.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';
|
|
6
6
|
import { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam, ChatCompletionAssistantMessageParam, ChatCompletionCreateParams } from 'openai/resources';
|
|
7
7
|
import AnthropicClient from '@anthropic-ai/sdk';
|
|
8
8
|
export { default as AnthropicClient } from '@anthropic-ai/sdk';
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
declare class ChatCompletionError extends Error {
|
|
11
|
+
readonly chatCompletionRequest: LogChatCompletionRequest;
|
|
12
|
+
readonly status: number | undefined;
|
|
13
|
+
readonly shouldRetry: boolean;
|
|
14
|
+
readonly name = "ChatCompletionError";
|
|
15
|
+
constructor(message: string, chatCompletionRequest: LogChatCompletionRequest, status: number | undefined, shouldRetry?: boolean);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare const SystemMessage: (props: {
|
|
19
|
+
children: AINode;
|
|
20
|
+
}) => AINode;
|
|
21
|
+
declare const UserMessage: (props: {
|
|
22
|
+
children: AINode;
|
|
23
|
+
}) => AINode;
|
|
24
|
+
declare const AssistantMessage: (props: {
|
|
25
|
+
children: AINode;
|
|
26
|
+
}) => AINode;
|
|
27
|
+
|
|
28
|
+
type TokenizerFn = (message: ChatMessage) => number;
|
|
29
|
+
declare const computeUsage: (messages: ChatMessage[], tokenizer: TokenizerFn) => {
|
|
30
|
+
prompt: number;
|
|
31
|
+
completion: number;
|
|
32
|
+
total: number;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
type ChatCompletionClientAndProvider<K> = {
|
|
36
|
+
client: K;
|
|
37
|
+
provider?: string;
|
|
38
|
+
providerRegion?: string;
|
|
39
|
+
costFn?: (model: string, usage: {
|
|
40
|
+
prompt: number;
|
|
41
|
+
completion: number;
|
|
42
|
+
}) => number;
|
|
43
|
+
};
|
|
11
44
|
|
|
12
45
|
type CreateRenderContextOptions = {
|
|
13
46
|
logger?: LogImplementation;
|
|
@@ -129,7 +162,7 @@ declare namespace AISpanAttributes {
|
|
|
129
162
|
retryCount?: number;
|
|
130
163
|
requestType: K;
|
|
131
164
|
chatCompletionRequest: ChatCompletionRequestPayloads[K];
|
|
132
|
-
inputMessages:
|
|
165
|
+
inputMessages: DebugMessage[];
|
|
133
166
|
finishReason: string | null;
|
|
134
167
|
output: string;
|
|
135
168
|
tokensUsed: Usage;
|
|
@@ -138,7 +171,6 @@ declare namespace AISpanAttributes {
|
|
|
138
171
|
declare namespace ProcessedAISpanAttributes {
|
|
139
172
|
type Prompt = AISpanAttributes.Prompt & {
|
|
140
173
|
prompt: never;
|
|
141
|
-
evaluators: EvaluatorResult[];
|
|
142
174
|
evaluatorResults: Record<string, EvaluatorResult>;
|
|
143
175
|
evaluatorError?: string;
|
|
144
176
|
totalUsage?: Usage;
|
|
@@ -201,7 +233,8 @@ declare module '@gammatech/aijsx' {
|
|
|
201
233
|
openai: OpenAIChatCompletionRequest;
|
|
202
234
|
}
|
|
203
235
|
}
|
|
204
|
-
type
|
|
236
|
+
type ValidOpenAIVisionModel = 'gpt-4o' | 'gpt-4o-2024-05-13' | 'gpt-4-turbo-2024-04-09' | 'gpt-4-turbo' | 'gpt-4-vision-preview';
|
|
237
|
+
type ValidOpenAIChatModel = ValidOpenAIVisionModel | 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-32k' | 'gpt-4-32k-0314' | 'gpt-4-32k-0613' | 'gpt-4-1106-preview' | 'gpt-4-0125-preview' | 'gpt-3.5-turbo' | 'gpt-3.5-turbo-0301' | 'gpt-3.5-turbo-0613' | 'gpt-3.5-turbo-16k' | 'gpt-3.5-turbo-16k-0613' | 'gpt-3.5-turbo-1106' | 'gpt-3.5-turbo-0125';
|
|
205
238
|
declare const OpenAIClientContext: Context<() => ChatCompletionClientAndProvider<OpenAI>>;
|
|
206
239
|
type OpenAIChatCompletionProps = {
|
|
207
240
|
model: ValidOpenAIChatModel;
|
|
@@ -214,33 +247,7 @@ type OpenAIChatCompletionProps = {
|
|
|
214
247
|
};
|
|
215
248
|
declare function OpenAIChatCompletion(props: OpenAIChatCompletionProps, ctx: RenderContext): AINode;
|
|
216
249
|
|
|
217
|
-
|
|
218
|
-
declare const ContentTypeImage: (_props: {
|
|
219
|
-
url: string;
|
|
220
|
-
dimensions?: {
|
|
221
|
-
width: number;
|
|
222
|
-
height: number;
|
|
223
|
-
};
|
|
224
|
-
detail?: 'auto' | 'high' | 'low';
|
|
225
|
-
}) => null;
|
|
226
|
-
type OpenAIVisionChatCompletionProps = {
|
|
227
|
-
model?: ValidOpenAIVisionModel;
|
|
228
|
-
maxTokens?: number;
|
|
229
|
-
stop?: string | string[];
|
|
230
|
-
temperature?: number;
|
|
231
|
-
maxRetries?: number;
|
|
232
|
-
children: AINode;
|
|
233
|
-
};
|
|
234
|
-
declare function OpenAIVisionChatCompletion(props: OpenAIVisionChatCompletionProps, ctx: RenderContext): AINode;
|
|
235
|
-
declare function OpenAIVisionChatCompletionInner(props: OpenAIVisionChatCompletionProps, { logger, render, tracer, getContext }: RenderContext): AsyncGenerator<string, void, unknown>;
|
|
236
|
-
|
|
237
|
-
declare const tokenizer: {
|
|
238
|
-
encode: (text: string) => number[];
|
|
239
|
-
decode: (tokens: number[]) => string;
|
|
240
|
-
};
|
|
241
|
-
declare function tokenLimitForChatModel(model: ValidOpenAIChatModel): number | undefined;
|
|
242
|
-
declare function tokenCountForOpenAIMessage(message: OpenAIChatMessage): number;
|
|
243
|
-
declare function tokenCountForOpenAIVisionMessage(message: OpenAIChatMessage): number;
|
|
250
|
+
declare const openaiTokenizer: TokenizerFn;
|
|
244
251
|
|
|
245
252
|
type AnthropicChatCompletionRequest = AnthropicClient.Messages.MessageStreamParams;
|
|
246
253
|
declare module '@gammatech/aijsx' {
|
|
@@ -263,23 +270,7 @@ type AnthropicChatCompletionProps = {
|
|
|
263
270
|
children: AINode;
|
|
264
271
|
};
|
|
265
272
|
declare function AnthropicChatCompletion(props: AnthropicChatCompletionProps, ctx: RenderContext): JSX.Element;
|
|
266
|
-
/**
|
|
267
|
-
* An AI.JSX component that invokes an Anthropic Large Language Model.
|
|
268
|
-
* @param children The children to render.
|
|
269
|
-
* @param chatModel The chat model to use.
|
|
270
|
-
* @param completionModel The completion model to use.
|
|
271
|
-
* @param client The Anthropic client.
|
|
272
|
-
*/
|
|
273
|
-
declare function AnthropicChatCompletionInner(props: AnthropicChatCompletionProps, { render, logger, tracer, getContext }: RenderContext): AsyncGenerator<string, void, unknown>;
|
|
274
273
|
|
|
275
|
-
|
|
276
|
-
data: string;
|
|
277
|
-
mediaType: ImageBlockParam.Source['media_type'];
|
|
278
|
-
};
|
|
279
|
-
type ClaudeImageBlockUrl = {
|
|
280
|
-
url: string;
|
|
281
|
-
};
|
|
282
|
-
type ClaudeImageBlockProps = ClaudeImageBlockBase64 | ClaudeImageBlockUrl;
|
|
283
|
-
declare const ClaudeImageBlock: (props: ClaudeImageBlockProps) => Promise<JSX.Element>;
|
|
274
|
+
declare const anthropicTokenizer: TokenizerFn;
|
|
284
275
|
|
|
285
|
-
export { AIComponent, AINode, AISpanAttributes, AISpanProcessor, AnthropicChatCompletion,
|
|
276
|
+
export { AIComponent, AINode, AISpanAttributes, AISpanProcessor, AnthropicChatCompletion, type AnthropicChatCompletionRequest, AnthropicClientContext, AssistantMessage, type ChatCompletionClientAndProvider, ChatCompletionError, type ChatCompletionRequestPayloads, ChatMessage, Context, type CostFn, DebugMessage, DefaultMaxRetriesContext, EnrichingSpanProcessor, EvaluatorFn, EvaluatorResult, Fallback, FunctionChain, LogChatCompletionRequest, LogImplementation, NotAsyncGenerator, OpenAIChatCompletion, type OpenAIChatCompletionRequest, type OpenAIChatMessage, OpenAIClientContext, ParseVariablesError, ProcessedAISpanAttributes, type Prompt, PromptInvalidOutputError, PromptParsed, ReadableSpan, RenderContext, Retry, RetryCountContext, SpanAttributes, SpanExporter, SpanProcessor, StreamChain, SystemMessage, type TokenizerFn, Trace, Tracer, UserMessage, type ValidAnthropicChatModel, type ValidOpenAIChatModel, type ValidOpenAIVisionModel, anthropicTokenizer, computeUsage, createFunctionChain, createPrompt, createRenderContext, createStreamChain, evaluatePrompt, openaiTokenizer, tracing };
|