llm-strings 1.4.0 → 1.5.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/LICENSE +21 -0
- package/README.md +341 -330
- package/dist/ai-sdk.cjs +1 -1176
- package/dist/ai-sdk.d.cts +1 -1
- package/dist/ai-sdk.d.ts +1 -1
- package/dist/ai-sdk.js +1 -543
- package/dist/chunk-CT44CYBU.js +1 -0
- package/dist/chunk-JURQSYOT.js +1 -0
- package/dist/chunk-LIYUWJME.js +1 -0
- package/dist/chunk-M5ENVTNI.js +1 -0
- package/dist/index.cjs +1 -1351
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -22
- package/dist/normalize.cjs +1 -527
- package/dist/normalize.d.cts +1 -1
- package/dist/normalize.d.ts +1 -1
- package/dist/normalize.js +1 -7
- package/dist/parse.cjs +1 -159
- package/dist/parse.d.cts +4 -4
- package/dist/parse.d.ts +4 -4
- package/dist/parse.js +1 -9
- package/dist/{provider-core-B934MuhJ.d.cts → provider-core-CjpJ4qyF.d.cts} +35 -15
- package/dist/{provider-core-B934MuhJ.d.ts → provider-core-CjpJ4qyF.d.ts} +35 -15
- package/dist/providers.cjs +1 -1267
- package/dist/providers.d.cts +2 -2
- package/dist/providers.d.ts +2 -2
- package/dist/providers.js +1 -218
- package/dist/validate.cjs +1 -1334
- package/dist/validate.d.cts +1 -1
- package/dist/validate.d.ts +1 -1
- package/dist/validate.js +1 -9
- package/package.json +17 -2
- package/dist/chunk-5YTG2NRX.js +0 -42
- package/dist/chunk-76EFNZCF.js +0 -1043
- package/dist/chunk-DPVT3FFP.js +0 -116
- package/dist/chunk-OBLFZFNR.js +0 -175
package/dist/ai-sdk.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NormalizeResult, NormalizeOptions } from './normalize.cjs';
|
|
2
2
|
import { LlmConnectionConfig } from './parse.cjs';
|
|
3
|
-
import { P as Provider } from './provider-core-
|
|
3
|
+
import { P as Provider } from './provider-core-CjpJ4qyF.cjs';
|
|
4
4
|
|
|
5
5
|
type AiSdkProviderOptions = Record<string, Record<string, unknown>>;
|
|
6
6
|
interface AiSdkProviderOptionsResult {
|
package/dist/ai-sdk.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NormalizeResult, NormalizeOptions } from './normalize.js';
|
|
2
2
|
import { LlmConnectionConfig } from './parse.js';
|
|
3
|
-
import { P as Provider } from './provider-core-
|
|
3
|
+
import { P as Provider } from './provider-core-CjpJ4qyF.js';
|
|
4
4
|
|
|
5
5
|
type AiSdkProviderOptions = Record<string, Record<string, unknown>>;
|
|
6
6
|
interface AiSdkProviderOptionsResult {
|
package/dist/ai-sdk.js
CHANGED
|
@@ -1,543 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
normalize
|
|
3
|
-
} from "./chunk-DPVT3FFP.js";
|
|
4
|
-
import {
|
|
5
|
-
parse
|
|
6
|
-
} from "./chunk-5YTG2NRX.js";
|
|
7
|
-
import "./chunk-76EFNZCF.js";
|
|
8
|
-
|
|
9
|
-
// src/ai-sdk.ts
|
|
10
|
-
var PROVIDER_OPTION_KEYS = {
|
|
11
|
-
openai: "openai",
|
|
12
|
-
azure: "azure",
|
|
13
|
-
anthropic: "anthropic",
|
|
14
|
-
google: "google",
|
|
15
|
-
"google-vertex": "vertex",
|
|
16
|
-
mistral: "mistral",
|
|
17
|
-
cohere: "cohere",
|
|
18
|
-
bedrock: "bedrock",
|
|
19
|
-
openrouter: "openrouter",
|
|
20
|
-
vercel: "gateway",
|
|
21
|
-
xai: "xai",
|
|
22
|
-
groq: "groq",
|
|
23
|
-
fal: "fal",
|
|
24
|
-
deepinfra: "deepinfra",
|
|
25
|
-
"black-forest-labs": "blackForestLabs",
|
|
26
|
-
together: "together",
|
|
27
|
-
fireworks: "fireworks",
|
|
28
|
-
deepseek: "deepseek",
|
|
29
|
-
moonshotai: "moonshotai",
|
|
30
|
-
perplexity: "perplexity",
|
|
31
|
-
alibaba: "alibaba",
|
|
32
|
-
cerebras: "cerebras",
|
|
33
|
-
replicate: "replicate",
|
|
34
|
-
prodia: "prodia",
|
|
35
|
-
luma: "luma",
|
|
36
|
-
bytedance: "bytedance",
|
|
37
|
-
kling: "kling",
|
|
38
|
-
elevenlabs: "elevenlabs",
|
|
39
|
-
assemblyai: "assemblyai",
|
|
40
|
-
deepgram: "deepgram",
|
|
41
|
-
gladia: "gladia",
|
|
42
|
-
lmnt: "lmnt",
|
|
43
|
-
hume: "hume",
|
|
44
|
-
revai: "revai",
|
|
45
|
-
baseten: "baseten",
|
|
46
|
-
huggingface: "huggingface"
|
|
47
|
-
};
|
|
48
|
-
var TRUE_VALUES = /* @__PURE__ */ new Set(["true", "1", "yes", "on"]);
|
|
49
|
-
var FALSE_VALUES = /* @__PURE__ */ new Set(["false", "0", "no", "off"]);
|
|
50
|
-
function providerOptionsKey(provider) {
|
|
51
|
-
return PROVIDER_OPTION_KEYS[provider];
|
|
52
|
-
}
|
|
53
|
-
function setProviderOption(options, provider, key, value) {
|
|
54
|
-
options[provider] ?? (options[provider] = {});
|
|
55
|
-
options[provider][key] = value;
|
|
56
|
-
}
|
|
57
|
-
function parseBoolean(value) {
|
|
58
|
-
const normalized = value.trim().toLowerCase();
|
|
59
|
-
if (TRUE_VALUES.has(normalized)) return true;
|
|
60
|
-
if (FALSE_VALUES.has(normalized)) return false;
|
|
61
|
-
return void 0;
|
|
62
|
-
}
|
|
63
|
-
function parseNumber(value) {
|
|
64
|
-
if (!value.trim()) return void 0;
|
|
65
|
-
const parsed = Number(value);
|
|
66
|
-
return Number.isFinite(parsed) ? parsed : void 0;
|
|
67
|
-
}
|
|
68
|
-
function parseJson(value) {
|
|
69
|
-
try {
|
|
70
|
-
return JSON.parse(value);
|
|
71
|
-
} catch {
|
|
72
|
-
return void 0;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function parseStringList(value) {
|
|
76
|
-
const json = parseJson(value);
|
|
77
|
-
if (Array.isArray(json)) {
|
|
78
|
-
return json.filter((item) => typeof item === "string");
|
|
79
|
-
}
|
|
80
|
-
return value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
81
|
-
}
|
|
82
|
-
function typedValue(value) {
|
|
83
|
-
const booleanValue = parseBoolean(value);
|
|
84
|
-
if (booleanValue !== void 0) return booleanValue;
|
|
85
|
-
const numberValue = parseNumber(value);
|
|
86
|
-
if (numberValue !== void 0) return numberValue;
|
|
87
|
-
const jsonValue = parseJson(value);
|
|
88
|
-
if (jsonValue !== void 0) return jsonValue;
|
|
89
|
-
return value;
|
|
90
|
-
}
|
|
91
|
-
function mergeObjectOption(options, provider, key, value) {
|
|
92
|
-
const parsed = parseJson(value);
|
|
93
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
94
|
-
setProviderOption(options, provider, key, parsed);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function addOpenAiOption(options, key, value, target = "openai") {
|
|
98
|
-
const mappings = {
|
|
99
|
-
reasoning_effort: "reasoningEffort",
|
|
100
|
-
max_completion_tokens: "maxCompletionTokens",
|
|
101
|
-
parallel_tool_calls: "parallelToolCalls",
|
|
102
|
-
service_tier: "serviceTier",
|
|
103
|
-
strict_json_schema: "strictJsonSchema",
|
|
104
|
-
text_verbosity: "textVerbosity",
|
|
105
|
-
prompt_cache_key: "promptCacheKey",
|
|
106
|
-
prompt_cache_retention: "promptCacheRetention",
|
|
107
|
-
safety_identifier: "safetyIdentifier",
|
|
108
|
-
system_message_mode: "systemMessageMode",
|
|
109
|
-
force_reasoning: "forceReasoning",
|
|
110
|
-
reasoning_summary: "reasoningSummary",
|
|
111
|
-
previous_response_id: "previousResponseId",
|
|
112
|
-
max_tool_calls: "maxToolCalls",
|
|
113
|
-
allowed_tools: "allowedTools"
|
|
114
|
-
};
|
|
115
|
-
const directKeys = /* @__PURE__ */ new Set([
|
|
116
|
-
"conversation",
|
|
117
|
-
"instructions",
|
|
118
|
-
"logprobs",
|
|
119
|
-
"metadata",
|
|
120
|
-
"prediction",
|
|
121
|
-
"store",
|
|
122
|
-
"truncation",
|
|
123
|
-
"user"
|
|
124
|
-
]);
|
|
125
|
-
if (!mappings[key] && !directKeys.has(key) && key !== "include") return;
|
|
126
|
-
const optionKey = mappings[key] ?? key;
|
|
127
|
-
if (key === "include") {
|
|
128
|
-
setProviderOption(options, target, optionKey, parseStringList(value));
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (key === "metadata" || key === "prediction" || key === "allowed_tools") {
|
|
132
|
-
mergeObjectOption(options, target, optionKey, value);
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
setProviderOption(options, target, optionKey, typedValue(value));
|
|
136
|
-
}
|
|
137
|
-
function addAnthropicOption(options, key, value) {
|
|
138
|
-
const target = "anthropic";
|
|
139
|
-
if (key === "cache_control" || key === "cacheControl") {
|
|
140
|
-
const ttl = options[target]?.cacheControl;
|
|
141
|
-
const ttlValue = ttl && typeof ttl === "object" && "ttl" in ttl ? ttl.ttl : void 0;
|
|
142
|
-
setProviderOption(options, target, "cacheControl", {
|
|
143
|
-
type: value === "ephemeral" ? "ephemeral" : value,
|
|
144
|
-
...ttlValue ? { ttl: ttlValue } : {}
|
|
145
|
-
});
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (key === "cache_ttl") {
|
|
149
|
-
const current = options[target]?.cacheControl;
|
|
150
|
-
setProviderOption(options, target, "cacheControl", {
|
|
151
|
-
...current && typeof current === "object" ? current : {},
|
|
152
|
-
type: "ephemeral",
|
|
153
|
-
ttl: value
|
|
154
|
-
});
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
if (key === "thinking") {
|
|
158
|
-
mergeObjectOption(options, target, "thinking", value);
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
if (key === "thinking_budget" || key === "budget_tokens") {
|
|
162
|
-
const budgetTokens = parseNumber(value);
|
|
163
|
-
if (budgetTokens !== void 0) {
|
|
164
|
-
setProviderOption(options, target, "thinking", {
|
|
165
|
-
type: "enabled",
|
|
166
|
-
budgetTokens
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
const mappings = {
|
|
172
|
-
send_reasoning: "sendReasoning",
|
|
173
|
-
structured_output_mode: "structuredOutputMode",
|
|
174
|
-
disable_parallel_tool_use: "disableParallelToolUse",
|
|
175
|
-
tool_streaming: "toolStreaming",
|
|
176
|
-
inference_geo: "inferenceGeo",
|
|
177
|
-
anthropic_beta: "anthropicBeta",
|
|
178
|
-
mcp_servers: "mcpServers",
|
|
179
|
-
task_budget: "taskBudget",
|
|
180
|
-
context_management: "contextManagement"
|
|
181
|
-
};
|
|
182
|
-
const directKeys = /* @__PURE__ */ new Set([
|
|
183
|
-
"effort",
|
|
184
|
-
"speed",
|
|
185
|
-
"sendReasoning",
|
|
186
|
-
"structuredOutputMode",
|
|
187
|
-
"disableParallelToolUse",
|
|
188
|
-
"toolStreaming",
|
|
189
|
-
"inferenceGeo",
|
|
190
|
-
"anthropicBeta",
|
|
191
|
-
"metadata",
|
|
192
|
-
"mcpServers",
|
|
193
|
-
"container",
|
|
194
|
-
"taskBudget",
|
|
195
|
-
"contextManagement"
|
|
196
|
-
]);
|
|
197
|
-
if (!mappings[key] && !directKeys.has(key)) return;
|
|
198
|
-
const optionKey = mappings[key] ?? key;
|
|
199
|
-
if (key === "anthropic_beta") {
|
|
200
|
-
setProviderOption(options, target, optionKey, parseStringList(value));
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (key === "metadata" || key === "mcp_servers" || key === "container" || key === "task_budget" || key === "context_management") {
|
|
204
|
-
mergeObjectOption(options, target, optionKey, value);
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
setProviderOption(options, target, optionKey, typedValue(value));
|
|
208
|
-
}
|
|
209
|
-
function addGoogleOption(options, key, value, target = "google") {
|
|
210
|
-
if (key === "thinking_budget" || key === "thinking_level" || key === "include_thoughts") {
|
|
211
|
-
const current = options[target]?.thinkingConfig;
|
|
212
|
-
const thinkingConfig = current && typeof current === "object" && !Array.isArray(current) ? { ...current } : {};
|
|
213
|
-
if (key === "thinking_budget") {
|
|
214
|
-
const parsed = parseNumber(value);
|
|
215
|
-
if (parsed !== void 0) thinkingConfig.thinkingBudget = parsed;
|
|
216
|
-
}
|
|
217
|
-
if (key === "thinking_level") thinkingConfig.thinkingLevel = value;
|
|
218
|
-
if (key === "include_thoughts") {
|
|
219
|
-
const parsed = parseBoolean(value);
|
|
220
|
-
if (parsed !== void 0) thinkingConfig.includeThoughts = parsed;
|
|
221
|
-
}
|
|
222
|
-
setProviderOption(options, target, "thinkingConfig", thinkingConfig);
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
const mappings = {
|
|
226
|
-
cached_content: "cachedContent",
|
|
227
|
-
structured_outputs: "structuredOutputs",
|
|
228
|
-
safety_settings: "safetySettings",
|
|
229
|
-
response_modalities: "responseModalities",
|
|
230
|
-
audio_timestamp: "audioTimestamp",
|
|
231
|
-
media_resolution: "mediaResolution",
|
|
232
|
-
image_config: "imageConfig",
|
|
233
|
-
retrieval_config: "retrievalConfig",
|
|
234
|
-
stream_function_call_arguments: "streamFunctionCallArguments",
|
|
235
|
-
service_tier: "serviceTier"
|
|
236
|
-
};
|
|
237
|
-
const directKeys = /* @__PURE__ */ new Set([
|
|
238
|
-
"cachedContent",
|
|
239
|
-
"structuredOutputs",
|
|
240
|
-
"safetySettings",
|
|
241
|
-
"threshold",
|
|
242
|
-
"audioTimestamp",
|
|
243
|
-
"labels",
|
|
244
|
-
"mediaResolution",
|
|
245
|
-
"imageConfig",
|
|
246
|
-
"retrievalConfig",
|
|
247
|
-
"responseModalities",
|
|
248
|
-
"streamFunctionCallArguments",
|
|
249
|
-
"serviceTier"
|
|
250
|
-
]);
|
|
251
|
-
if (!mappings[key] && !directKeys.has(key)) return;
|
|
252
|
-
const optionKey = mappings[key] ?? key;
|
|
253
|
-
if (key === "response_modalities") {
|
|
254
|
-
setProviderOption(options, target, optionKey, parseStringList(value));
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
if (key === "safety_settings" || key === "labels" || key === "image_config" || key === "retrieval_config") {
|
|
258
|
-
mergeObjectOption(options, target, optionKey, value);
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
setProviderOption(options, target, optionKey, typedValue(value));
|
|
262
|
-
}
|
|
263
|
-
function addMistralOption(options, key, value) {
|
|
264
|
-
const target = "mistral";
|
|
265
|
-
const mappings = {
|
|
266
|
-
safe_prompt: "safePrompt",
|
|
267
|
-
document_image_limit: "documentImageLimit",
|
|
268
|
-
document_page_limit: "documentPageLimit",
|
|
269
|
-
structured_outputs: "structuredOutputs",
|
|
270
|
-
strict_json_schema: "strictJsonSchema",
|
|
271
|
-
parallel_tool_calls: "parallelToolCalls",
|
|
272
|
-
reasoning_effort: "reasoningEffort"
|
|
273
|
-
};
|
|
274
|
-
const directKeys = /* @__PURE__ */ new Set([
|
|
275
|
-
"safePrompt",
|
|
276
|
-
"documentImageLimit",
|
|
277
|
-
"documentPageLimit",
|
|
278
|
-
"structuredOutputs",
|
|
279
|
-
"strictJsonSchema",
|
|
280
|
-
"parallelToolCalls",
|
|
281
|
-
"reasoningEffort"
|
|
282
|
-
]);
|
|
283
|
-
if (!mappings[key] && !directKeys.has(key)) return;
|
|
284
|
-
const optionKey = mappings[key] ?? key;
|
|
285
|
-
setProviderOption(options, target, optionKey, typedValue(value));
|
|
286
|
-
}
|
|
287
|
-
function addCohereOption(options, key, value) {
|
|
288
|
-
const target = "cohere";
|
|
289
|
-
if (key === "thinking") {
|
|
290
|
-
mergeObjectOption(options, target, "thinking", value);
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
if (key === "thinking_token_budget" || key === "token_budget") {
|
|
294
|
-
const tokenBudget = parseNumber(value);
|
|
295
|
-
if (tokenBudget !== void 0) {
|
|
296
|
-
setProviderOption(options, target, "thinking", {
|
|
297
|
-
type: "enabled",
|
|
298
|
-
tokenBudget
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
if (key === "thinking_type") {
|
|
304
|
-
const current = options[target]?.thinking;
|
|
305
|
-
setProviderOption(options, target, "thinking", {
|
|
306
|
-
...current && typeof current === "object" ? current : {},
|
|
307
|
-
type: value
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
function addBedrockOption(options, key, value) {
|
|
312
|
-
const target = "bedrock";
|
|
313
|
-
if (key === "cache_control") {
|
|
314
|
-
setProviderOption(options, target, "cachePoint", {
|
|
315
|
-
type: value === "ephemeral" ? "default" : value
|
|
316
|
-
});
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
if (key === "cache_ttl") {
|
|
320
|
-
const current = options[target]?.cachePoint;
|
|
321
|
-
setProviderOption(options, target, "cachePoint", {
|
|
322
|
-
...current && typeof current === "object" ? current : {},
|
|
323
|
-
type: "default",
|
|
324
|
-
ttl: value
|
|
325
|
-
});
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
if (key === "reasoning_config") {
|
|
329
|
-
mergeObjectOption(options, target, "reasoningConfig", value);
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
if (key === "budget_tokens" || key === "reasoning_effort") {
|
|
333
|
-
const current = options[target]?.reasoningConfig;
|
|
334
|
-
const reasoningConfig = current && typeof current === "object" && !Array.isArray(current) ? { ...current } : {};
|
|
335
|
-
reasoningConfig.type = "enabled";
|
|
336
|
-
if (key === "budget_tokens") {
|
|
337
|
-
const budgetTokens = parseNumber(value);
|
|
338
|
-
if (budgetTokens !== void 0)
|
|
339
|
-
reasoningConfig.budgetTokens = budgetTokens;
|
|
340
|
-
}
|
|
341
|
-
if (key === "reasoning_effort") reasoningConfig.maxReasoningEffort = value;
|
|
342
|
-
setProviderOption(options, target, "reasoningConfig", reasoningConfig);
|
|
343
|
-
return;
|
|
344
|
-
}
|
|
345
|
-
const mappings = {
|
|
346
|
-
additional_model_request_fields: "additionalModelRequestFields",
|
|
347
|
-
anthropic_beta: "anthropicBeta",
|
|
348
|
-
service_tier: "serviceTier"
|
|
349
|
-
};
|
|
350
|
-
const directKeys = /* @__PURE__ */ new Set([
|
|
351
|
-
"additionalModelRequestFields",
|
|
352
|
-
"anthropicBeta",
|
|
353
|
-
"serviceTier"
|
|
354
|
-
]);
|
|
355
|
-
if (!mappings[key] && !directKeys.has(key)) return;
|
|
356
|
-
const optionKey = mappings[key] ?? key;
|
|
357
|
-
if (key === "additional_model_request_fields") {
|
|
358
|
-
mergeObjectOption(options, target, optionKey, value);
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
if (key === "anthropic_beta") {
|
|
362
|
-
setProviderOption(options, target, optionKey, parseStringList(value));
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
setProviderOption(options, target, optionKey, typedValue(value));
|
|
366
|
-
}
|
|
367
|
-
function addGatewayOption(options, key, value) {
|
|
368
|
-
const target = "gateway";
|
|
369
|
-
const listKeys = /* @__PURE__ */ new Set(["only", "order", "tags", "models"]);
|
|
370
|
-
const objectKeys = /* @__PURE__ */ new Set(["byok", "provider_timeouts"]);
|
|
371
|
-
const mappings = {
|
|
372
|
-
zero_data_retention: "zeroDataRetention",
|
|
373
|
-
disallow_prompt_training: "disallowPromptTraining",
|
|
374
|
-
hipaa_compliant: "hipaaCompliant",
|
|
375
|
-
quota_entity_id: "quotaEntityId",
|
|
376
|
-
provider_timeouts: "providerTimeouts"
|
|
377
|
-
};
|
|
378
|
-
const directKeys = /* @__PURE__ */ new Set([
|
|
379
|
-
"sort",
|
|
380
|
-
"user",
|
|
381
|
-
"zeroDataRetention",
|
|
382
|
-
"disallowPromptTraining",
|
|
383
|
-
"hipaaCompliant",
|
|
384
|
-
"quotaEntityId",
|
|
385
|
-
"providerTimeouts"
|
|
386
|
-
]);
|
|
387
|
-
if (!mappings[key] && !directKeys.has(key) && !listKeys.has(key) && !objectKeys.has(key)) {
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
const optionKey = mappings[key] ?? key;
|
|
391
|
-
if (listKeys.has(key)) {
|
|
392
|
-
setProviderOption(options, target, optionKey, parseStringList(value));
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
if (objectKeys.has(key)) {
|
|
396
|
-
mergeObjectOption(options, target, optionKey, value);
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
setProviderOption(options, target, optionKey, typedValue(value));
|
|
400
|
-
}
|
|
401
|
-
function addOpenRouterOption(options, key, value) {
|
|
402
|
-
const target = "openrouter";
|
|
403
|
-
if (key === "models") {
|
|
404
|
-
setProviderOption(options, target, "models", parseStringList(value));
|
|
405
|
-
return;
|
|
406
|
-
}
|
|
407
|
-
if (key === "reasoning") {
|
|
408
|
-
mergeObjectOption(options, target, "reasoning", value);
|
|
409
|
-
return;
|
|
410
|
-
}
|
|
411
|
-
if (key === "reasoning_effort") {
|
|
412
|
-
const current = options[target]?.reasoning;
|
|
413
|
-
setProviderOption(options, target, "reasoning", {
|
|
414
|
-
...current && typeof current === "object" ? current : {},
|
|
415
|
-
effort: value
|
|
416
|
-
});
|
|
417
|
-
return;
|
|
418
|
-
}
|
|
419
|
-
if (key === "reasoning_max_tokens" || key === "max_reasoning_tokens") {
|
|
420
|
-
const current = options[target]?.reasoning;
|
|
421
|
-
const maxTokens = parseNumber(value);
|
|
422
|
-
if (maxTokens !== void 0) {
|
|
423
|
-
setProviderOption(options, target, "reasoning", {
|
|
424
|
-
...current && typeof current === "object" ? current : {},
|
|
425
|
-
max_tokens: maxTokens
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
if (key === "reasoning_enabled" || key === "reasoning_exclude") {
|
|
431
|
-
const current = options[target]?.reasoning;
|
|
432
|
-
const parsed = parseBoolean(value);
|
|
433
|
-
if (parsed !== void 0) {
|
|
434
|
-
setProviderOption(options, target, "reasoning", {
|
|
435
|
-
...current && typeof current === "object" ? current : {},
|
|
436
|
-
[key === "reasoning_enabled" ? "enabled" : "exclude"]: parsed
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
if (key === "user") {
|
|
442
|
-
setProviderOption(options, target, "user", value);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
function addFlexibleProviderOption(options, target, key, value) {
|
|
446
|
-
setProviderOption(options, target, key, typedValue(value));
|
|
447
|
-
}
|
|
448
|
-
function addProviderSpecificOption(options, provider, key, value, includeGatewayOptions) {
|
|
449
|
-
if (provider === "vercel") {
|
|
450
|
-
if (includeGatewayOptions) addGatewayOption(options, key, value);
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
if (provider === "openai") addOpenAiOption(options, key, value);
|
|
454
|
-
if (provider === "azure") addOpenAiOption(options, key, value, "azure");
|
|
455
|
-
if (provider === "anthropic") addAnthropicOption(options, key, value);
|
|
456
|
-
if (provider === "google") addGoogleOption(options, key, value);
|
|
457
|
-
if (provider === "google-vertex")
|
|
458
|
-
addGoogleOption(options, key, value, "vertex");
|
|
459
|
-
if (provider === "mistral") addMistralOption(options, key, value);
|
|
460
|
-
if (provider === "cohere") addCohereOption(options, key, value);
|
|
461
|
-
if (provider === "bedrock") addBedrockOption(options, key, value);
|
|
462
|
-
if (provider === "openrouter") addOpenRouterOption(options, key, value);
|
|
463
|
-
if (provider === "xai") addOpenAiOption(options, key, value, "xai");
|
|
464
|
-
if (provider === "groq") addOpenAiOption(options, key, value, "groq");
|
|
465
|
-
if (provider === "fal") addFlexibleProviderOption(options, "fal", key, value);
|
|
466
|
-
if (provider === "deepinfra")
|
|
467
|
-
addOpenAiOption(options, key, value, "deepinfra");
|
|
468
|
-
if (provider === "black-forest-labs")
|
|
469
|
-
addFlexibleProviderOption(options, "blackForestLabs", key, value);
|
|
470
|
-
if (provider === "together") addOpenAiOption(options, key, value, "together");
|
|
471
|
-
if (provider === "fireworks")
|
|
472
|
-
addOpenAiOption(options, key, value, "fireworks");
|
|
473
|
-
if (provider === "deepseek") addOpenAiOption(options, key, value, "deepseek");
|
|
474
|
-
if (provider === "moonshotai")
|
|
475
|
-
addOpenAiOption(options, key, value, "moonshotai");
|
|
476
|
-
if (provider === "perplexity")
|
|
477
|
-
addOpenAiOption(options, key, value, "perplexity");
|
|
478
|
-
if (provider === "alibaba") addOpenAiOption(options, key, value, "alibaba");
|
|
479
|
-
if (provider === "cerebras") addOpenAiOption(options, key, value, "cerebras");
|
|
480
|
-
if (provider === "replicate")
|
|
481
|
-
addFlexibleProviderOption(options, "replicate", key, value);
|
|
482
|
-
if (provider === "prodia")
|
|
483
|
-
addFlexibleProviderOption(options, "prodia", key, value);
|
|
484
|
-
if (provider === "luma")
|
|
485
|
-
addFlexibleProviderOption(options, "luma", key, value);
|
|
486
|
-
if (provider === "bytedance")
|
|
487
|
-
addFlexibleProviderOption(options, "bytedance", key, value);
|
|
488
|
-
if (provider === "kling")
|
|
489
|
-
addFlexibleProviderOption(options, "kling", key, value);
|
|
490
|
-
if (provider === "elevenlabs")
|
|
491
|
-
addFlexibleProviderOption(options, "elevenlabs", key, value);
|
|
492
|
-
if (provider === "assemblyai")
|
|
493
|
-
addFlexibleProviderOption(options, "assemblyai", key, value);
|
|
494
|
-
if (provider === "deepgram")
|
|
495
|
-
addFlexibleProviderOption(options, "deepgram", key, value);
|
|
496
|
-
if (provider === "gladia")
|
|
497
|
-
addFlexibleProviderOption(options, "gladia", key, value);
|
|
498
|
-
if (provider === "lmnt")
|
|
499
|
-
addFlexibleProviderOption(options, "lmnt", key, value);
|
|
500
|
-
if (provider === "hume")
|
|
501
|
-
addFlexibleProviderOption(options, "hume", key, value);
|
|
502
|
-
if (provider === "revai")
|
|
503
|
-
addFlexibleProviderOption(options, "revai", key, value);
|
|
504
|
-
if (provider === "baseten") addOpenAiOption(options, key, value, "baseten");
|
|
505
|
-
if (provider === "huggingface")
|
|
506
|
-
addOpenAiOption(options, key, value, "huggingface");
|
|
507
|
-
}
|
|
508
|
-
function createAiSdkProviderOptions(configOrResult, options = {}) {
|
|
509
|
-
const normalized = typeof configOrResult === "string" ? normalize(parse(configOrResult), options) : "changes" in configOrResult && "subProvider" in configOrResult ? configOrResult : normalize(configOrResult, options);
|
|
510
|
-
const providerOptions = {};
|
|
511
|
-
if (!normalized.provider) {
|
|
512
|
-
return {
|
|
513
|
-
provider: normalized.provider,
|
|
514
|
-
subProvider: normalized.subProvider,
|
|
515
|
-
providerOptions
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
const includeGatewayOptions = options.includeGatewayOptions ?? normalized.provider === "vercel";
|
|
519
|
-
for (const [key, value] of Object.entries(normalized.config.params)) {
|
|
520
|
-
addProviderSpecificOption(
|
|
521
|
-
providerOptions,
|
|
522
|
-
normalized.provider,
|
|
523
|
-
key,
|
|
524
|
-
value,
|
|
525
|
-
includeGatewayOptions
|
|
526
|
-
);
|
|
527
|
-
}
|
|
528
|
-
if (normalized.provider !== "vercel" && !providerOptions[providerOptionsKey(normalized.provider)]) {
|
|
529
|
-
return {
|
|
530
|
-
provider: normalized.provider,
|
|
531
|
-
subProvider: normalized.subProvider,
|
|
532
|
-
providerOptions: {}
|
|
533
|
-
};
|
|
534
|
-
}
|
|
535
|
-
return {
|
|
536
|
-
provider: normalized.provider,
|
|
537
|
-
subProvider: normalized.subProvider,
|
|
538
|
-
providerOptions
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
export {
|
|
542
|
-
createAiSdkProviderOptions
|
|
543
|
-
};
|
|
1
|
+
import{normalize as e}from"./chunk-JURQSYOT.js";import{parse as t}from"./chunk-M5ENVTNI.js";import"./chunk-LIYUWJME.js";var o={openai:"openai",azure:"azure",anthropic:"anthropic",google:"google","google-vertex":"vertex",mistral:"mistral",cohere:"cohere",bedrock:"bedrock",openrouter:"openrouter",vercel:"gateway",xai:"xai",groq:"groq",fal:"fal",deepinfra:"deepinfra","black-forest-labs":"blackForestLabs",together:"together",fireworks:"fireworks",deepseek:"deepseek",moonshotai:"moonshotai",perplexity:"perplexity",alibaba:"alibaba",cerebras:"cerebras",replicate:"replicate",prodia:"prodia",luma:"luma",bytedance:"bytedance",kling:"kling",elevenlabs:"elevenlabs",assemblyai:"assemblyai",deepgram:"deepgram",gladia:"gladia",lmnt:"lmnt",hume:"hume",revai:"revai",baseten:"baseten",huggingface:"huggingface"},r=new Set(["true","1","yes","on"]),n=new Set(["false","0","no","off"]);function i(e,t,o,r){e[t]??(e[t]={}),e[t][o]=r}function a(e){const t=e.trim().toLowerCase();return!!r.has(t)||!n.has(t)&&void 0}function s(e){if(!e.trim())return;const t=Number(e);return Number.isFinite(t)?t:void 0}function c(e){try{return JSON.parse(e)}catch{return}}function l(e){const t=c(e);return Array.isArray(t)?t.filter(e=>"string"==typeof e):e.split(",").map(e=>e.trim()).filter(Boolean)}function d(e){const t=a(e);if(void 0!==t)return t;const o=s(e);if(void 0!==o)return o;const r=c(e);return void 0!==r?r:e}function u(e,t,o,r){const n=c(r);n&&"object"==typeof n&&!Array.isArray(n)&&i(e,t,o,n)}function p(e,t,o,r="openai"){const n={reasoning_effort:"reasoningEffort",max_completion_tokens:"maxCompletionTokens",parallel_tool_calls:"parallelToolCalls",service_tier:"serviceTier",strict_json_schema:"strictJsonSchema",text_verbosity:"textVerbosity",prompt_cache_key:"promptCacheKey",prompt_cache_retention:"promptCacheRetention",safety_identifier:"safetyIdentifier",system_message_mode:"systemMessageMode",force_reasoning:"forceReasoning",reasoning_summary:"reasoningSummary",previous_response_id:"previousResponseId",max_tool_calls:"maxToolCalls",allowed_tools:"allowedTools"};if(!n[t]&&!new Set(["conversation","instructions","logprobs","metadata","prediction","store","truncation","user"]).has(t)&&"include"!==t)return;const a=n[t]??t;"include"!==t?"metadata"!==t&&"prediction"!==t&&"allowed_tools"!==t?i(e,r,a,d(o)):u(e,r,a,o):i(e,r,a,l(o))}function g(e,t,o,r="google"){if("thinking_budget"===t||"thinking_level"===t||"include_thoughts"===t){const n=e[r]?.thinkingConfig,c=n&&"object"==typeof n&&!Array.isArray(n)?{...n}:{};if("thinking_budget"===t){const e=s(o);void 0!==e&&(c.thinkingBudget=e)}if("thinking_level"===t&&(c.thinkingLevel=o),"include_thoughts"===t){const e=a(o);void 0!==e&&(c.includeThoughts=e)}return void i(e,r,"thinkingConfig",c)}const n={cached_content:"cachedContent",structured_outputs:"structuredOutputs",safety_settings:"safetySettings",response_modalities:"responseModalities",audio_timestamp:"audioTimestamp",media_resolution:"mediaResolution",image_config:"imageConfig",retrieval_config:"retrievalConfig",stream_function_call_arguments:"streamFunctionCallArguments",service_tier:"serviceTier"};if(!n[t]&&!new Set(["cachedContent","structuredOutputs","safetySettings","threshold","audioTimestamp","labels","mediaResolution","imageConfig","retrievalConfig","responseModalities","streamFunctionCallArguments","serviceTier"]).has(t))return;const c=n[t]??t;"response_modalities"!==t?"safety_settings"!==t&&"labels"!==t&&"image_config"!==t&&"retrieval_config"!==t?i(e,r,c,d(o)):u(e,r,c,o):i(e,r,c,l(o))}function f(e,t,o,r){i(e,t,o,d(r))}var m={openai:p,azure:(e,t,o)=>p(e,t,o,"azure"),anthropic:function(e,t,o){const r="anthropic";if("cache_control"===t||"cacheControl"===t){const t=e[r]?.cacheControl,n=t&&"object"==typeof t&&"ttl"in t?t.ttl:void 0;return void i(e,r,"cacheControl",{type:"ephemeral"===o?"ephemeral":o,...n?{ttl:n}:{}})}if("cache_ttl"===t){const t=e[r]?.cacheControl;return void i(e,r,"cacheControl",{...t&&"object"==typeof t?t:{},type:"ephemeral",ttl:o})}if("thinking"===t)return void u(e,r,"thinking",o);if("thinking_budget"===t||"budget_tokens"===t){const t=s(o);return void(void 0!==t&&i(e,r,"thinking",{type:"enabled",budgetTokens:t}))}const n={send_reasoning:"sendReasoning",structured_output_mode:"structuredOutputMode",disable_parallel_tool_use:"disableParallelToolUse",tool_streaming:"toolStreaming",inference_geo:"inferenceGeo",anthropic_beta:"anthropicBeta",mcp_servers:"mcpServers",task_budget:"taskBudget",context_management:"contextManagement"};if(!n[t]&&!new Set(["effort","speed","sendReasoning","structuredOutputMode","disableParallelToolUse","toolStreaming","inferenceGeo","anthropicBeta","metadata","mcpServers","container","taskBudget","contextManagement"]).has(t))return;const a=n[t]??t;"anthropic_beta"!==t?"metadata"!==t&&"mcp_servers"!==t&&"container"!==t&&"task_budget"!==t&&"context_management"!==t?i(e,r,a,d(o)):u(e,r,a,o):i(e,r,a,l(o))},google:g,"google-vertex":(e,t,o)=>g(e,t,o,"vertex"),mistral:function(e,t,o){const r={safe_prompt:"safePrompt",document_image_limit:"documentImageLimit",document_page_limit:"documentPageLimit",structured_outputs:"structuredOutputs",strict_json_schema:"strictJsonSchema",parallel_tool_calls:"parallelToolCalls",reasoning_effort:"reasoningEffort"};if(!r[t]&&!new Set(["safePrompt","documentImageLimit","documentPageLimit","structuredOutputs","strictJsonSchema","parallelToolCalls","reasoningEffort"]).has(t))return;i(e,"mistral",r[t]??t,d(o))},cohere:function(e,t,o){const r="cohere";if("thinking"!==t){if("thinking_token_budget"===t||"token_budget"===t){const t=s(o);return void(void 0!==t&&i(e,r,"thinking",{type:"enabled",tokenBudget:t}))}if("thinking_type"===t){const t=e[r]?.thinking;i(e,r,"thinking",{...t&&"object"==typeof t?t:{},type:o})}}else u(e,r,"thinking",o)},bedrock:function(e,t,o){const r="bedrock";if("cache_control"===t)return void i(e,r,"cachePoint",{type:"ephemeral"===o?"default":o});if("cache_ttl"===t){const t=e[r]?.cachePoint;return void i(e,r,"cachePoint",{...t&&"object"==typeof t?t:{},type:"default",ttl:o})}if("reasoning_config"===t)return void u(e,r,"reasoningConfig",o);if("budget_tokens"===t||"reasoning_effort"===t){const n=e[r]?.reasoningConfig,a=n&&"object"==typeof n&&!Array.isArray(n)?{...n}:{};if(a.type="enabled","budget_tokens"===t){const e=s(o);void 0!==e&&(a.budgetTokens=e)}return"reasoning_effort"===t&&(a.maxReasoningEffort=o),void i(e,r,"reasoningConfig",a)}const n={additional_model_request_fields:"additionalModelRequestFields",anthropic_beta:"anthropicBeta",service_tier:"serviceTier"};if(!n[t]&&!new Set(["additionalModelRequestFields","anthropicBeta","serviceTier"]).has(t))return;const a=n[t]??t;"additional_model_request_fields"!==t?i(e,r,a,"anthropic_beta"!==t?d(o):l(o)):u(e,r,a,o)},openrouter:function(e,t,o){const r="openrouter",n=t.startsWith("provider.")?t.slice(9):t,p=new Set(["order","only","ignore","quantizations"]),g=new Set(["provider","sort","preferred_min_throughput","preferred_max_latency","max_price"]),f=new Set(["allow_fallbacks","require_parameters","data_collection","zdr","enforce_distillable_text"]);if("models"!==t)if("transforms"!==t){if("plugins"===t){const t=c(o);return void i(e,r,"plugins",Array.isArray(t)?t:l(o))}if(t.startsWith("provider.")||p.has(n)||f.has(n)||g.has(n)){if("provider"===n)return void u(e,r,"provider",o);const t=e[r]?.provider,a=t&&"object"==typeof t&&!Array.isArray(t)?{...t}:{};if(p.has(n))a[n]=l(o);else if(g.has(n)){const e=c(o);a[n]=void 0!==e?e:d(o)}else a[n]=d(o);return void i(e,r,"provider",a)}if("reasoning"!==t){if("reasoning_effort"===t){const t=e[r]?.reasoning;return void i(e,r,"reasoning",{...t&&"object"==typeof t?t:{},effort:o})}if("reasoning_max_tokens"===t||"max_reasoning_tokens"===t){const t=e[r]?.reasoning,n=s(o);return void(void 0!==n&&i(e,r,"reasoning",{...t&&"object"==typeof t?t:{},max_tokens:n}))}if("reasoning_enabled"===t||"reasoning_exclude"===t){const n=e[r]?.reasoning,s=a(o);return void(void 0!==s&&i(e,r,"reasoning",{...n&&"object"==typeof n?n:{},["reasoning_enabled"===t?"enabled":"exclude"]:s}))}"user"===t&&i(e,r,"user",o)}else u(e,r,"reasoning",o)}else i(e,r,"transforms",l(o));else i(e,r,"models",l(o))},xai:(e,t,o)=>p(e,t,o,"xai"),groq:(e,t,o)=>p(e,t,o,"groq"),fal:(e,t,o)=>f(e,"fal",t,o),deepinfra:(e,t,o)=>p(e,t,o,"deepinfra"),"black-forest-labs":(e,t,o)=>f(e,"blackForestLabs",t,o),together:(e,t,o)=>p(e,t,o,"together"),fireworks:(e,t,o)=>p(e,t,o,"fireworks"),deepseek:(e,t,o)=>p(e,t,o,"deepseek"),moonshotai:(e,t,o)=>p(e,t,o,"moonshotai"),perplexity:(e,t,o)=>p(e,t,o,"perplexity"),alibaba:(e,t,o)=>p(e,t,o,"alibaba"),cerebras:(e,t,o)=>p(e,t,o,"cerebras"),replicate:(e,t,o)=>f(e,"replicate",t,o),prodia:(e,t,o)=>f(e,"prodia",t,o),luma:(e,t,o)=>f(e,"luma",t,o),bytedance:(e,t,o)=>f(e,"bytedance",t,o),kling:(e,t,o)=>f(e,"kling",t,o),elevenlabs:(e,t,o)=>f(e,"elevenlabs",t,o),assemblyai:(e,t,o)=>f(e,"assemblyai",t,o),deepgram:(e,t,o)=>f(e,"deepgram",t,o),gladia:(e,t,o)=>f(e,"gladia",t,o),lmnt:(e,t,o)=>f(e,"lmnt",t,o),hume:(e,t,o)=>f(e,"hume",t,o),revai:(e,t,o)=>f(e,"revai",t,o),baseten:(e,t,o)=>p(e,t,o,"baseten"),huggingface:(e,t,o)=>p(e,t,o,"huggingface")};function _(e,t,o,r,n){"vercel"!==t?m[t](e,o,r):n&&function(e,t,o){const r="gateway",n=new Set(["only","order","tags","models"]),a=new Set(["byok","provider_timeouts"]),s={zero_data_retention:"zeroDataRetention",disallow_prompt_training:"disallowPromptTraining",hipaa_compliant:"hipaaCompliant",quota_entity_id:"quotaEntityId",provider_timeouts:"providerTimeouts"};if(!(s[t]||new Set(["sort","caching","user","zeroDataRetention","disallowPromptTraining","hipaaCompliant","quotaEntityId","providerTimeouts"]).has(t)||n.has(t)||a.has(t)))return;const c=s[t]??t;n.has(t)?i(e,r,c,l(o)):a.has(t)?u(e,r,c,o):i(e,r,c,d(o))}(e,o,r)}function h(r,n={}){const i="string"==typeof r?e(t(r),n):"changes"in r&&"subProvider"in r?r:e(r,n),a={};if(!i.provider)return{provider:i.provider,subProvider:i.subProvider,providerOptions:a};const s=n.includeGatewayOptions??"vercel"===i.provider;for(const[e,t]of Object.entries(i.config.params))_(a,i.provider,e,t,s);return"vercel"===i.provider||a[c=i.provider,o[c]]?{provider:i.provider,subProvider:i.subProvider,providerOptions:a}:{provider:i.provider,subProvider:i.subProvider,providerOptions:{}};var c}export{h as createAiSdkProviderOptions};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{normalize as e}from"./chunk-JURQSYOT.js";import{parse as o}from"./chunk-M5ENVTNI.js";import{PARAM_SPECS as r,PROVIDER_PARAMS as t,bedrockSupportsCaching as s,detectBedrockModelFamily as n}from"./chunk-LIYUWJME.js";function a(e,o,s){const n=o[e]??e,a=t[s]?.[n];return a?{spec:r[s]?.[a],canonical:n}:{spec:void 0,canonical:n}}function i(i,p={}){const u=o(i),{config:c,provider:m,subProvider:l}=e(u),d=[];if(!m)return d.push({param:"host",value:c.host,message:`Unknown provider for host "${c.host}". Validation skipped.`,severity:p.strict?"error":"warning"}),d;const v=l??m,f=r[v],h=l?function(e){const o={};for(const[r,s]of Object.entries(t[e]))o[s]=r;return o}(m):void 0,b=l?function(e,o){const r=new Set,s=new Set(Object.keys(t[o]));for(const[o,n]of Object.entries(t[e]))s.has(o)&&r.add(n);return r}(m,l):new Set(Object.values(t[m]));for(const[e,o]of Object.entries(c.params)){const t=l&&h?a(e,h,l):void 0,i=l&&!t?.spec?r[m]?.[e]:void 0;if("bedrock"===m){const r=n(c.model);if("topK"===e&&r&&"anthropic"!==r&&"cohere"!==r&&"mistral"!==r){d.push({param:e,value:o,message:`"topK" is not supported by ${r} models on Bedrock.`,severity:"error"});continue}if("cache_control"===e&&!s(c.model)){d.push({param:e,value:o,message:`Prompt caching is only supported for Anthropic Claude and Amazon Nova models on Bedrock, not ${r??"unknown"} models.`,severity:"error"});continue}}if(!b.has(e)&&!f[e]&&!i){p.strict&&d.push({param:e,value:o,message:`Unknown param "${e}" for ${v}.`,severity:"error"});continue}const u=t?.spec??i??f[e];if(u){if(("anthropic"===v||"bedrock"===m&&"anthropic"===n(c.model))&&("temperature"===e||"top_p"===e||"topP"===e)){const r="temperature"===e?"bedrock"===m?"topP":"top_p":"temperature";"temperature"===e&&void 0!==c.params[r]&&d.push({param:e,value:o,message:`Cannot specify both "temperature" and "${r}" for Anthropic models.`,severity:"error"})}if("number"===u.type){const r=Number(o);if(isNaN(r)){d.push({param:e,value:o,message:`"${e}" should be a number, got "${o}".`,severity:"error"});continue}void 0!==u.min&&r<u.min&&d.push({param:e,value:o,message:`"${e}" must be >= ${u.min}, got ${r}.`,severity:"error"}),void 0!==u.max&&r>u.max&&d.push({param:e,value:o,message:`"${e}" must be <= ${u.max}, got ${r}.`,severity:"error"})}"boolean"===u.type&&(["true","false","0","1"].includes(o)||d.push({param:e,value:o,message:`"${e}" should be a boolean (true/false), got "${o}".`,severity:"error"})),"string"===u.type&&u.values&&(u.values.includes(o)||d.push({param:e,value:o,message:`"${e}" must be one of [${u.values.join(", ")}], got "${o}".`,severity:"error"}))}}return d}export{i as validate};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{ALIASES as o,CACHE_TTLS as e,CACHE_VALUES as s,PROVIDER_PARAMS as a,REASONING_MODEL_UNSUPPORTED as t,bedrockSupportsCaching as r,canHostOpenAIModels as c,detectGatewaySubProvider as n,detectProvider as m,isGatewayProvider as i,isReasoningModel as h,providerFromHostAlias as u}from"./chunk-LIYUWJME.js";var l=/^\d+[mh]$/;function p(p,d={}){const f=(p.hostAlias?u(p.hostAlias):void 0)??m(p.host),v=f&&i(f)?n(p.model):void 0,$=[],_={};for(const[n,m]of Object.entries(p.params)){let i=n;if(o[i]){const e=o[i];d.verbose&&$.push({from:i,to:e,value:m,reason:`alias: "${i}" → "${e}"`}),i=e}if("cache"===i&&f){let o=s[f];if("bedrock"!==f||r(p.model)||(o=void 0),!o){d.verbose&&$.push({from:"cache",to:"(dropped)",value:m,reason:`${f} does not use a cache param for this model (caching is automatic or unsupported)`});continue}const t="true"===m||"1"===m||"yes"===m,c=l.test(m);if(t||c){const s=a[f]?.cache??"cache";d.verbose&&$.push({from:"cache",to:s,value:o,reason:`cache=${m} → ${s}=${o} for ${f}`}),_[s]=o,c&&e[f]&&(d.verbose&&$.push({from:"cache",to:"cache_ttl",value:m,reason:`cache=${m} → cache_ttl=${m} for ${f}`}),_.cache_ttl=m);continue}}if(f&&a[f]){const o=a[f][i];o&&o!==i&&(d.verbose&&$.push({from:i,to:o,value:m,reason:`${f} uses "${o}" instead of "${i}"`}),i=o)}f&&c(f)&&h(p.model)&&"max_tokens"===i&&(d.verbose&&$.push({from:"max_tokens",to:"max_completion_tokens",value:m,reason:"OpenAI reasoning models use max_completion_tokens instead of max_tokens"}),i="max_completion_tokens"),f&&c(f)&&h(p.model)&&t.has(i)?d.verbose&&$.push({from:i,to:"(dropped)",value:m,reason:`${f} reasoning model "${p.model}" does not support "${i}"`}):_[i]=m}return{config:{...p,params:_},provider:f,subProvider:v,changes:$}}export{p as normalize};
|