@gammatech/aijsx 0.2.0-vision.2 → 0.3.0-beta.1
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/{chunk-7GA5BUUP.mjs → chunk-2JPDWMO2.mjs} +9 -17
- package/dist/chunk-LWRCGF5O.mjs +22 -0
- package/dist/{createElement-y5NHsp6D.d.mts → createElement-jIxJ-zr7.d.mts} +36 -22
- package/dist/{createElement-y5NHsp6D.d.ts → createElement-jIxJ-zr7.d.ts} +36 -22
- package/dist/index.d.mts +29 -16
- package/dist/index.d.ts +29 -16
- package/dist/index.js +555 -192
- package/dist/index.mjs +543 -179
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-dev-runtime.js +5 -2
- package/dist/jsx-dev-runtime.mjs +2 -1
- package/dist/jsx-runtime.d.mts +8 -5
- package/dist/jsx-runtime.d.ts +8 -5
- package/dist/jsx-runtime.js +5 -2
- package/dist/jsx-runtime.mjs +2 -1
- package/package.json +2 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/createElement.ts
|
|
2
|
-
|
|
2
|
+
var parseAsString = (result) => result;
|
|
3
|
+
function createAIElement(tag, props, children) {
|
|
3
4
|
const propsToPass = {
|
|
4
5
|
...props ?? {},
|
|
5
6
|
...children.length === 0 ? {} : { children: children.length === 1 ? children[0] : children }
|
|
@@ -7,14 +8,18 @@ function createAIElement(tag, props, ...children) {
|
|
|
7
8
|
const result = {
|
|
8
9
|
tag,
|
|
9
10
|
props: propsToPass,
|
|
11
|
+
parse: "parse" in tag ? tag.parse : parseAsString,
|
|
10
12
|
render: (ctx) => {
|
|
11
13
|
return tag(propsToPass, ctx);
|
|
12
14
|
}
|
|
13
15
|
};
|
|
14
16
|
return result;
|
|
15
17
|
}
|
|
18
|
+
function isParsedAIElement(value) {
|
|
19
|
+
return value !== null && typeof value === "object" && "tag" in value && "parse" in value && "render" in value;
|
|
20
|
+
}
|
|
16
21
|
function isAIElement(value) {
|
|
17
|
-
return value !== null && typeof value === "object" && "tag" in value;
|
|
22
|
+
return value !== null && typeof value === "object" && "tag" in value && "render" in value;
|
|
18
23
|
}
|
|
19
24
|
function isLiteral(value) {
|
|
20
25
|
return typeof value === "string" || typeof value === "number" || typeof value === "undefined" || typeof value === "boolean" || // capture null + undefined
|
|
@@ -24,23 +29,10 @@ function AIFragment({ children }) {
|
|
|
24
29
|
return children;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
// src/jsx-runtime.ts
|
|
28
|
-
function jsx(type, config, maybeKey) {
|
|
29
|
-
const configWithKey = maybeKey !== void 0 ? { ...config, key: maybeKey } : config;
|
|
30
|
-
const children = config && Array.isArray(config.children) ? config.children : [];
|
|
31
|
-
return createAIElement(type, configWithKey, ...children);
|
|
32
|
-
}
|
|
33
|
-
var jsxDEV = jsx;
|
|
34
|
-
var jsxs = jsx;
|
|
35
|
-
var Fragment = AIFragment;
|
|
36
|
-
|
|
37
32
|
export {
|
|
38
33
|
createAIElement,
|
|
34
|
+
isParsedAIElement,
|
|
39
35
|
isAIElement,
|
|
40
36
|
isLiteral,
|
|
41
|
-
AIFragment
|
|
42
|
-
jsx,
|
|
43
|
-
jsxDEV,
|
|
44
|
-
jsxs,
|
|
45
|
-
Fragment
|
|
37
|
+
AIFragment
|
|
46
38
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AIFragment,
|
|
3
|
+
createAIElement
|
|
4
|
+
} from "./chunk-2JPDWMO2.mjs";
|
|
5
|
+
|
|
6
|
+
// src/jsx-runtime.ts
|
|
7
|
+
function jsx(type, config, maybeKey) {
|
|
8
|
+
const configWithKey = maybeKey !== void 0 ? { ...config, key: maybeKey } : config;
|
|
9
|
+
const children = config && Array.isArray(config.children) ? config.children : [];
|
|
10
|
+
const res = createAIElement(type, configWithKey, children);
|
|
11
|
+
return res;
|
|
12
|
+
}
|
|
13
|
+
var jsxDEV = jsx;
|
|
14
|
+
var jsxs = jsx;
|
|
15
|
+
var Fragment = AIFragment;
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
jsx,
|
|
19
|
+
jsxDEV,
|
|
20
|
+
jsxs,
|
|
21
|
+
Fragment
|
|
22
|
+
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
type Literal = string | number | null | undefined | boolean;
|
|
2
|
+
type JSONSerializable = string | number | boolean | null | JSONSerializable[] | {
|
|
3
|
+
[key: string]: JSONSerializable;
|
|
4
|
+
};
|
|
2
5
|
interface RenderableStream {
|
|
3
6
|
[Symbol.asyncIterator]: () => AsyncGenerator<string, void, unknown>;
|
|
4
7
|
}
|
|
@@ -9,34 +12,53 @@ interface Context<T> {
|
|
|
9
12
|
Provider: AIComponent<{
|
|
10
13
|
children: AINode;
|
|
11
14
|
value: T;
|
|
12
|
-
}>;
|
|
15
|
+
}, string>;
|
|
13
16
|
defaultValue: T;
|
|
14
17
|
key: symbol;
|
|
15
18
|
}
|
|
16
|
-
|
|
19
|
+
interface AIComponentString<P, _Result extends string> {
|
|
20
|
+
(props: P, context: RenderContext): Renderable;
|
|
21
|
+
}
|
|
22
|
+
interface AIComponentParsed<P, ParsedResult extends JSONSerializable = string> {
|
|
23
|
+
(props: P, context: RenderContext): Renderable;
|
|
24
|
+
parse: (result: string) => ParsedResult;
|
|
25
|
+
}
|
|
26
|
+
type AINode = Literal | AIElement<AIComponent<any, any>> | AINode[];
|
|
27
|
+
type Renderable = AINode | PromiseLike<Renderable> | RenderableStream;
|
|
28
|
+
type AIComponent<P, R extends string | JSONSerializable> = R extends string ? AIComponentString<P, R> : R extends JSONSerializable ? AIComponentParsed<P, R> : never;
|
|
17
29
|
declare const attachedContextSymbol: unique symbol;
|
|
18
|
-
interface AIElement<
|
|
30
|
+
interface AIElement<C extends AIComponent<any, any>> {
|
|
19
31
|
/** The tag associated with this {@link AIElement}. */
|
|
20
|
-
tag:
|
|
32
|
+
tag: C;
|
|
21
33
|
/** The component properties. */
|
|
22
|
-
props:
|
|
34
|
+
props: PropsOfAIComponent<C>;
|
|
23
35
|
/** A function that renders this {@link AIElement} to a {@link Renderable}. */
|
|
24
36
|
render: (ctx: RenderContext) => Renderable;
|
|
37
|
+
parse: (result: string) => ParsedTypeOfAIComponent<C>;
|
|
25
38
|
/** The {@link RenderContext} associated with this {@link Element}. */
|
|
26
39
|
[attachedContextSymbol]?: Record<symbol, any>;
|
|
27
40
|
}
|
|
28
|
-
type
|
|
29
|
-
type
|
|
30
|
-
type
|
|
41
|
+
type PropsOfAIComponent<T extends AIComponent<any, any>> = T extends AIComponent<infer P, any> ? P : never;
|
|
42
|
+
type ParsedTypeOfAIComponent<T extends AIComponent<any, any>> = T extends AIComponent<any, infer P> ? P : never;
|
|
43
|
+
type ParsedTypeOfRenderable<R extends Renderable> = R extends AIElement<infer C> ? C extends AIComponentParsed<any, infer U> ? U : string : string;
|
|
31
44
|
|
|
32
45
|
declare const LoggerContext: Context<LogImplementation>;
|
|
46
|
+
type RenderOptions = {
|
|
47
|
+
preserveTags?: boolean;
|
|
48
|
+
renderedProps?: {
|
|
49
|
+
[tagName: string]: {
|
|
50
|
+
[propName: string]: boolean;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
33
54
|
interface RenderContext {
|
|
34
55
|
parentContext: RenderContext | null;
|
|
35
|
-
element: AIElement<any
|
|
56
|
+
element: AIElement<AIComponent<any, any>>;
|
|
36
57
|
renderId: string;
|
|
37
58
|
logger: Logger;
|
|
38
59
|
getContext<T>(context: Context<T>): T;
|
|
39
|
-
render(renderable: Renderable): RenderResult;
|
|
60
|
+
render(renderable: Renderable, opts?: RenderOptions): RenderResult;
|
|
61
|
+
renderJson<R extends Renderable>(renderable: R): Promise<ParsedTypeOfRenderable<R>>;
|
|
40
62
|
}
|
|
41
63
|
declare function createContext<T>(defaultValue: T): Context<T>;
|
|
42
64
|
|
|
@@ -126,16 +148,11 @@ declare const UserMessage: (props: {
|
|
|
126
148
|
declare const AssistantMessage: (props: {
|
|
127
149
|
children: AINode;
|
|
128
150
|
}) => AINode;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
element: AIElement<PropsOfAIComponent<C>>;
|
|
132
|
-
}
|
|
133
|
-
type ConversationMessage = ConversationMessageType<'user', typeof UserMessage> | ConversationMessageType<'assistant', typeof AssistantMessage> | ConversationMessageType<'system', typeof SystemMessage>;
|
|
134
|
-
type RenderedConversationMessage = ConversationMessage & {
|
|
151
|
+
type RenderedConversationMessage = {
|
|
152
|
+
role: ChatCompletionRole;
|
|
135
153
|
content: string;
|
|
136
154
|
tokens: number;
|
|
137
155
|
};
|
|
138
|
-
declare const childrenToConversationMessage: (c: AIElement<any> | AIElement<any>[]) => ConversationMessage[];
|
|
139
156
|
declare const computeUsage: (messages: RenderedConversationMessage[]) => {
|
|
140
157
|
prompt: number;
|
|
141
158
|
completion: number;
|
|
@@ -146,14 +163,11 @@ declare class ChatCompletionError extends Error {
|
|
|
146
163
|
constructor(message: string, chatCompletionRequest: LogChatCompletionRequest);
|
|
147
164
|
}
|
|
148
165
|
|
|
149
|
-
declare function createAIElement<P extends {
|
|
150
|
-
children: C;
|
|
151
|
-
}, C>(tag: AIComponent<P>, props: Omit<P, 'children'> | null, ...children: [C]): AIElement<P>;
|
|
152
166
|
declare function createAIElement<P extends {
|
|
153
167
|
children: C[];
|
|
154
|
-
}, C
|
|
168
|
+
}, C, T extends AIComponent<P, any>>(tag: T, props: Omit<P, 'children'> | null, children: C[]): AIElement<T>;
|
|
155
169
|
declare function AIFragment({ children }: {
|
|
156
170
|
children: AINode;
|
|
157
171
|
}): Renderable;
|
|
158
172
|
|
|
159
|
-
export { type
|
|
173
|
+
export { type AINode as A, BoundLogger as B, type Context as C, type ParsedTypeOfRenderable as D, type JSONSerializable as J, LogImplementation as L, NoopLogImplementation as N, type PropsOfAIComponent as P, type RenderContext as R, SystemMessage as S, UserMessage as U, AIFragment as a, LoggerContext as b, createAIElement as c, createContext as d, type ChatCompletionRole as e, AssistantMessage as f, type RenderedConversationMessage as g, computeUsage as h, ChatCompletionError as i, type ChatCompletionRequestPayloads as j, type LogChatCompletionRequest as k, type LogChatCompletionResponse as l, type LogLevel as m, type Logger as n, ConsoleLogger as o, CombinedLogger as p, type Literal as q, type RenderableStream as r, type RenderResult as s, type AIComponentString as t, type AIComponentParsed as u, type Renderable as v, type AIComponent as w, attachedContextSymbol as x, type AIElement as y, type ParsedTypeOfAIComponent as z };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
type Literal = string | number | null | undefined | boolean;
|
|
2
|
+
type JSONSerializable = string | number | boolean | null | JSONSerializable[] | {
|
|
3
|
+
[key: string]: JSONSerializable;
|
|
4
|
+
};
|
|
2
5
|
interface RenderableStream {
|
|
3
6
|
[Symbol.asyncIterator]: () => AsyncGenerator<string, void, unknown>;
|
|
4
7
|
}
|
|
@@ -9,34 +12,53 @@ interface Context<T> {
|
|
|
9
12
|
Provider: AIComponent<{
|
|
10
13
|
children: AINode;
|
|
11
14
|
value: T;
|
|
12
|
-
}>;
|
|
15
|
+
}, string>;
|
|
13
16
|
defaultValue: T;
|
|
14
17
|
key: symbol;
|
|
15
18
|
}
|
|
16
|
-
|
|
19
|
+
interface AIComponentString<P, _Result extends string> {
|
|
20
|
+
(props: P, context: RenderContext): Renderable;
|
|
21
|
+
}
|
|
22
|
+
interface AIComponentParsed<P, ParsedResult extends JSONSerializable = string> {
|
|
23
|
+
(props: P, context: RenderContext): Renderable;
|
|
24
|
+
parse: (result: string) => ParsedResult;
|
|
25
|
+
}
|
|
26
|
+
type AINode = Literal | AIElement<AIComponent<any, any>> | AINode[];
|
|
27
|
+
type Renderable = AINode | PromiseLike<Renderable> | RenderableStream;
|
|
28
|
+
type AIComponent<P, R extends string | JSONSerializable> = R extends string ? AIComponentString<P, R> : R extends JSONSerializable ? AIComponentParsed<P, R> : never;
|
|
17
29
|
declare const attachedContextSymbol: unique symbol;
|
|
18
|
-
interface AIElement<
|
|
30
|
+
interface AIElement<C extends AIComponent<any, any>> {
|
|
19
31
|
/** The tag associated with this {@link AIElement}. */
|
|
20
|
-
tag:
|
|
32
|
+
tag: C;
|
|
21
33
|
/** The component properties. */
|
|
22
|
-
props:
|
|
34
|
+
props: PropsOfAIComponent<C>;
|
|
23
35
|
/** A function that renders this {@link AIElement} to a {@link Renderable}. */
|
|
24
36
|
render: (ctx: RenderContext) => Renderable;
|
|
37
|
+
parse: (result: string) => ParsedTypeOfAIComponent<C>;
|
|
25
38
|
/** The {@link RenderContext} associated with this {@link Element}. */
|
|
26
39
|
[attachedContextSymbol]?: Record<symbol, any>;
|
|
27
40
|
}
|
|
28
|
-
type
|
|
29
|
-
type
|
|
30
|
-
type
|
|
41
|
+
type PropsOfAIComponent<T extends AIComponent<any, any>> = T extends AIComponent<infer P, any> ? P : never;
|
|
42
|
+
type ParsedTypeOfAIComponent<T extends AIComponent<any, any>> = T extends AIComponent<any, infer P> ? P : never;
|
|
43
|
+
type ParsedTypeOfRenderable<R extends Renderable> = R extends AIElement<infer C> ? C extends AIComponentParsed<any, infer U> ? U : string : string;
|
|
31
44
|
|
|
32
45
|
declare const LoggerContext: Context<LogImplementation>;
|
|
46
|
+
type RenderOptions = {
|
|
47
|
+
preserveTags?: boolean;
|
|
48
|
+
renderedProps?: {
|
|
49
|
+
[tagName: string]: {
|
|
50
|
+
[propName: string]: boolean;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
33
54
|
interface RenderContext {
|
|
34
55
|
parentContext: RenderContext | null;
|
|
35
|
-
element: AIElement<any
|
|
56
|
+
element: AIElement<AIComponent<any, any>>;
|
|
36
57
|
renderId: string;
|
|
37
58
|
logger: Logger;
|
|
38
59
|
getContext<T>(context: Context<T>): T;
|
|
39
|
-
render(renderable: Renderable): RenderResult;
|
|
60
|
+
render(renderable: Renderable, opts?: RenderOptions): RenderResult;
|
|
61
|
+
renderJson<R extends Renderable>(renderable: R): Promise<ParsedTypeOfRenderable<R>>;
|
|
40
62
|
}
|
|
41
63
|
declare function createContext<T>(defaultValue: T): Context<T>;
|
|
42
64
|
|
|
@@ -126,16 +148,11 @@ declare const UserMessage: (props: {
|
|
|
126
148
|
declare const AssistantMessage: (props: {
|
|
127
149
|
children: AINode;
|
|
128
150
|
}) => AINode;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
element: AIElement<PropsOfAIComponent<C>>;
|
|
132
|
-
}
|
|
133
|
-
type ConversationMessage = ConversationMessageType<'user', typeof UserMessage> | ConversationMessageType<'assistant', typeof AssistantMessage> | ConversationMessageType<'system', typeof SystemMessage>;
|
|
134
|
-
type RenderedConversationMessage = ConversationMessage & {
|
|
151
|
+
type RenderedConversationMessage = {
|
|
152
|
+
role: ChatCompletionRole;
|
|
135
153
|
content: string;
|
|
136
154
|
tokens: number;
|
|
137
155
|
};
|
|
138
|
-
declare const childrenToConversationMessage: (c: AIElement<any> | AIElement<any>[]) => ConversationMessage[];
|
|
139
156
|
declare const computeUsage: (messages: RenderedConversationMessage[]) => {
|
|
140
157
|
prompt: number;
|
|
141
158
|
completion: number;
|
|
@@ -146,14 +163,11 @@ declare class ChatCompletionError extends Error {
|
|
|
146
163
|
constructor(message: string, chatCompletionRequest: LogChatCompletionRequest);
|
|
147
164
|
}
|
|
148
165
|
|
|
149
|
-
declare function createAIElement<P extends {
|
|
150
|
-
children: C;
|
|
151
|
-
}, C>(tag: AIComponent<P>, props: Omit<P, 'children'> | null, ...children: [C]): AIElement<P>;
|
|
152
166
|
declare function createAIElement<P extends {
|
|
153
167
|
children: C[];
|
|
154
|
-
}, C
|
|
168
|
+
}, C, T extends AIComponent<P, any>>(tag: T, props: Omit<P, 'children'> | null, children: C[]): AIElement<T>;
|
|
155
169
|
declare function AIFragment({ children }: {
|
|
156
170
|
children: AINode;
|
|
157
171
|
}): Renderable;
|
|
158
172
|
|
|
159
|
-
export { type
|
|
173
|
+
export { type AINode as A, BoundLogger as B, type Context as C, type ParsedTypeOfRenderable as D, type JSONSerializable as J, LogImplementation as L, NoopLogImplementation as N, type PropsOfAIComponent as P, type RenderContext as R, SystemMessage as S, UserMessage as U, AIFragment as a, LoggerContext as b, createAIElement as c, createContext as d, type ChatCompletionRole as e, AssistantMessage as f, type RenderedConversationMessage as g, computeUsage as h, ChatCompletionError as i, type ChatCompletionRequestPayloads as j, type LogChatCompletionRequest as k, type LogChatCompletionResponse as l, type LogLevel as m, type Logger as n, ConsoleLogger as o, CombinedLogger as p, type Literal as q, type RenderableStream as r, type RenderResult as s, type AIComponentString as t, type AIComponentParsed as u, type Renderable as v, type AIComponent as w, attachedContextSymbol as x, type AIElement as y, type ParsedTypeOfAIComponent as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { L as LogImplementation, R as RenderContext,
|
|
2
|
-
export {
|
|
1
|
+
import { L as LogImplementation, R as RenderContext, C as Context, A as AINode } from './createElement-jIxJ-zr7.mjs';
|
|
2
|
+
export { w as AIComponent, u as AIComponentParsed, t as AIComponentString, y as AIElement, a as AIFragment, f as AssistantMessage, B as BoundLogger, i as ChatCompletionError, j as ChatCompletionRequestPayloads, e as ChatCompletionRole, p as CombinedLogger, o as ConsoleLogger, J as JSONSerializable, q as Literal, k as LogChatCompletionRequest, l as LogChatCompletionResponse, m as LogLevel, n as Logger, b as LoggerContext, N as NoopLogImplementation, z as ParsedTypeOfAIComponent, D as ParsedTypeOfRenderable, P as PropsOfAIComponent, s as RenderResult, v as Renderable, r as RenderableStream, g as RenderedConversationMessage, S as SystemMessage, U as UserMessage, x as attachedContextSymbol, h as computeUsage, c as createAIElement, d as createContext } from './createElement-jIxJ-zr7.mjs';
|
|
3
3
|
import { OpenAI } from 'openai';
|
|
4
4
|
export { OpenAI as OpenAIClient } from 'openai';
|
|
5
|
-
import { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam, ChatCompletionAssistantMessageParam } from 'openai/resources';
|
|
5
|
+
import { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam, ChatCompletionAssistantMessageParam, ChatCompletionCreateParams } from 'openai/resources';
|
|
6
6
|
import AnthropicClient from '@anthropic-ai/sdk';
|
|
7
7
|
export { default as AnthropicClient } from '@anthropic-ai/sdk';
|
|
8
8
|
export { countTokens as countAnthropicTokens } from '@anthropic-ai/tokenizer';
|
|
@@ -19,32 +19,45 @@ declare module '@gammatech/aijsx' {
|
|
|
19
19
|
openai: OpenAIChatCompletionRequest;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
type
|
|
23
|
-
children: AINode;
|
|
24
|
-
images: {
|
|
25
|
-
url: string;
|
|
26
|
-
detail?: 'low' | 'high' | 'auto';
|
|
27
|
-
}[];
|
|
28
|
-
};
|
|
29
|
-
declare const UserMessageWithImages: AIComponent<UserMessageWithImagesProps>;
|
|
30
|
-
type ValidOpenAIChatModel = 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-32k' | 'gpt-4-32k-0314' | 'gpt-4-32k-0613' | 'gpt-4-1106-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-4-vision-preview';
|
|
22
|
+
type ValidOpenAIChatModel = 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-32k' | 'gpt-4-32k-0314' | 'gpt-4-32k-0613' | 'gpt-4-1106-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';
|
|
31
23
|
declare const OpenAIClientContext: Context<() => OpenAI>;
|
|
32
24
|
type OpenAIChatCompletionProps = {
|
|
33
25
|
model: ValidOpenAIChatModel;
|
|
34
26
|
maxTokens?: number;
|
|
35
27
|
temperature?: number;
|
|
36
|
-
|
|
28
|
+
responseFormat?: ChatCompletionCreateParams.ResponseFormat['type'];
|
|
29
|
+
children: AINode;
|
|
37
30
|
provider?: string;
|
|
38
31
|
providerRegion?: string;
|
|
39
32
|
};
|
|
40
33
|
declare function OpenAIChatCompletion(props: OpenAIChatCompletionProps, { logger, render, getContext }: RenderContext): AsyncGenerator<string, void, unknown>;
|
|
41
34
|
|
|
35
|
+
type ValidOpenAIVisionModel = 'gpt-4-vision-preview';
|
|
36
|
+
declare const ContentTypeImage: (_props: {
|
|
37
|
+
url: string;
|
|
38
|
+
dimensions?: {
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
};
|
|
42
|
+
detail?: 'auto' | 'high' | 'low';
|
|
43
|
+
}) => null;
|
|
44
|
+
type OpenAIVisionChatCompletionProps = {
|
|
45
|
+
model?: ValidOpenAIVisionModel;
|
|
46
|
+
maxTokens?: number;
|
|
47
|
+
temperature?: number;
|
|
48
|
+
children: AINode;
|
|
49
|
+
provider?: string;
|
|
50
|
+
providerRegion?: string;
|
|
51
|
+
};
|
|
52
|
+
declare function OpenAIVisionChatCompletion(props: OpenAIVisionChatCompletionProps, { logger, render, getContext }: RenderContext): AsyncGenerator<string, void, unknown>;
|
|
53
|
+
|
|
42
54
|
declare const tokenizer: {
|
|
43
55
|
encode: (text: string) => number[];
|
|
44
56
|
decode: (tokens: number[]) => string;
|
|
45
57
|
};
|
|
46
58
|
declare function tokenLimitForChatModel(model: ValidOpenAIChatModel): number | undefined;
|
|
47
|
-
declare function
|
|
59
|
+
declare function tokenCountForOpenAIMessage(message: OpenAIChatMessage): number;
|
|
60
|
+
declare function tokenCountForOpenAIVisionMessage(message: OpenAIChatMessage): number;
|
|
48
61
|
|
|
49
62
|
type AnthropicChatCompletionRequest = AnthropicClient.CompletionCreateParams;
|
|
50
63
|
declare module '@gammatech/aijsx' {
|
|
@@ -66,7 +79,7 @@ type AnthropicChatCompletionProps = {
|
|
|
66
79
|
model: ValidAnthropicChatModel;
|
|
67
80
|
maxTokens?: number;
|
|
68
81
|
temperature?: number;
|
|
69
|
-
children:
|
|
82
|
+
children: AINode;
|
|
70
83
|
provider?: string;
|
|
71
84
|
providerRegion?: string;
|
|
72
85
|
};
|
|
@@ -79,4 +92,4 @@ type AnthropicChatCompletionProps = {
|
|
|
79
92
|
*/
|
|
80
93
|
declare function AnthropicChatCompletion(props: AnthropicChatCompletionProps, { render, logger, getContext }: RenderContext): AsyncGenerator<string, void, unknown>;
|
|
81
94
|
|
|
82
|
-
export {
|
|
95
|
+
export { AINode, AnthropicChatCompletion, type AnthropicChatCompletionRequest, AnthropicClientContext, ContentTypeImage, Context, LogImplementation, OpenAIChatCompletion, type OpenAIChatCompletionRequest, type OpenAIChatMessage, OpenAIClientContext, OpenAIVisionChatCompletion, RenderContext, type ValidAnthropicChatModel, type ValidOpenAIChatModel, type ValidOpenAIVisionModel, createRenderContext, defaultMaxTokens, tokenCountForOpenAIMessage, tokenCountForOpenAIVisionMessage, tokenLimitForChatModel, tokenizer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { L as LogImplementation, R as RenderContext,
|
|
2
|
-
export {
|
|
1
|
+
import { L as LogImplementation, R as RenderContext, C as Context, A as AINode } from './createElement-jIxJ-zr7.js';
|
|
2
|
+
export { w as AIComponent, u as AIComponentParsed, t as AIComponentString, y as AIElement, a as AIFragment, f as AssistantMessage, B as BoundLogger, i as ChatCompletionError, j as ChatCompletionRequestPayloads, e as ChatCompletionRole, p as CombinedLogger, o as ConsoleLogger, J as JSONSerializable, q as Literal, k as LogChatCompletionRequest, l as LogChatCompletionResponse, m as LogLevel, n as Logger, b as LoggerContext, N as NoopLogImplementation, z as ParsedTypeOfAIComponent, D as ParsedTypeOfRenderable, P as PropsOfAIComponent, s as RenderResult, v as Renderable, r as RenderableStream, g as RenderedConversationMessage, S as SystemMessage, U as UserMessage, x as attachedContextSymbol, h as computeUsage, c as createAIElement, d as createContext } from './createElement-jIxJ-zr7.js';
|
|
3
3
|
import { OpenAI } from 'openai';
|
|
4
4
|
export { OpenAI as OpenAIClient } from 'openai';
|
|
5
|
-
import { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam, ChatCompletionAssistantMessageParam } from 'openai/resources';
|
|
5
|
+
import { ChatCompletionSystemMessageParam, ChatCompletionUserMessageParam, ChatCompletionAssistantMessageParam, ChatCompletionCreateParams } from 'openai/resources';
|
|
6
6
|
import AnthropicClient from '@anthropic-ai/sdk';
|
|
7
7
|
export { default as AnthropicClient } from '@anthropic-ai/sdk';
|
|
8
8
|
export { countTokens as countAnthropicTokens } from '@anthropic-ai/tokenizer';
|
|
@@ -19,32 +19,45 @@ declare module '@gammatech/aijsx' {
|
|
|
19
19
|
openai: OpenAIChatCompletionRequest;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
type
|
|
23
|
-
children: AINode;
|
|
24
|
-
images: {
|
|
25
|
-
url: string;
|
|
26
|
-
detail?: 'low' | 'high' | 'auto';
|
|
27
|
-
}[];
|
|
28
|
-
};
|
|
29
|
-
declare const UserMessageWithImages: AIComponent<UserMessageWithImagesProps>;
|
|
30
|
-
type ValidOpenAIChatModel = 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-32k' | 'gpt-4-32k-0314' | 'gpt-4-32k-0613' | 'gpt-4-1106-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-4-vision-preview';
|
|
22
|
+
type ValidOpenAIChatModel = 'gpt-4' | 'gpt-4-0314' | 'gpt-4-0613' | 'gpt-4-32k' | 'gpt-4-32k-0314' | 'gpt-4-32k-0613' | 'gpt-4-1106-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';
|
|
31
23
|
declare const OpenAIClientContext: Context<() => OpenAI>;
|
|
32
24
|
type OpenAIChatCompletionProps = {
|
|
33
25
|
model: ValidOpenAIChatModel;
|
|
34
26
|
maxTokens?: number;
|
|
35
27
|
temperature?: number;
|
|
36
|
-
|
|
28
|
+
responseFormat?: ChatCompletionCreateParams.ResponseFormat['type'];
|
|
29
|
+
children: AINode;
|
|
37
30
|
provider?: string;
|
|
38
31
|
providerRegion?: string;
|
|
39
32
|
};
|
|
40
33
|
declare function OpenAIChatCompletion(props: OpenAIChatCompletionProps, { logger, render, getContext }: RenderContext): AsyncGenerator<string, void, unknown>;
|
|
41
34
|
|
|
35
|
+
type ValidOpenAIVisionModel = 'gpt-4-vision-preview';
|
|
36
|
+
declare const ContentTypeImage: (_props: {
|
|
37
|
+
url: string;
|
|
38
|
+
dimensions?: {
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
};
|
|
42
|
+
detail?: 'auto' | 'high' | 'low';
|
|
43
|
+
}) => null;
|
|
44
|
+
type OpenAIVisionChatCompletionProps = {
|
|
45
|
+
model?: ValidOpenAIVisionModel;
|
|
46
|
+
maxTokens?: number;
|
|
47
|
+
temperature?: number;
|
|
48
|
+
children: AINode;
|
|
49
|
+
provider?: string;
|
|
50
|
+
providerRegion?: string;
|
|
51
|
+
};
|
|
52
|
+
declare function OpenAIVisionChatCompletion(props: OpenAIVisionChatCompletionProps, { logger, render, getContext }: RenderContext): AsyncGenerator<string, void, unknown>;
|
|
53
|
+
|
|
42
54
|
declare const tokenizer: {
|
|
43
55
|
encode: (text: string) => number[];
|
|
44
56
|
decode: (tokens: number[]) => string;
|
|
45
57
|
};
|
|
46
58
|
declare function tokenLimitForChatModel(model: ValidOpenAIChatModel): number | undefined;
|
|
47
|
-
declare function
|
|
59
|
+
declare function tokenCountForOpenAIMessage(message: OpenAIChatMessage): number;
|
|
60
|
+
declare function tokenCountForOpenAIVisionMessage(message: OpenAIChatMessage): number;
|
|
48
61
|
|
|
49
62
|
type AnthropicChatCompletionRequest = AnthropicClient.CompletionCreateParams;
|
|
50
63
|
declare module '@gammatech/aijsx' {
|
|
@@ -66,7 +79,7 @@ type AnthropicChatCompletionProps = {
|
|
|
66
79
|
model: ValidAnthropicChatModel;
|
|
67
80
|
maxTokens?: number;
|
|
68
81
|
temperature?: number;
|
|
69
|
-
children:
|
|
82
|
+
children: AINode;
|
|
70
83
|
provider?: string;
|
|
71
84
|
providerRegion?: string;
|
|
72
85
|
};
|
|
@@ -79,4 +92,4 @@ type AnthropicChatCompletionProps = {
|
|
|
79
92
|
*/
|
|
80
93
|
declare function AnthropicChatCompletion(props: AnthropicChatCompletionProps, { render, logger, getContext }: RenderContext): AsyncGenerator<string, void, unknown>;
|
|
81
94
|
|
|
82
|
-
export {
|
|
95
|
+
export { AINode, AnthropicChatCompletion, type AnthropicChatCompletionRequest, AnthropicClientContext, ContentTypeImage, Context, LogImplementation, OpenAIChatCompletion, type OpenAIChatCompletionRequest, type OpenAIChatMessage, OpenAIClientContext, OpenAIVisionChatCompletion, RenderContext, type ValidAnthropicChatModel, type ValidOpenAIChatModel, type ValidOpenAIVisionModel, createRenderContext, defaultMaxTokens, tokenCountForOpenAIMessage, tokenCountForOpenAIVisionMessage, tokenLimitForChatModel, tokenizer };
|