@gammatech/aijsx 0.8.1-dev.2024-05-24.2 → 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 -51
- package/dist/index.d.ts +43 -51
- 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;
|
|
@@ -200,7 +233,8 @@ declare module '@gammatech/aijsx' {
|
|
|
200
233
|
openai: OpenAIChatCompletionRequest;
|
|
201
234
|
}
|
|
202
235
|
}
|
|
203
|
-
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';
|
|
204
238
|
declare const OpenAIClientContext: Context<() => ChatCompletionClientAndProvider<OpenAI>>;
|
|
205
239
|
type OpenAIChatCompletionProps = {
|
|
206
240
|
model: ValidOpenAIChatModel;
|
|
@@ -213,33 +247,7 @@ type OpenAIChatCompletionProps = {
|
|
|
213
247
|
};
|
|
214
248
|
declare function OpenAIChatCompletion(props: OpenAIChatCompletionProps, ctx: RenderContext): AINode;
|
|
215
249
|
|
|
216
|
-
|
|
217
|
-
declare const ContentTypeImage: (_props: {
|
|
218
|
-
url: string;
|
|
219
|
-
dimensions?: {
|
|
220
|
-
width: number;
|
|
221
|
-
height: number;
|
|
222
|
-
};
|
|
223
|
-
detail?: 'auto' | 'high' | 'low';
|
|
224
|
-
}) => null;
|
|
225
|
-
type OpenAIVisionChatCompletionProps = {
|
|
226
|
-
model?: ValidOpenAIVisionModel;
|
|
227
|
-
maxTokens?: number;
|
|
228
|
-
stop?: string | string[];
|
|
229
|
-
temperature?: number;
|
|
230
|
-
maxRetries?: number;
|
|
231
|
-
children: AINode;
|
|
232
|
-
};
|
|
233
|
-
declare function OpenAIVisionChatCompletion(props: OpenAIVisionChatCompletionProps, ctx: RenderContext): AINode;
|
|
234
|
-
declare function OpenAIVisionChatCompletionInner(props: OpenAIVisionChatCompletionProps, { logger, render, tracer, getContext }: RenderContext): AsyncGenerator<string, void, unknown>;
|
|
235
|
-
|
|
236
|
-
declare const tokenizer: {
|
|
237
|
-
encode: (text: string) => number[];
|
|
238
|
-
decode: (tokens: number[]) => string;
|
|
239
|
-
};
|
|
240
|
-
declare function tokenLimitForChatModel(model: ValidOpenAIChatModel): number | undefined;
|
|
241
|
-
declare function tokenCountForOpenAIMessage(message: OpenAIChatMessage): number;
|
|
242
|
-
declare function tokenCountForOpenAIVisionMessage(message: OpenAIChatMessage): number;
|
|
250
|
+
declare const openaiTokenizer: TokenizerFn;
|
|
243
251
|
|
|
244
252
|
type AnthropicChatCompletionRequest = AnthropicClient.Messages.MessageStreamParams;
|
|
245
253
|
declare module '@gammatech/aijsx' {
|
|
@@ -262,23 +270,7 @@ type AnthropicChatCompletionProps = {
|
|
|
262
270
|
children: AINode;
|
|
263
271
|
};
|
|
264
272
|
declare function AnthropicChatCompletion(props: AnthropicChatCompletionProps, ctx: RenderContext): JSX.Element;
|
|
265
|
-
/**
|
|
266
|
-
* An AI.JSX component that invokes an Anthropic Large Language Model.
|
|
267
|
-
* @param children The children to render.
|
|
268
|
-
* @param chatModel The chat model to use.
|
|
269
|
-
* @param completionModel The completion model to use.
|
|
270
|
-
* @param client The Anthropic client.
|
|
271
|
-
*/
|
|
272
|
-
declare function AnthropicChatCompletionInner(props: AnthropicChatCompletionProps, { render, logger, tracer, getContext }: RenderContext): AsyncGenerator<string, void, unknown>;
|
|
273
273
|
|
|
274
|
-
|
|
275
|
-
data: string;
|
|
276
|
-
mediaType: ImageBlockParam.Source['media_type'];
|
|
277
|
-
};
|
|
278
|
-
type ClaudeImageBlockUrl = {
|
|
279
|
-
url: string;
|
|
280
|
-
};
|
|
281
|
-
type ClaudeImageBlockProps = ClaudeImageBlockBase64 | ClaudeImageBlockUrl;
|
|
282
|
-
declare const ClaudeImageBlock: (props: ClaudeImageBlockProps) => Promise<JSX.Element>;
|
|
274
|
+
declare const anthropicTokenizer: TokenizerFn;
|
|
283
275
|
|
|
284
|
-
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;
|
|
@@ -200,7 +233,8 @@ declare module '@gammatech/aijsx' {
|
|
|
200
233
|
openai: OpenAIChatCompletionRequest;
|
|
201
234
|
}
|
|
202
235
|
}
|
|
203
|
-
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';
|
|
204
238
|
declare const OpenAIClientContext: Context<() => ChatCompletionClientAndProvider<OpenAI>>;
|
|
205
239
|
type OpenAIChatCompletionProps = {
|
|
206
240
|
model: ValidOpenAIChatModel;
|
|
@@ -213,33 +247,7 @@ type OpenAIChatCompletionProps = {
|
|
|
213
247
|
};
|
|
214
248
|
declare function OpenAIChatCompletion(props: OpenAIChatCompletionProps, ctx: RenderContext): AINode;
|
|
215
249
|
|
|
216
|
-
|
|
217
|
-
declare const ContentTypeImage: (_props: {
|
|
218
|
-
url: string;
|
|
219
|
-
dimensions?: {
|
|
220
|
-
width: number;
|
|
221
|
-
height: number;
|
|
222
|
-
};
|
|
223
|
-
detail?: 'auto' | 'high' | 'low';
|
|
224
|
-
}) => null;
|
|
225
|
-
type OpenAIVisionChatCompletionProps = {
|
|
226
|
-
model?: ValidOpenAIVisionModel;
|
|
227
|
-
maxTokens?: number;
|
|
228
|
-
stop?: string | string[];
|
|
229
|
-
temperature?: number;
|
|
230
|
-
maxRetries?: number;
|
|
231
|
-
children: AINode;
|
|
232
|
-
};
|
|
233
|
-
declare function OpenAIVisionChatCompletion(props: OpenAIVisionChatCompletionProps, ctx: RenderContext): AINode;
|
|
234
|
-
declare function OpenAIVisionChatCompletionInner(props: OpenAIVisionChatCompletionProps, { logger, render, tracer, getContext }: RenderContext): AsyncGenerator<string, void, unknown>;
|
|
235
|
-
|
|
236
|
-
declare const tokenizer: {
|
|
237
|
-
encode: (text: string) => number[];
|
|
238
|
-
decode: (tokens: number[]) => string;
|
|
239
|
-
};
|
|
240
|
-
declare function tokenLimitForChatModel(model: ValidOpenAIChatModel): number | undefined;
|
|
241
|
-
declare function tokenCountForOpenAIMessage(message: OpenAIChatMessage): number;
|
|
242
|
-
declare function tokenCountForOpenAIVisionMessage(message: OpenAIChatMessage): number;
|
|
250
|
+
declare const openaiTokenizer: TokenizerFn;
|
|
243
251
|
|
|
244
252
|
type AnthropicChatCompletionRequest = AnthropicClient.Messages.MessageStreamParams;
|
|
245
253
|
declare module '@gammatech/aijsx' {
|
|
@@ -262,23 +270,7 @@ type AnthropicChatCompletionProps = {
|
|
|
262
270
|
children: AINode;
|
|
263
271
|
};
|
|
264
272
|
declare function AnthropicChatCompletion(props: AnthropicChatCompletionProps, ctx: RenderContext): JSX.Element;
|
|
265
|
-
/**
|
|
266
|
-
* An AI.JSX component that invokes an Anthropic Large Language Model.
|
|
267
|
-
* @param children The children to render.
|
|
268
|
-
* @param chatModel The chat model to use.
|
|
269
|
-
* @param completionModel The completion model to use.
|
|
270
|
-
* @param client The Anthropic client.
|
|
271
|
-
*/
|
|
272
|
-
declare function AnthropicChatCompletionInner(props: AnthropicChatCompletionProps, { render, logger, tracer, getContext }: RenderContext): AsyncGenerator<string, void, unknown>;
|
|
273
273
|
|
|
274
|
-
|
|
275
|
-
data: string;
|
|
276
|
-
mediaType: ImageBlockParam.Source['media_type'];
|
|
277
|
-
};
|
|
278
|
-
type ClaudeImageBlockUrl = {
|
|
279
|
-
url: string;
|
|
280
|
-
};
|
|
281
|
-
type ClaudeImageBlockProps = ClaudeImageBlockBase64 | ClaudeImageBlockUrl;
|
|
282
|
-
declare const ClaudeImageBlock: (props: ClaudeImageBlockProps) => Promise<JSX.Element>;
|
|
274
|
+
declare const anthropicTokenizer: TokenizerFn;
|
|
283
275
|
|
|
284
|
-
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 };
|