@adaline/provider 0.7.0 → 0.8.0
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 +69 -232
- package/dist/index.d.ts +69 -232
- package/dist/index.js +40 -62
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,274 +1,92 @@
|
|
|
1
|
+
import { GatewayBaseError, RoleEnum, ModalityEnum, MessageType, ConfigType, ToolType, ChatResponseType, PartialChatResponseType, EmbeddingModalityEnum, EmbeddingRequestsType, EmbeddingResponseType } from '@adaline/types';
|
|
1
2
|
import { z } from 'zod';
|
|
2
|
-
import { RoleEnum, ModalityEnum, MessageType, ConfigType, ToolType, ChatResponseType, PartialChatResponseType, EmbeddingModalityEnum, EmbeddingRequestsType, EmbeddingResponseType } from '@adaline/types';
|
|
3
3
|
|
|
4
|
-
declare class
|
|
5
|
-
readonly name
|
|
4
|
+
declare class ProviderError extends GatewayBaseError {
|
|
5
|
+
readonly name: "ProviderError";
|
|
6
6
|
readonly info: string;
|
|
7
7
|
readonly cause: unknown;
|
|
8
|
-
constructor({ info,
|
|
8
|
+
constructor({ info, cause }: {
|
|
9
9
|
info: string;
|
|
10
|
-
error: unknown;
|
|
11
|
-
});
|
|
12
|
-
static isApiRequestError(error: unknown): error is ApiRequestError;
|
|
13
|
-
toJSON(): {
|
|
14
|
-
name: string;
|
|
15
|
-
message: string;
|
|
16
10
|
cause: unknown;
|
|
17
|
-
stack: string | undefined;
|
|
18
|
-
info: string;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare class ApiResponseError extends Error {
|
|
23
|
-
readonly name = "Gateway_ApiResponseError";
|
|
24
|
-
readonly info: string;
|
|
25
|
-
readonly cause: unknown;
|
|
26
|
-
constructor({ info, error }: {
|
|
27
|
-
info: string;
|
|
28
|
-
error: unknown;
|
|
29
11
|
});
|
|
30
|
-
static
|
|
31
|
-
toJSON(): {
|
|
32
|
-
name: string;
|
|
33
|
-
message: string;
|
|
34
|
-
cause: unknown;
|
|
35
|
-
stack: string | undefined;
|
|
36
|
-
info: string;
|
|
37
|
-
};
|
|
12
|
+
static isProviderError(error: unknown): error is ProviderError;
|
|
38
13
|
}
|
|
39
14
|
|
|
40
|
-
declare class
|
|
41
|
-
readonly name
|
|
15
|
+
declare class ModelError extends GatewayBaseError {
|
|
16
|
+
readonly name: "ModelError";
|
|
42
17
|
readonly info: string;
|
|
43
18
|
readonly cause: unknown;
|
|
44
|
-
constructor({ info,
|
|
19
|
+
constructor({ info, cause }: {
|
|
45
20
|
info: string;
|
|
46
|
-
error: unknown;
|
|
47
|
-
});
|
|
48
|
-
static isDownloadError(error: unknown): error is DownloadError;
|
|
49
|
-
toJSON(): {
|
|
50
|
-
name: string;
|
|
51
|
-
message: string;
|
|
52
21
|
cause: unknown;
|
|
53
|
-
stack: string | undefined;
|
|
54
|
-
info: string;
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
declare class InvalidAuthError extends Error {
|
|
59
|
-
readonly name = "Gateway_InvalidAuthError";
|
|
60
|
-
readonly info: string;
|
|
61
|
-
readonly cause: unknown;
|
|
62
|
-
constructor({ info, error }: {
|
|
63
|
-
info: string;
|
|
64
|
-
error: unknown;
|
|
65
22
|
});
|
|
66
|
-
static
|
|
67
|
-
toJSON(): {
|
|
68
|
-
name: string;
|
|
69
|
-
message: string;
|
|
70
|
-
cause: unknown;
|
|
71
|
-
stack: string | undefined;
|
|
72
|
-
info: string;
|
|
73
|
-
};
|
|
23
|
+
static isModelError(error: unknown): error is ModelError;
|
|
74
24
|
}
|
|
75
25
|
|
|
76
|
-
declare class
|
|
77
|
-
readonly name
|
|
26
|
+
declare class ModelResponseError extends GatewayBaseError {
|
|
27
|
+
readonly name: "ModelResponseError";
|
|
78
28
|
readonly info: string;
|
|
79
29
|
readonly cause: unknown;
|
|
80
|
-
constructor({ info,
|
|
30
|
+
constructor({ info, cause }: {
|
|
81
31
|
info: string;
|
|
82
|
-
error: unknown;
|
|
83
|
-
});
|
|
84
|
-
static isInvalidConfigError(error: unknown): error is InvalidConfigError;
|
|
85
|
-
toJSON(): {
|
|
86
|
-
name: string;
|
|
87
|
-
message: string;
|
|
88
32
|
cause: unknown;
|
|
89
|
-
stack: string | undefined;
|
|
90
|
-
info: string;
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
declare class InvalidEndpointError extends Error {
|
|
95
|
-
readonly name = "Gateway_InvalidEndpointError";
|
|
96
|
-
readonly info: string;
|
|
97
|
-
readonly cause: unknown;
|
|
98
|
-
constructor({ info, error }: {
|
|
99
|
-
info: string;
|
|
100
|
-
error: unknown;
|
|
101
33
|
});
|
|
102
|
-
static
|
|
103
|
-
toJSON(): {
|
|
104
|
-
name: string;
|
|
105
|
-
message: string;
|
|
106
|
-
cause: unknown;
|
|
107
|
-
stack: string | undefined;
|
|
108
|
-
info: string;
|
|
109
|
-
};
|
|
34
|
+
static isModelResponseError(error: unknown): error is ModelResponseError;
|
|
110
35
|
}
|
|
111
36
|
|
|
112
|
-
declare class
|
|
113
|
-
readonly name
|
|
37
|
+
declare class InvalidModelRequestError extends GatewayBaseError {
|
|
38
|
+
readonly name: "InvalidModelRequestError";
|
|
114
39
|
readonly info: string;
|
|
115
40
|
readonly cause: unknown;
|
|
116
|
-
constructor({ info,
|
|
41
|
+
constructor({ info, cause }: {
|
|
117
42
|
info: string;
|
|
118
|
-
error: unknown;
|
|
119
|
-
});
|
|
120
|
-
static isInvalidMessagesError(error: unknown): error is InvalidMessagesError;
|
|
121
|
-
toJSON(): {
|
|
122
|
-
name: string;
|
|
123
|
-
message: string;
|
|
124
43
|
cause: unknown;
|
|
125
|
-
stack: string | undefined;
|
|
126
|
-
info: string;
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
declare class InvalidModalityError extends Error {
|
|
131
|
-
readonly name = "Gateway_InvalidModalityError";
|
|
132
|
-
readonly info: string;
|
|
133
|
-
readonly cause: unknown;
|
|
134
|
-
constructor({ info, error }: {
|
|
135
|
-
info: string;
|
|
136
|
-
error: unknown;
|
|
137
44
|
});
|
|
138
|
-
static
|
|
139
|
-
toJSON(): {
|
|
140
|
-
name: string;
|
|
141
|
-
message: string;
|
|
142
|
-
cause: unknown;
|
|
143
|
-
stack: string | undefined;
|
|
144
|
-
info: string;
|
|
145
|
-
};
|
|
45
|
+
static isInvalidModelRequestError(error: unknown): error is InvalidModelRequestError;
|
|
146
46
|
}
|
|
147
47
|
|
|
148
|
-
declare class
|
|
149
|
-
readonly name
|
|
48
|
+
declare class InvalidConfigError extends GatewayBaseError {
|
|
49
|
+
readonly name: "InvalidConfigError";
|
|
150
50
|
readonly info: string;
|
|
151
51
|
readonly cause: unknown;
|
|
152
|
-
constructor({ info,
|
|
52
|
+
constructor({ info, cause }: {
|
|
153
53
|
info: string;
|
|
154
|
-
error: unknown;
|
|
155
|
-
});
|
|
156
|
-
static isInvalidModelError(error: unknown): error is InvalidModelError;
|
|
157
|
-
toJSON(): {
|
|
158
|
-
name: string;
|
|
159
|
-
message: string;
|
|
160
54
|
cause: unknown;
|
|
161
|
-
stack: string | undefined;
|
|
162
|
-
info: string;
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
declare class InvalidPromptError extends Error {
|
|
167
|
-
readonly name = "Gateway_InvalidPromptError";
|
|
168
|
-
readonly info: string;
|
|
169
|
-
readonly cause: unknown;
|
|
170
|
-
constructor({ info, error }: {
|
|
171
|
-
info: string;
|
|
172
|
-
error: unknown;
|
|
173
55
|
});
|
|
174
|
-
static
|
|
175
|
-
toJSON(): {
|
|
176
|
-
name: string;
|
|
177
|
-
message: string;
|
|
178
|
-
cause: unknown;
|
|
179
|
-
stack: string | undefined;
|
|
180
|
-
info: string;
|
|
181
|
-
};
|
|
56
|
+
static isInvalidConfigError(error: unknown): error is InvalidConfigError;
|
|
182
57
|
}
|
|
183
58
|
|
|
184
|
-
declare class
|
|
185
|
-
readonly name
|
|
59
|
+
declare class InvalidMessagesError extends GatewayBaseError {
|
|
60
|
+
readonly name: "InvalidMessagesError";
|
|
186
61
|
readonly info: string;
|
|
187
62
|
readonly cause: unknown;
|
|
188
|
-
constructor({ info,
|
|
63
|
+
constructor({ info, cause }: {
|
|
189
64
|
info: string;
|
|
190
|
-
error: unknown;
|
|
191
|
-
});
|
|
192
|
-
static isInvalidRoleError(error: unknown): error is InvalidRoleError;
|
|
193
|
-
toJSON(): {
|
|
194
|
-
name: string;
|
|
195
|
-
message: string;
|
|
196
65
|
cause: unknown;
|
|
197
|
-
stack: string | undefined;
|
|
198
|
-
info: string;
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
declare class InvalidToolsError extends Error {
|
|
203
|
-
readonly name = "Gateway_InvalidToolsError";
|
|
204
|
-
readonly info: string;
|
|
205
|
-
readonly cause: unknown;
|
|
206
|
-
constructor({ info, error }: {
|
|
207
|
-
info: string;
|
|
208
|
-
error: unknown;
|
|
209
66
|
});
|
|
210
|
-
static
|
|
211
|
-
toJSON(): {
|
|
212
|
-
name: string;
|
|
213
|
-
message: string;
|
|
214
|
-
cause: unknown;
|
|
215
|
-
stack: string | undefined;
|
|
216
|
-
info: string;
|
|
217
|
-
};
|
|
67
|
+
static isInvalidMessagesError(error: unknown): error is InvalidMessagesError;
|
|
218
68
|
}
|
|
219
69
|
|
|
220
|
-
declare class
|
|
221
|
-
readonly name
|
|
70
|
+
declare class InvalidToolsError extends GatewayBaseError {
|
|
71
|
+
readonly name: "InvalidToolsError";
|
|
222
72
|
readonly info: string;
|
|
223
73
|
readonly cause: unknown;
|
|
224
|
-
constructor({ info,
|
|
74
|
+
constructor({ info, cause }: {
|
|
225
75
|
info: string;
|
|
226
|
-
error: unknown;
|
|
227
|
-
});
|
|
228
|
-
static isInvalidEmbeddingRequestsError(error: unknown): error is InvalidEmbeddingRequestsError;
|
|
229
|
-
toJSON(): {
|
|
230
|
-
name: string;
|
|
231
|
-
message: string;
|
|
232
76
|
cause: unknown;
|
|
233
|
-
info: string;
|
|
234
|
-
stack: string | undefined;
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
declare class JsonParseError extends Error {
|
|
239
|
-
readonly name = "Gateway_JsonParseError";
|
|
240
|
-
readonly info: string;
|
|
241
|
-
readonly cause: unknown;
|
|
242
|
-
constructor({ info, error }: {
|
|
243
|
-
info: string;
|
|
244
|
-
error: unknown;
|
|
245
77
|
});
|
|
246
|
-
static
|
|
247
|
-
toJSON(): {
|
|
248
|
-
name: string;
|
|
249
|
-
message: string;
|
|
250
|
-
cause: unknown;
|
|
251
|
-
stack: string | undefined;
|
|
252
|
-
info: string;
|
|
253
|
-
};
|
|
78
|
+
static isInvalidToolsError(error: unknown): error is InvalidToolsError;
|
|
254
79
|
}
|
|
255
80
|
|
|
256
|
-
declare class
|
|
257
|
-
readonly name
|
|
81
|
+
declare class InvalidEmbeddingRequestsError extends GatewayBaseError {
|
|
82
|
+
readonly name: "InvalidEmbeddingRequestsError";
|
|
258
83
|
readonly info: string;
|
|
259
84
|
readonly cause: unknown;
|
|
260
|
-
constructor({ info,
|
|
85
|
+
constructor({ info, cause }: {
|
|
261
86
|
info: string;
|
|
262
|
-
error: unknown;
|
|
263
|
-
});
|
|
264
|
-
static isValidationError(error: unknown): error is ValidationError;
|
|
265
|
-
toJSON(): {
|
|
266
|
-
name: string;
|
|
267
|
-
message: string;
|
|
268
87
|
cause: unknown;
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
};
|
|
88
|
+
});
|
|
89
|
+
static isInvalidEmbeddingRequestsError(error: unknown): error is InvalidEmbeddingRequestsError;
|
|
272
90
|
}
|
|
273
91
|
|
|
274
92
|
declare const ChatModelSchema: <R extends z.ZodEnum<[string, ...string[]]> = z.ZodEnum<["system", "user", "assistant", "tool"]>, M extends z.ZodEnum<[string, ...string[]]> = z.ZodEnum<["text", "image", "tool-call", "tool-response"]>>(Roles?: R, Modalities?: M) => z.ZodObject<{
|
|
@@ -1889,20 +1707,30 @@ declare const ObjectSchemaConfigItem: (data: Omit<ObjectSchemaConfigItemType, "t
|
|
|
1889
1707
|
interface ChatModelV1<MS extends ChatModelSchemaType = ChatModelSchemaType> {
|
|
1890
1708
|
readonly version: "v1";
|
|
1891
1709
|
readonly modelSchema: MS;
|
|
1892
|
-
getTokenCount(messages: MessageType[]): number;
|
|
1893
1710
|
getDefaultBaseUrl(): UrlType;
|
|
1894
1711
|
getDefaultHeaders(): HeadersType;
|
|
1895
1712
|
getDefaultParams(): ParamsType;
|
|
1713
|
+
getRetryDelay(responseHeaders: HeadersType): {
|
|
1714
|
+
shouldRetry: boolean;
|
|
1715
|
+
delayMs: number;
|
|
1716
|
+
};
|
|
1717
|
+
getTokenCount(messages: MessageType[]): number;
|
|
1718
|
+
transformModelRequest(request: any): {
|
|
1719
|
+
modelName: string | undefined;
|
|
1720
|
+
config: ConfigType | undefined;
|
|
1721
|
+
messages: MessageType[] | undefined;
|
|
1722
|
+
tools: ToolType[] | undefined;
|
|
1723
|
+
};
|
|
1896
1724
|
transformConfig(config: ConfigType, messages?: MessageType[], tools?: ToolType[]): ParamsType;
|
|
1897
1725
|
transformMessages(messages: MessageType[]): ParamsType;
|
|
1898
1726
|
transformTools(tools: ToolType[]): ParamsType;
|
|
1899
|
-
getCompleteChatUrl(config?: ConfigType, messages?: MessageType[], tools?: ToolType[]): UrlType
|
|
1727
|
+
getCompleteChatUrl(config?: ConfigType, messages?: MessageType[], tools?: ToolType[]): Promise<UrlType>;
|
|
1900
1728
|
getCompleteChatHeaders(config?: ConfigType, messages?: MessageType[], tools?: ToolType[]): Promise<HeadersType>;
|
|
1901
|
-
getCompleteChatData(config: ConfigType, messages: MessageType[], tools?: ToolType[]): ParamsType
|
|
1729
|
+
getCompleteChatData(config: ConfigType, messages: MessageType[], tools?: ToolType[]): Promise<ParamsType>;
|
|
1902
1730
|
transformCompleteChatResponse(response: any): ChatResponseType;
|
|
1903
|
-
getStreamChatUrl(config?: ConfigType, messages?: MessageType[], tools?: ToolType[]): UrlType
|
|
1731
|
+
getStreamChatUrl(config?: ConfigType, messages?: MessageType[], tools?: ToolType[]): Promise<UrlType>;
|
|
1904
1732
|
getStreamChatHeaders(config?: ConfigType, messages?: MessageType[], tools?: ToolType[]): Promise<HeadersType>;
|
|
1905
|
-
getStreamChatData(config: ConfigType, messages: MessageType[], tools?: ToolType[]): ParamsType
|
|
1733
|
+
getStreamChatData(config: ConfigType, messages: MessageType[], tools?: ToolType[]): Promise<ParamsType>;
|
|
1906
1734
|
transformStreamChatResponseChunk(chunk: string, buffer: string): AsyncGenerator<{
|
|
1907
1735
|
partialResponse: PartialChatResponseType;
|
|
1908
1736
|
buffer: string;
|
|
@@ -2263,16 +2091,25 @@ type EmbeddingModelSchemaType<M extends z.ZodEnum<[string, ...string[]]> = typeo
|
|
|
2263
2091
|
interface EmbeddingModelV1<MS extends EmbeddingModelSchemaType = EmbeddingModelSchemaType> {
|
|
2264
2092
|
readonly version: "v1";
|
|
2265
2093
|
readonly modelSchema: MS;
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2094
|
+
getDefaultBaseUrl(): UrlType;
|
|
2095
|
+
getDefaultHeaders(): HeadersType;
|
|
2096
|
+
getDefaultParams(): ParamsType;
|
|
2097
|
+
getRetryDelay(responseHeaders: HeadersType): {
|
|
2098
|
+
shouldRetry: boolean;
|
|
2099
|
+
delayMs: number;
|
|
2100
|
+
};
|
|
2101
|
+
getTokenCount(requests: EmbeddingRequestsType): number;
|
|
2102
|
+
transformModelRequest(request: any): {
|
|
2103
|
+
modelName: string | undefined;
|
|
2104
|
+
config: ConfigType | undefined;
|
|
2105
|
+
embeddingRequests: EmbeddingRequestsType | undefined;
|
|
2106
|
+
};
|
|
2107
|
+
transformConfig(config: ConfigType, requests?: EmbeddingRequestsType): ParamsType;
|
|
2108
|
+
transformEmbeddingRequests(requests: EmbeddingRequestsType): ParamsType;
|
|
2109
|
+
getGetEmbeddingsUrl(config?: ConfigType, requests?: EmbeddingRequestsType): Promise<UrlType>;
|
|
2110
|
+
getGetEmbeddingsHeaders(config?: ConfigType, requests?: EmbeddingRequestsType): Promise<HeadersType>;
|
|
2111
|
+
getGetEmbeddingsData(config: ConfigType, requests: EmbeddingRequestsType): Promise<ParamsType>;
|
|
2112
|
+
transformGetEmbeddingsResponse(response: any): EmbeddingResponseType;
|
|
2276
2113
|
}
|
|
2277
2114
|
|
|
2278
2115
|
interface ProviderV1<O extends Record<string, any> = Record<string, any>> {
|
|
@@ -2338,4 +2175,4 @@ declare const urlWithoutTrailingSlash: (url: string) => string;
|
|
|
2338
2175
|
|
|
2339
2176
|
declare const isRunningInBrowser: () => boolean;
|
|
2340
2177
|
|
|
2341
|
-
export {
|
|
2178
|
+
export { CONFIG, ChatModelSchema, type ChatModelSchemaType, type ChatModelV1, ConfigItemDef, type ConfigItemDefType, ConfigItemEnum, type ConfigItemEnumType, ConfigItemLiterals, EmbeddingModelSchema, type EmbeddingModelSchemaType, type EmbeddingModelV1, Headers, type HeadersType, InvalidConfigError, InvalidEmbeddingRequestsError, InvalidMessagesError, InvalidModelRequestError, InvalidToolsError, ModelError, ModelResponseError, MultiStringConfigItem, MultiStringConfigItemDef, MultiStringConfigItemSchema, type MultiStringConfigItemSchemaType, type MultiStringConfigItemType, MultiStringConfigItemTypeLiteral, ObjectSchemaConfigItem, ObjectSchemaConfigItemDef, ObjectSchemaConfigItemSchema, type ObjectSchemaConfigItemSchemaType, type ObjectSchemaConfigItemType, ObjectSchemaConfigItemTypeLiteral, Params, type ParamsType, ProviderError, type ProviderV1, RangeConfigItem, RangeConfigItemDef, type RangeConfigItemDefType, RangeConfigItemSchema, type RangeConfigItemSchemaType, RangeConfigItemTypeLiteral, SelectBooleanConfigItem, SelectBooleanConfigItemDef, type SelectBooleanConfigItemDefType, SelectBooleanConfigItemSchema, type SelectBooleanConfigItemSchemaType, SelectBooleanConfigItemTypeLiteral, SelectStringConfigItem, SelectStringConfigItemDef, type SelectStringConfigItemDefType, SelectStringConfigItemSchema, type SelectStringConfigItemSchemaType, SelectStringConfigItemTypeLiteral, Url, type UrlType, convertBase64ToUint8Array, convertUint8ArrayToBase64, encodedBase64ToString, getErrorMessage, isRunningInBrowser, removeUndefinedEntries, urlWithoutTrailingSlash };
|