@convex-dev/ai-sdk-provider 0.2.1 → 0.3.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/README.md +63 -9
- package/dist/commonjs/decision-model.d.ts +4 -0
- package/dist/commonjs/decision-model.d.ts.map +1 -0
- package/dist/commonjs/{evaluation-model.js → decision-model.js} +3 -3
- package/dist/commonjs/decision-model.js.map +1 -0
- package/dist/commonjs/index.d.ts +46 -37
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +97 -26
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/transcription-model.d.ts +10 -0
- package/dist/commonjs/transcription-model.d.ts.map +1 -0
- package/dist/commonjs/transcription-model.js +102 -0
- package/dist/commonjs/transcription-model.js.map +1 -0
- package/dist/commonjs/video-model.d.ts +1 -1
- package/dist/commonjs/video-model.d.ts.map +1 -1
- package/dist/esm/decision-model.d.ts +4 -0
- package/dist/esm/decision-model.d.ts.map +1 -0
- package/dist/esm/{evaluation-model.js → decision-model.js} +2 -2
- package/dist/esm/decision-model.js.map +1 -0
- package/dist/esm/index.d.ts +46 -9
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +96 -24
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/transcription-model.d.ts +10 -0
- package/dist/esm/transcription-model.d.ts.map +1 -0
- package/dist/esm/transcription-model.js +99 -0
- package/dist/esm/transcription-model.js.map +1 -0
- package/dist/esm/video-model.d.ts +1 -1
- package/dist/esm/video-model.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/{evaluation-model.ts → decision-model.ts} +3 -3
- package/src/index.ts +138 -25
- package/src/transcription-model.ts +133 -0
- package/src/video-model.ts +1 -1
- package/dist/commonjs/evaluation-model.d.ts +0 -5
- package/dist/commonjs/evaluation-model.d.ts.map +0 -1
- package/dist/commonjs/evaluation-model.js.map +0 -1
- package/dist/esm/evaluation-model.d.ts +0 -5
- package/dist/esm/evaluation-model.d.ts.map +0 -1
- package/dist/esm/evaluation-model.js.map +0 -1
package/src/index.ts
CHANGED
|
@@ -10,8 +10,12 @@ import {
|
|
|
10
10
|
wrapLanguageModel,
|
|
11
11
|
} from "ai";
|
|
12
12
|
import { getServiceToken } from "convex/server";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { createDecisionModel, type DecisionModel } from "./decision-model.js";
|
|
14
|
+
import {
|
|
15
|
+
createTranscriptionModel,
|
|
16
|
+
type TranscriptionModel,
|
|
17
|
+
} from "./transcription-model.js";
|
|
18
|
+
import { createVideoModel, type GatewayVideoModel } from "./video-model.js";
|
|
15
19
|
|
|
16
20
|
type Provider = ReturnType<typeof createOpenAICompatible>;
|
|
17
21
|
type ChatModel = ReturnType<Provider>;
|
|
@@ -20,9 +24,15 @@ type ProviderMetadata = NonNullable<
|
|
|
20
24
|
Awaited<ReturnType<MetadataExtractor["extractMetadata"]>>
|
|
21
25
|
>;
|
|
22
26
|
type ImageModel = ReturnType<Provider["imageModel"]>;
|
|
27
|
+
type SpeechModel = ReturnType<ReturnType<typeof createOpenAI>["speech"]>;
|
|
23
28
|
type LanguageModel = Parameters<typeof wrapLanguageModel>[0]["model"];
|
|
24
29
|
type GatewayLanguageModel = ReturnType<typeof wrapLanguageModel>;
|
|
25
30
|
|
|
31
|
+
export interface GatewayModelOptions {
|
|
32
|
+
/** Require an inference endpoint with a zero-data-retention policy. */
|
|
33
|
+
zdr?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
26
36
|
const maxEmbeddingsPerCall = 512;
|
|
27
37
|
// Official providers require a credential before gatewayFetch replaces it with a deployment JWT.
|
|
28
38
|
const placeholderCredential = "convex-gateway";
|
|
@@ -82,11 +92,11 @@ const costMetadataExtractor: MetadataExtractor = {
|
|
|
82
92
|
},
|
|
83
93
|
};
|
|
84
94
|
|
|
85
|
-
function createGatewayProvider(): Provider {
|
|
95
|
+
function createGatewayProvider(fetch = gatewayFetch): Provider {
|
|
86
96
|
return createOpenAICompatible({
|
|
87
97
|
name: "convexGateway",
|
|
88
98
|
baseURL: gatewayBaseURL(),
|
|
89
|
-
fetch
|
|
99
|
+
fetch,
|
|
90
100
|
metadataExtractor: costMetadataExtractor,
|
|
91
101
|
supportsStructuredOutputs: true,
|
|
92
102
|
supportedUrls: () => ({ "image/*": [/^https?:\/\/.*$/] }),
|
|
@@ -109,9 +119,13 @@ function gatewayModelFetch(
|
|
|
109
119
|
gatewayModelId: string,
|
|
110
120
|
input: RequestInfo | URL,
|
|
111
121
|
init?: RequestInit,
|
|
122
|
+
options?: GatewayModelOptions,
|
|
112
123
|
): Promise<Response> {
|
|
113
124
|
const body = JSON.parse(init?.body as string);
|
|
114
125
|
body.model = gatewayModelId;
|
|
126
|
+
if (options?.zdr !== undefined) {
|
|
127
|
+
body.provider = { ...body.provider, zdr: options.zdr };
|
|
128
|
+
}
|
|
115
129
|
return gatewayFetch(input, { ...init, body: JSON.stringify(body) });
|
|
116
130
|
}
|
|
117
131
|
|
|
@@ -135,29 +149,40 @@ function gatewayLanguageModel(
|
|
|
135
149
|
* `getServiceToken` caches and refreshes credentials within the current action,
|
|
136
150
|
* so calling this more than once in the same action is fine.
|
|
137
151
|
*/
|
|
138
|
-
|
|
139
|
-
|
|
152
|
+
function convexGateway(
|
|
153
|
+
modelId: string,
|
|
154
|
+
options?: GatewayModelOptions,
|
|
155
|
+
): ChatModel {
|
|
156
|
+
return createGatewayProvider((input, init) =>
|
|
157
|
+
gatewayModelFetch(modelId, input, init, options),
|
|
158
|
+
)(modelId);
|
|
140
159
|
}
|
|
141
160
|
|
|
142
|
-
|
|
161
|
+
function messages(
|
|
162
|
+
modelId: string,
|
|
163
|
+
options?: GatewayModelOptions,
|
|
164
|
+
): GatewayLanguageModel {
|
|
143
165
|
const provider = createAnthropic({
|
|
144
166
|
name: "convexGateway.messages",
|
|
145
167
|
baseURL: gatewayBaseURL(),
|
|
146
168
|
authToken: placeholderCredential,
|
|
147
|
-
fetch: (input, init) => gatewayModelFetch(modelId, input, init),
|
|
169
|
+
fetch: (input, init) => gatewayModelFetch(modelId, input, init, options),
|
|
148
170
|
});
|
|
149
171
|
return gatewayLanguageModel(
|
|
150
172
|
modelId,
|
|
151
173
|
provider.messages(sdkModelId(modelId, "anthropic")),
|
|
152
174
|
);
|
|
153
|
-
}
|
|
175
|
+
}
|
|
154
176
|
|
|
155
|
-
|
|
177
|
+
function responses(
|
|
178
|
+
modelId: string,
|
|
179
|
+
options?: GatewayModelOptions,
|
|
180
|
+
): GatewayLanguageModel {
|
|
156
181
|
const provider = createOpenAI({
|
|
157
182
|
name: "convexGateway.responses",
|
|
158
183
|
baseURL: gatewayBaseURL(),
|
|
159
184
|
apiKey: placeholderCredential,
|
|
160
|
-
fetch: (input, init) => gatewayModelFetch(modelId, input, init),
|
|
185
|
+
fetch: (input, init) => gatewayModelFetch(modelId, input, init, options),
|
|
161
186
|
});
|
|
162
187
|
return gatewayLanguageModel(
|
|
163
188
|
modelId,
|
|
@@ -166,41 +191,129 @@ convexGateway.responses = function (modelId: string): GatewayLanguageModel {
|
|
|
166
191
|
settings: { providerOptions: { openai: { store: false } } },
|
|
167
192
|
}),
|
|
168
193
|
);
|
|
169
|
-
}
|
|
194
|
+
}
|
|
170
195
|
|
|
171
|
-
/**
|
|
172
|
-
|
|
173
|
-
|
|
196
|
+
/** Decide typed questions through the alpha Decisions API. */
|
|
197
|
+
function decisionModel(
|
|
198
|
+
modelId: string,
|
|
199
|
+
options?: GatewayModelOptions,
|
|
200
|
+
): DecisionModel {
|
|
201
|
+
return createDecisionModel(
|
|
174
202
|
modelId,
|
|
175
203
|
gatewayBaseURL("alpha"),
|
|
176
|
-
|
|
204
|
+
(input, init) => gatewayModelFetch(modelId, input, init, options),
|
|
177
205
|
convexGatewayUsageMetadata,
|
|
178
206
|
);
|
|
179
|
-
}
|
|
207
|
+
}
|
|
180
208
|
|
|
181
|
-
|
|
209
|
+
function embeddingModel(
|
|
210
|
+
modelId: string,
|
|
211
|
+
options?: GatewayModelOptions,
|
|
212
|
+
): EmbeddingModel {
|
|
182
213
|
return wrapEmbeddingModel({
|
|
183
|
-
model: createGatewayProvider(
|
|
214
|
+
model: createGatewayProvider((input, init) =>
|
|
215
|
+
gatewayModelFetch(modelId, input, init, options),
|
|
216
|
+
).embeddingModel(modelId),
|
|
184
217
|
middleware: {
|
|
185
218
|
specificationVersion: "v4",
|
|
186
219
|
overrideMaxEmbeddingsPerCall: () => maxEmbeddingsPerCall,
|
|
187
220
|
},
|
|
188
221
|
});
|
|
189
|
-
}
|
|
222
|
+
}
|
|
190
223
|
|
|
191
224
|
/** Image model for the AI SDK's `generateImage`. */
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
225
|
+
function imageModel(modelId: string): ImageModel {
|
|
226
|
+
const { specificationVersion, provider, maxImagesPerCall } =
|
|
227
|
+
createGatewayProvider().imageModel(modelId);
|
|
228
|
+
return {
|
|
229
|
+
specificationVersion,
|
|
230
|
+
provider,
|
|
231
|
+
modelId,
|
|
232
|
+
maxImagesPerCall,
|
|
233
|
+
async doGenerate(options) {
|
|
234
|
+
if (options.files?.length || options.mask) {
|
|
235
|
+
throw new Error(
|
|
236
|
+
"Convex AI Gateway does not support image editing. Use a text prompt without input images or a mask.",
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
// The SDK's image adapter discards `usage` and has no metadata hook, so
|
|
240
|
+
// each call reads it from its own response through a per-call fetch.
|
|
241
|
+
let usage: unknown;
|
|
242
|
+
const model = createGatewayProvider(async (input, init) => {
|
|
243
|
+
const response = await gatewayFetch(input, init);
|
|
244
|
+
if (response.ok) {
|
|
245
|
+
usage = (await response.clone().json()).usage;
|
|
246
|
+
}
|
|
247
|
+
return response;
|
|
248
|
+
}).imageModel(modelId);
|
|
249
|
+
const result = await model.doGenerate(options);
|
|
250
|
+
const metadata = convexGatewayUsageMetadata(usage)?.convexGateway;
|
|
251
|
+
return {
|
|
252
|
+
...result,
|
|
253
|
+
...(metadata && {
|
|
254
|
+
// The SDK's image metadata type requires a per-image `images` array.
|
|
255
|
+
providerMetadata: { convexGateway: { ...metadata, images: [] } },
|
|
256
|
+
}),
|
|
257
|
+
};
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** Speech-to-text for the AI SDK's `experimental_transcribe`. */
|
|
263
|
+
function transcriptionModel(modelId: string): TranscriptionModel {
|
|
264
|
+
return createTranscriptionModel(
|
|
265
|
+
modelId,
|
|
266
|
+
gatewayBaseURL(),
|
|
267
|
+
gatewayFetch,
|
|
268
|
+
convexGatewayUsageMetadata,
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Text-to-speech for the AI SDK's `experimental_generateSpeech`. The gateway
|
|
274
|
+
* reports speech cost after the call, so results carry no cost metadata.
|
|
275
|
+
*/
|
|
276
|
+
function speechModel(modelId: string): SpeechModel {
|
|
277
|
+
const provider = createOpenAI({
|
|
278
|
+
name: "convexGateway.speech",
|
|
279
|
+
baseURL: gatewayBaseURL(),
|
|
280
|
+
apiKey: placeholderCredential,
|
|
281
|
+
fetch: (input, init) => gatewayModelFetch(modelId, input, init),
|
|
282
|
+
});
|
|
283
|
+
return provider.speech(modelId);
|
|
284
|
+
}
|
|
195
285
|
|
|
196
286
|
/** Video generation for the AI SDK's `experimental_generateVideo`. */
|
|
197
|
-
|
|
287
|
+
function videoModel(modelId: string): GatewayVideoModel {
|
|
198
288
|
return createVideoModel(
|
|
199
289
|
modelId,
|
|
200
290
|
gatewayBaseURL(),
|
|
201
291
|
gatewayFetch,
|
|
202
292
|
convexGatewayUsageMetadata,
|
|
203
293
|
);
|
|
204
|
-
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Editors show this copy on hover over the import and the function's copy on calls and signature help.
|
|
297
|
+
/**
|
|
298
|
+
* The recommended model interface for text generation through the Convex AI gateway.
|
|
299
|
+
* Use `messages` or `responses` only for endpoint-specific features.
|
|
300
|
+
*
|
|
301
|
+
* `getServiceToken` caches and refreshes credentials within the current action,
|
|
302
|
+
* so calling this more than once in the same action is fine.
|
|
303
|
+
*/
|
|
304
|
+
const gateway = Object.assign(convexGateway, {
|
|
305
|
+
messages,
|
|
306
|
+
responses,
|
|
307
|
+
decisionModel,
|
|
308
|
+
/** @deprecated Use `decisionModel` instead. */
|
|
309
|
+
evaluationModel: decisionModel,
|
|
310
|
+
embeddingModel,
|
|
311
|
+
imageModel,
|
|
312
|
+
transcriptionModel,
|
|
313
|
+
speechModel,
|
|
314
|
+
videoModel,
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
export { gateway as convexGateway };
|
|
205
318
|
|
|
206
319
|
export { verifyVideoWebhook, type VideoWebhookEvent } from "./video-webhook.js";
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {
|
|
2
|
+
APICallError,
|
|
3
|
+
type experimental_transcribe as transcribe,
|
|
4
|
+
type ProviderMetadata,
|
|
5
|
+
} from "ai";
|
|
6
|
+
|
|
7
|
+
export type TranscriptionModel = Extract<
|
|
8
|
+
Parameters<typeof transcribe>[0]["model"],
|
|
9
|
+
{ specificationVersion: "v4" }
|
|
10
|
+
>;
|
|
11
|
+
type TranscriptionOptions = Parameters<TranscriptionModel["doGenerate"]>[0];
|
|
12
|
+
type TranscriptionResult = Awaited<
|
|
13
|
+
ReturnType<TranscriptionModel["doGenerate"]>
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
// OpenRouter names formats by extension, not media type.
|
|
17
|
+
const audioFormats: Record<string, string> = {
|
|
18
|
+
"audio/mpeg": "mp3",
|
|
19
|
+
"audio/mp3": "mp3",
|
|
20
|
+
"audio/mpga": "mp3",
|
|
21
|
+
"audio/x-mp3": "mp3",
|
|
22
|
+
"audio/wav": "wav",
|
|
23
|
+
"audio/wave": "wav",
|
|
24
|
+
"audio/x-wav": "wav",
|
|
25
|
+
"audio/flac": "flac",
|
|
26
|
+
"audio/x-flac": "flac",
|
|
27
|
+
"audio/mp4": "m4a",
|
|
28
|
+
"audio/m4a": "m4a",
|
|
29
|
+
"audio/x-m4a": "m4a",
|
|
30
|
+
"audio/ogg": "ogg",
|
|
31
|
+
"audio/webm": "webm",
|
|
32
|
+
"audio/aac": "aac",
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function base64(audio: Uint8Array | string): string {
|
|
36
|
+
if (typeof audio === "string") return audio;
|
|
37
|
+
// Chunked so large recordings stay under the engine's argument limit.
|
|
38
|
+
let binary = "";
|
|
39
|
+
for (let i = 0; i < audio.length; i += 0x8000) {
|
|
40
|
+
binary += String.fromCharCode(...audio.subarray(i, i + 0x8000));
|
|
41
|
+
}
|
|
42
|
+
return btoa(binary);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The gateway accepts JSON only, so this model sends base64 audio instead of
|
|
47
|
+
* the multipart upload `@ai-sdk/openai` uses.
|
|
48
|
+
*/
|
|
49
|
+
export function createTranscriptionModel(
|
|
50
|
+
modelId: string,
|
|
51
|
+
baseURL: string,
|
|
52
|
+
fetch: typeof globalThis.fetch,
|
|
53
|
+
usageMetadata: (usage: unknown) => ProviderMetadata | undefined,
|
|
54
|
+
): TranscriptionModel {
|
|
55
|
+
return {
|
|
56
|
+
specificationVersion: "v4",
|
|
57
|
+
provider: "convexGateway",
|
|
58
|
+
modelId,
|
|
59
|
+
async doGenerate(
|
|
60
|
+
options: TranscriptionOptions,
|
|
61
|
+
): Promise<TranscriptionResult> {
|
|
62
|
+
const format =
|
|
63
|
+
audioFormats[options.mediaType.split(";")[0].trim().toLowerCase()];
|
|
64
|
+
if (!format) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`Unsupported audio type for the Convex AI gateway: ${options.mediaType}`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
const extra = options.providerOptions?.convexGateway ?? {};
|
|
70
|
+
const headers = new Headers();
|
|
71
|
+
for (const [key, value] of Object.entries(options.headers ?? {})) {
|
|
72
|
+
if (value !== undefined) headers.set(key, value);
|
|
73
|
+
}
|
|
74
|
+
headers.set("Content-Type", "application/json");
|
|
75
|
+
const timestamp = new Date();
|
|
76
|
+
const url = `${baseURL}/audio/transcriptions`;
|
|
77
|
+
const requestBody = {
|
|
78
|
+
...extra,
|
|
79
|
+
model: modelId,
|
|
80
|
+
input_audio: { data: base64(options.audio), format },
|
|
81
|
+
};
|
|
82
|
+
const response = await fetch(url, {
|
|
83
|
+
method: "POST",
|
|
84
|
+
headers,
|
|
85
|
+
signal: options.abortSignal,
|
|
86
|
+
body: JSON.stringify(requestBody),
|
|
87
|
+
});
|
|
88
|
+
// A proxy error page is not JSON; the status message covers it.
|
|
89
|
+
const body = (await response.json().catch(() => ({}))) as {
|
|
90
|
+
text?: unknown;
|
|
91
|
+
language?: unknown;
|
|
92
|
+
duration?: unknown;
|
|
93
|
+
segments?: Array<{ text?: unknown; start?: unknown; end?: unknown }>;
|
|
94
|
+
usage?: { seconds?: unknown };
|
|
95
|
+
error?: { message?: string };
|
|
96
|
+
};
|
|
97
|
+
if (!response.ok || typeof body.text !== "string") {
|
|
98
|
+
throw new APICallError({
|
|
99
|
+
message:
|
|
100
|
+
body.error?.message ?? `Transcription failed (${response.status})`,
|
|
101
|
+
url,
|
|
102
|
+
requestBodyValues: requestBody,
|
|
103
|
+
statusCode: response.status,
|
|
104
|
+
responseHeaders: Object.fromEntries(response.headers),
|
|
105
|
+
responseBody: JSON.stringify(body),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const duration = body.duration ?? body.usage?.seconds;
|
|
109
|
+
return {
|
|
110
|
+
text: body.text,
|
|
111
|
+
// Present with `response_format: "verbose_json"`.
|
|
112
|
+
segments: (Array.isArray(body.segments) ? body.segments : []).flatMap(
|
|
113
|
+
({ text, start, end }) =>
|
|
114
|
+
typeof text === "string" &&
|
|
115
|
+
typeof start === "number" &&
|
|
116
|
+
typeof end === "number"
|
|
117
|
+
? [{ text, startSecond: start, endSecond: end }]
|
|
118
|
+
: [],
|
|
119
|
+
),
|
|
120
|
+
language: typeof body.language === "string" ? body.language : undefined,
|
|
121
|
+
durationInSeconds: typeof duration === "number" ? duration : undefined,
|
|
122
|
+
warnings: [],
|
|
123
|
+
providerMetadata: usageMetadata(body.usage),
|
|
124
|
+
response: {
|
|
125
|
+
timestamp,
|
|
126
|
+
modelId,
|
|
127
|
+
headers: Object.fromEntries(response.headers),
|
|
128
|
+
body,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
package/src/video-model.ts
CHANGED
|
@@ -21,7 +21,7 @@ type StatusResult = {
|
|
|
21
21
|
providerMetadata?: ProviderMetadata;
|
|
22
22
|
response: VideoResult["response"];
|
|
23
23
|
} & ({ status: "pending" | "completed" } | { status: "error"; error: string });
|
|
24
|
-
type GatewayVideoModel = Omit<
|
|
24
|
+
export type GatewayVideoModel = Omit<
|
|
25
25
|
VideoModel,
|
|
26
26
|
"doStatus" | "handleWebhookOption"
|
|
27
27
|
> & {
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type experimental_evaluate, type ProviderMetadata } from "ai";
|
|
2
|
-
type EvaluationModel = Exclude<Parameters<typeof experimental_evaluate>[0]["model"], string>;
|
|
3
|
-
export declare function createEvaluationModel(modelId: string, baseURL: string, fetch: typeof globalThis.fetch, usageMetadata: (usage: unknown) => ProviderMetadata | undefined): EvaluationModel;
|
|
4
|
-
export {};
|
|
5
|
-
//# sourceMappingURL=evaluation-model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"evaluation-model.d.ts","sourceRoot":"","sources":["../../src/evaluation-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACtB,MAAM,IAAI,CAAC;AAGZ,KAAK,eAAe,GAAG,OAAO,CAC5B,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC,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AE;oBACL,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY;oBACtC,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa;iBACzC;gBACD,2EAA2E;gBAC3E,QAAQ,EAAE,EAAE,mBAAmB,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE;gBACtD,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC7C,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;oBAC9D,IAAI,EAAE,aAAsB;oBAC5B,OAAO,EAAE,mBAAmB,QAAQ,EAAE;iBACvC,CAAC,CAAC;gBACH,QAAQ,EAAE;oBACR,EAAE,EAAE,MAAM,CAAC,EAAE;oBACb,OAAO,EAAE,MAAM,CAAC,KAAK;oBACrB,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC;oBAC7C,IAAI,EAAE,OAAO;iBACd;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type experimental_evaluate, type ProviderMetadata } from "ai";
|
|
2
|
-
type EvaluationModel = Exclude<Parameters<typeof experimental_evaluate>[0]["model"], string>;
|
|
3
|
-
export declare function createEvaluationModel(modelId: string, baseURL: string, fetch: typeof globalThis.fetch, usageMetadata: (usage: unknown) => ProviderMetadata | undefined): EvaluationModel;
|
|
4
|
-
export {};
|
|
5
|
-
//# sourceMappingURL=evaluation-model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"evaluation-model.d.ts","sourceRoot":"","sources":["../../src/evaluation-model.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACtB,MAAM,IAAI,CAAC;AAGZ,KAAK,eAAe,GAAG,OAA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