@juspay/neurolink 13.16.2 → 13.17.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/CHANGELOG.md +2 -2
- package/dist/adapters/providerImageAdapter.js +29 -495
- package/dist/browser/neurolink.min.js +465 -471
- package/dist/constants/contextWindows.js +13 -328
- package/dist/constants/enums.d.ts +1 -0
- package/dist/constants/enums.js +2 -1
- package/dist/context/anthropicLoopGuard.d.ts +1 -1
- package/dist/context/anthropicLoopGuard.js +2 -1
- package/dist/core/constants.js +6 -53
- package/dist/core/geminiLoopAdapter.js +8 -6
- package/dist/core/modules/structuredOutputPolicy.d.ts +0 -21
- package/dist/core/modules/structuredOutputPolicy.js +4 -54
- package/dist/core/nativeGenerateLoop.js +5 -0
- package/dist/factories/providerDescriptors.js +3 -2
- package/dist/factories/providerRegistry.js +3 -2
- package/dist/models/manifests/anthropic.d.ts +1 -1
- package/dist/models/manifests/anthropic.js +1 -1
- package/dist/models/manifests/azure.js +9 -9
- package/dist/models/manifests/ollama.js +13 -0
- package/dist/models/manifests/openai.d.ts +1 -1
- package/dist/models/manifests/openai.js +1 -1
- package/dist/models/modelRegistry.js +25 -42
- package/dist/neurolink.js +1 -0
- package/dist/providers/amazonBedrock/client.js +9 -37
- package/dist/providers/amazonBedrock/loopAdapter.js +3 -11
- package/dist/providers/amazonSagemaker.js +6 -0
- package/dist/providers/anthropic/client.js +57 -100
- package/dist/providers/anthropic/loopAdapter.js +24 -22
- package/dist/providers/anthropic/structuredOutput.d.ts +0 -2
- package/dist/providers/anthropic/structuredOutput.js +3 -5
- package/dist/providers/azureOpenai.js +4 -22
- package/dist/providers/catalog/loader.js +12 -25
- package/dist/providers/cohere.js +5 -30
- package/dist/providers/googleAiStudio/client.js +12 -61
- package/dist/providers/googleNativeGemini3/utils.js +43 -102
- package/dist/providers/googleVertex/client.d.ts +7 -0
- package/dist/providers/googleVertex/client.js +150 -192
- package/dist/providers/litellm/client.js +10 -50
- package/dist/providers/llamaCpp.js +4 -15
- package/dist/providers/lmStudio.js +9 -14
- package/dist/providers/nvidiaNim/client.js +4 -62
- package/dist/providers/ollama/client.js +14 -54
- package/dist/providers/ollama/constants.d.ts +1 -3
- package/dist/providers/ollama/constants.js +2 -3
- package/dist/providers/openAI/client.js +5 -57
- package/dist/providers/openRouter/client.js +4 -65
- package/dist/providers/openaiChatCompletionsBase.js +53 -62
- package/dist/providers/openaiChatCompletionsClient.js +17 -57
- package/dist/providers/openaiCompatible/client.js +9 -36
- package/dist/providers/rules/README.md +100 -0
- package/dist/providers/rules/anthropic.json +108 -0
- package/dist/providers/rules/azure.json +13 -0
- package/dist/providers/rules/bedrock.json +48 -0
- package/dist/providers/rules/cohere.json +32 -0
- package/dist/providers/rules/credentials.json +34 -0
- package/dist/providers/rules/errorRules.d.ts +17 -0
- package/dist/providers/rules/errorRules.js +197 -0
- package/dist/providers/rules/errorSignals.d.ts +2 -0
- package/dist/providers/rules/errorSignals.js +28 -0
- package/dist/providers/rules/fallbackModel.d.ts +4 -0
- package/dist/providers/rules/fallbackModel.js +21 -0
- package/dist/providers/rules/finalResultTool.d.ts +11 -0
- package/dist/providers/rules/finalResultTool.js +17 -0
- package/dist/providers/rules/finishReasons.d.ts +10 -0
- package/dist/providers/rules/finishReasons.js +28 -0
- package/dist/providers/rules/gemini.json +92 -0
- package/dist/providers/rules/google-ai.json +55 -0
- package/dist/providers/rules/limits.json +338 -0
- package/dist/providers/rules/litellm.json +36 -0
- package/dist/providers/rules/llamacpp.json +23 -0
- package/dist/providers/rules/lm-studio.json +21 -0
- package/dist/providers/rules/model-families.json +115 -0
- package/dist/providers/rules/modelFamilies.d.ts +10 -0
- package/dist/providers/rules/modelFamilies.js +45 -0
- package/dist/providers/rules/nvidia-nim.json +43 -0
- package/dist/providers/rules/ollama.json +37 -0
- package/dist/providers/rules/openai-chat.json +66 -0
- package/dist/providers/rules/openai-compatible.json +31 -0
- package/dist/providers/rules/openai.json +38 -0
- package/dist/providers/rules/openrouter.json +57 -0
- package/dist/providers/rules/proxy.json +44 -0
- package/dist/providers/rules/registry.d.ts +7 -0
- package/dist/providers/rules/registry.js +76 -0
- package/dist/providers/rules/requestDefaults.d.ts +7 -0
- package/dist/providers/rules/requestDefaults.js +9 -0
- package/dist/providers/rules/requestFields.d.ts +21 -0
- package/dist/providers/rules/requestFields.js +42 -0
- package/dist/providers/rules/sagemaker.json +88 -0
- package/dist/providers/rules/schema.d.ts +242 -0
- package/dist/providers/rules/schema.js +359 -0
- package/dist/providers/rules/structured-output.json +36 -0
- package/dist/providers/rules/thinkingLimits.d.ts +7 -0
- package/dist/providers/rules/thinkingLimits.js +9 -0
- package/dist/providers/rules/toolRules.d.ts +16 -0
- package/dist/providers/rules/toolRules.js +95 -0
- package/dist/providers/rules/usage.json +51 -0
- package/dist/providers/rules/vertex.json +65 -0
- package/dist/providers/rules/vision.json +505 -0
- package/dist/providers/rules/wireUsage.d.ts +38 -0
- package/dist/providers/rules/wireUsage.js +82 -0
- package/dist/providers/sagemaker/language-model.js +6 -33
- package/dist/providers/sagemaker/parsers.js +13 -48
- package/dist/providers/sagemaker/streaming.js +9 -16
- package/dist/proxy/claudeFormat.js +3 -16
- package/dist/proxy/geminiFormat.js +3 -9
- package/dist/proxy/openaiFormat.js +3 -16
- package/dist/types/generate.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/providerRules.d.ts +414 -0
- package/dist/types/providerRules.js +10 -0
- package/dist/utils/errorClassifier.d.ts +2 -2
- package/dist/utils/errorClassifier.js +3 -2
- package/dist/utils/modelDetection.d.ts +1 -1
- package/dist/utils/modelDetection.js +30 -71
- package/dist/utils/providerConfig.d.ts +10 -9
- package/dist/utils/providerConfig.js +26 -25
- package/dist/utils/providerHealth.js +1 -0
- package/dist/utils/thinkingConfig.d.ts +1 -1
- package/dist/utils/thinkingConfig.js +8 -8
- package/dist/utils/tokenUtils.d.ts +12 -38
- package/dist/utils/tokenUtils.js +44 -127
- package/docs-site/static/search-index.json +5 -5
- package/package.json +2 -1
- package/dist/providers/localRuntimeOpenAICompat.d.ts +0 -16
- package/dist/providers/localRuntimeOpenAICompat.js +0 -26
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AIProviderName } from "../constants/enums.js";
|
|
2
|
-
import { GoogleAIModels, OpenAIModels, AnthropicModels, VertexModels,
|
|
2
|
+
import { GoogleAIModels, OpenAIModels, AnthropicModels, VertexModels, LiteLLMModels, NvidiaNimModels, OpenRouterModels, CohereModels, VoyageModels, TypeSafeModels, PerplexityDeciderModels, CloudflareClefModels, JinaModels, StabilityModels, IdeogramModels, RecraftModels, ReplicateModels, } from "../constants/enums.js";
|
|
3
3
|
import { API_KEY_FORMATS } from "../utils/providerConfig.js";
|
|
4
|
+
import { getDefaultModel } from "../providers/rules/fallbackModel.js";
|
|
4
5
|
import { getCatalogJsonEntries, getDecideCatalogEntries, catalogCredentialsKey, catalogEnvVar, } from "../providers/catalog/loader.js";
|
|
5
6
|
import { DEFAULT_INFERENCE_KINDS } from "../types/index.js";
|
|
6
7
|
/**
|
|
@@ -206,7 +207,7 @@ const HAND_DESCRIPTORS = [
|
|
|
206
207
|
model: "OLLAMA_MODEL",
|
|
207
208
|
optional: true,
|
|
208
209
|
},
|
|
209
|
-
defaultModel:
|
|
210
|
+
defaultModel: getDefaultModel("ollama"),
|
|
210
211
|
toolSupport: "model-dependent",
|
|
211
212
|
localRuntime: true,
|
|
212
213
|
healthCheck: "models-probe",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ProviderFactory } from "./providerFactory.js";
|
|
2
2
|
import { logger } from "../utils/logger.js";
|
|
3
|
-
import { AIProviderName, GoogleAIModels, OpenAIModels, AnthropicModels, VertexModels,
|
|
3
|
+
import { AIProviderName, GoogleAIModels, OpenAIModels, AnthropicModels, VertexModels, LiteLLMModels, NvidiaNimModels, OpenRouterModels, CohereModels, VoyageModels, JinaModels, StabilityModels, IdeogramModels, RecraftModels, TypeSafeModels, PerplexityDeciderModels, CloudflareClefModels, ReplicateModels, } from "../constants/enums.js";
|
|
4
4
|
import { PROVIDER_DESCRIPTORS_BY_NAME } from "./providerDescriptors.js";
|
|
5
|
+
import { getDefaultModel } from "../providers/rules/fallbackModel.js";
|
|
5
6
|
import { OPENAI_COMPAT_CATALOG } from "../providers/openaiCompatCatalog.js";
|
|
6
7
|
import { providerChoicesFor } from "./mediaHandlerCatalog.js";
|
|
7
8
|
import { catalogEnvVar, getDecideCatalogEntries, } from "../providers/catalog/loader.js";
|
|
@@ -143,7 +144,7 @@ export class ProviderRegistry {
|
|
|
143
144
|
const ollamaCreds = credentials;
|
|
144
145
|
const { OllamaProvider } = await import("../providers/ollama/index.js");
|
|
145
146
|
return new OllamaProvider(modelName, sdk, undefined, ollamaCreds);
|
|
146
|
-
}, process.env.OLLAMA_MODEL ||
|
|
147
|
+
}, process.env.OLLAMA_MODEL || getDefaultModel("ollama"), ["ollama", "local"], PROVIDER_DESCRIPTORS_BY_NAME.get(AIProviderName.OLLAMA));
|
|
147
148
|
// Register LiteLLM provider
|
|
148
149
|
ProviderFactory.registerProvider(AIProviderName.LITELLM, async (modelName, _providerName, sdk, _region, credentials) => {
|
|
149
150
|
const litellmCreds = credentials;
|
|
@@ -2,7 +2,7 @@ import type { ProviderModelManifest } from "../../types/index.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Anthropic model manifest. Canonical ids match AnthropicModels
|
|
4
4
|
* (src/lib/constants/enums.ts:524+) and MODEL_CONTEXT_WINDOWS.anthropic
|
|
5
|
-
* (src/lib/
|
|
5
|
+
* (src/lib/providers/rules/limits.json). maxOutputTokens values
|
|
6
6
|
* come from getClaudeMaxOutputTokens (src/lib/utils/tokenLimits.ts) — the
|
|
7
7
|
* regex ladder already authoritative for native Claude request paths.
|
|
8
8
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Anthropic model manifest. Canonical ids match AnthropicModels
|
|
3
3
|
* (src/lib/constants/enums.ts:524+) and MODEL_CONTEXT_WINDOWS.anthropic
|
|
4
|
-
* (src/lib/
|
|
4
|
+
* (src/lib/providers/rules/limits.json). maxOutputTokens values
|
|
5
5
|
* come from getClaudeMaxOutputTokens (src/lib/utils/tokenLimits.ts) — the
|
|
6
6
|
* regex ladder already authoritative for native Claude request paths.
|
|
7
7
|
*/
|
|
@@ -4,8 +4,8 @@ export const azureManifest = {
|
|
|
4
4
|
"gpt-5.1": {
|
|
5
5
|
aliases: ["azure-gpt-5.1", "gpt51-azure", "azure-flagship"],
|
|
6
6
|
displayName: "GPT-5.1 (Azure)",
|
|
7
|
-
contextWindow:
|
|
8
|
-
maxOutputTokens:
|
|
7
|
+
contextWindow: 400000,
|
|
8
|
+
maxOutputTokens: 128000,
|
|
9
9
|
pricingPerMTok: { input: 0.625, output: 5 },
|
|
10
10
|
vision: true,
|
|
11
11
|
functionCalling: true,
|
|
@@ -15,8 +15,8 @@ export const azureManifest = {
|
|
|
15
15
|
"gpt-5.1-chat": {
|
|
16
16
|
aliases: ["azure-gpt-5.1-chat", "gpt51-chat-azure"],
|
|
17
17
|
displayName: "GPT-5.1 Chat (Azure)",
|
|
18
|
-
contextWindow:
|
|
19
|
-
maxOutputTokens:
|
|
18
|
+
contextWindow: 128000,
|
|
19
|
+
maxOutputTokens: 16384,
|
|
20
20
|
pricingPerMTok: { input: 0.625, output: 5 },
|
|
21
21
|
vision: true,
|
|
22
22
|
functionCalling: true,
|
|
@@ -26,8 +26,8 @@ export const azureManifest = {
|
|
|
26
26
|
"gpt-5.1-codex": {
|
|
27
27
|
aliases: ["azure-gpt-5.1-codex", "gpt51-codex-azure", "azure-code"],
|
|
28
28
|
displayName: "GPT-5.1 Codex (Azure)",
|
|
29
|
-
contextWindow:
|
|
30
|
-
maxOutputTokens:
|
|
29
|
+
contextWindow: 400000,
|
|
30
|
+
maxOutputTokens: 128000,
|
|
31
31
|
pricingPerMTok: { input: 1.25, output: 10 },
|
|
32
32
|
vision: true,
|
|
33
33
|
functionCalling: true,
|
|
@@ -37,8 +37,8 @@ export const azureManifest = {
|
|
|
37
37
|
"gpt-5.1-codex-mini": {
|
|
38
38
|
aliases: ["azure-gpt-5.1-codex-mini", "gpt51-codex-mini-azure"],
|
|
39
39
|
displayName: "GPT-5.1 Codex Mini (Azure)",
|
|
40
|
-
contextWindow:
|
|
41
|
-
maxOutputTokens:
|
|
40
|
+
contextWindow: 400000,
|
|
41
|
+
maxOutputTokens: 128000,
|
|
42
42
|
pricingPerMTok: { input: 1.25, output: 10 },
|
|
43
43
|
vision: true,
|
|
44
44
|
functionCalling: true,
|
|
@@ -52,7 +52,7 @@ export const azureManifest = {
|
|
|
52
52
|
"azure-enterprise",
|
|
53
53
|
],
|
|
54
54
|
displayName: "GPT-5.1 Codex Max (Azure)",
|
|
55
|
-
contextWindow:
|
|
55
|
+
contextWindow: 400000,
|
|
56
56
|
maxOutputTokens: 128000,
|
|
57
57
|
pricingPerMTok: { input: 1.25, output: 10 },
|
|
58
58
|
vision: true,
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
export const ollamaManifest = {
|
|
2
2
|
defaultContextWindow: 128000,
|
|
3
3
|
models: {
|
|
4
|
+
"gemma4:e2b": {
|
|
5
|
+
aliases: ["gemma4", "gemma4-local"],
|
|
6
|
+
displayName: "Gemma 4 E2B",
|
|
7
|
+
// ollama.com/library/gemma4: 128K context; tools, vision and thinking.
|
|
8
|
+
contextWindow: 131072,
|
|
9
|
+
// Ollama publishes no output cap; this matches its default in tokens.ts.
|
|
10
|
+
maxOutputTokens: 8192,
|
|
11
|
+
// pricingPerMTok omitted: hasPricing() reports no verified rate
|
|
12
|
+
vision: true,
|
|
13
|
+
functionCalling: true,
|
|
14
|
+
reasoning: true,
|
|
15
|
+
jsonMode: true,
|
|
16
|
+
},
|
|
4
17
|
"llama4:latest": {
|
|
5
18
|
aliases: ["llama4", "llama4-local"],
|
|
6
19
|
displayName: "Llama 4",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ProviderModelManifest } from "../../types/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* OpenAI model manifest. contextWindow values come from
|
|
4
|
-
* MODEL_CONTEXT_WINDOWS.openai (src/lib/
|
|
4
|
+
* MODEL_CONTEXT_WINDOWS.openai (src/lib/providers/rules/limits.json), which
|
|
5
5
|
* disagrees with MODEL_REGISTRY.limits.maxContextTokens for several ids
|
|
6
6
|
* (e.g. gpt-5: 400_000 here vs 256_000 there) — MODEL_CONTEXT_WINDOWS wins
|
|
7
7
|
* as the more actively-maintained store. maxOutputTokens/aliases/capability
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* OpenAI model manifest. contextWindow values come from
|
|
3
|
-
* MODEL_CONTEXT_WINDOWS.openai (src/lib/
|
|
3
|
+
* MODEL_CONTEXT_WINDOWS.openai (src/lib/providers/rules/limits.json), which
|
|
4
4
|
* disagrees with MODEL_REGISTRY.limits.maxContextTokens for several ids
|
|
5
5
|
* (e.g. gpt-5: 400_000 here vs 256_000 there) — MODEL_CONTEXT_WINDOWS wins
|
|
6
6
|
* as the more actively-maintained store. maxOutputTokens/aliases/capability
|
|
@@ -7,6 +7,7 @@ import { DEFAULT_MODEL_ALIASES } from "../types/index.js";
|
|
|
7
7
|
import { logger } from "../utils/logger.js";
|
|
8
8
|
import { AIProviderName, OpenAIModels, AzureOpenAIModels, GoogleAIModels, AnthropicModels, BedrockModels, MistralModels, OllamaModels, } from "../constants/enums.js";
|
|
9
9
|
import { getAllManifestProviders, getManifestForProvider, } from "./manifestRegistry.js";
|
|
10
|
+
import { getModelFamilyPatterns } from "../providers/rules/modelFamilies.js";
|
|
10
11
|
/**
|
|
11
12
|
* Comprehensive model registry — hand-authored base. Every id defined here
|
|
12
13
|
* that the manifest doesn't also carry a priced entry for stays exactly as
|
|
@@ -2205,8 +2206,8 @@ const LEGACY_MODEL_REGISTRY = {
|
|
|
2205
2206
|
accuracy: "high",
|
|
2206
2207
|
},
|
|
2207
2208
|
limits: {
|
|
2208
|
-
maxContextTokens:
|
|
2209
|
-
maxOutputTokens:
|
|
2209
|
+
maxContextTokens: 400000,
|
|
2210
|
+
maxOutputTokens: 128000,
|
|
2210
2211
|
maxRequestsPerMinute: 100,
|
|
2211
2212
|
},
|
|
2212
2213
|
useCases: {
|
|
@@ -2249,8 +2250,8 @@ const LEGACY_MODEL_REGISTRY = {
|
|
|
2249
2250
|
accuracy: "high",
|
|
2250
2251
|
},
|
|
2251
2252
|
limits: {
|
|
2252
|
-
maxContextTokens:
|
|
2253
|
-
maxOutputTokens:
|
|
2253
|
+
maxContextTokens: 128000,
|
|
2254
|
+
maxOutputTokens: 16384,
|
|
2254
2255
|
maxRequestsPerMinute: 150,
|
|
2255
2256
|
},
|
|
2256
2257
|
useCases: {
|
|
@@ -2293,8 +2294,8 @@ const LEGACY_MODEL_REGISTRY = {
|
|
|
2293
2294
|
accuracy: "high",
|
|
2294
2295
|
},
|
|
2295
2296
|
limits: {
|
|
2296
|
-
maxContextTokens:
|
|
2297
|
-
maxOutputTokens:
|
|
2297
|
+
maxContextTokens: 400000,
|
|
2298
|
+
maxOutputTokens: 128000,
|
|
2298
2299
|
maxRequestsPerMinute: 100,
|
|
2299
2300
|
},
|
|
2300
2301
|
useCases: {
|
|
@@ -2337,8 +2338,8 @@ const LEGACY_MODEL_REGISTRY = {
|
|
|
2337
2338
|
accuracy: "high",
|
|
2338
2339
|
},
|
|
2339
2340
|
limits: {
|
|
2340
|
-
maxContextTokens:
|
|
2341
|
-
maxOutputTokens:
|
|
2341
|
+
maxContextTokens: 400000,
|
|
2342
|
+
maxOutputTokens: 128000,
|
|
2342
2343
|
maxRequestsPerMinute: 300,
|
|
2343
2344
|
},
|
|
2344
2345
|
useCases: {
|
|
@@ -2381,7 +2382,7 @@ const LEGACY_MODEL_REGISTRY = {
|
|
|
2381
2382
|
accuracy: "high",
|
|
2382
2383
|
},
|
|
2383
2384
|
limits: {
|
|
2384
|
-
maxContextTokens:
|
|
2385
|
+
maxContextTokens: 400000,
|
|
2385
2386
|
maxOutputTokens: 128000,
|
|
2386
2387
|
maxRequestsPerMinute: 50,
|
|
2387
2388
|
},
|
|
@@ -2788,20 +2789,11 @@ export function modelSupports(capability, provider, model) {
|
|
|
2788
2789
|
return modelInfo.capabilities[capability] ?? true;
|
|
2789
2790
|
}
|
|
2790
2791
|
/**
|
|
2791
|
-
* Model families
|
|
2792
|
-
*
|
|
2793
|
-
* Claude Sonnet 5, Opus 4.7+ (including Opus 5), and the Fable/Mythos 5
|
|
2794
|
-
* tier — notably as served through Vertex. Kept as patterns because gateway
|
|
2795
|
-
* model ids carry arbitrary prefixes/suffixes
|
|
2796
|
-
* (`vertex_ai/claude-sonnet-5@20260203`) that exact registry ids can't cover.
|
|
2792
|
+
* Model families that reject classic sampling parameters (`temperature` /
|
|
2793
|
+
* `topP`) in favour of reasoning-effort controls (model-families.json).
|
|
2797
2794
|
*/
|
|
2798
|
-
const
|
|
2799
|
-
|
|
2800
|
-
/opus[-_.]?4[-_.]?(?:[7-9]|\d{2,})(?![0-9])/i,
|
|
2801
|
-
/opus[-_.]?5(?![0-9])/i,
|
|
2802
|
-
/fable/i,
|
|
2803
|
-
/mythos/i,
|
|
2804
|
-
];
|
|
2795
|
+
const SAMPLING_EXCLUSIVE_FAMILIES = getModelFamilyPatterns("samplingExclusive");
|
|
2796
|
+
const SAMPLING_PARAM_REJECTING_FAMILIES = getModelFamilyPatterns("samplingParamsRejected");
|
|
2805
2797
|
/**
|
|
2806
2798
|
* Whether a model accepts classic sampling parameters
|
|
2807
2799
|
* (`temperature` / `topP`).
|
|
@@ -2833,6 +2825,13 @@ export function modelSupportsSamplingParams(provider, model) {
|
|
|
2833
2825
|
*/
|
|
2834
2826
|
export function resolveSamplingParams(provider, model, params, site) {
|
|
2835
2827
|
if (modelSupportsSamplingParams(provider, model)) {
|
|
2828
|
+
const normalizedModel = (model ?? "").toLowerCase();
|
|
2829
|
+
if (params.temperature !== undefined &&
|
|
2830
|
+
params.topP !== undefined &&
|
|
2831
|
+
SAMPLING_EXCLUSIVE_FAMILIES.some((family) => family.test(normalizedModel))) {
|
|
2832
|
+
logger.debug(`[ModelRegistry] Dropping topP for ${provider}/${model} at ${site} — the model rejects temperature and top_p together; temperature is kept`, { provider, model, site });
|
|
2833
|
+
return { temperature: params.temperature };
|
|
2834
|
+
}
|
|
2836
2835
|
return params;
|
|
2837
2836
|
}
|
|
2838
2837
|
if (params.temperature !== undefined || params.topP !== undefined) {
|
|
@@ -2846,26 +2845,10 @@ export function resolveSamplingParams(provider, model, params, site) {
|
|
|
2846
2845
|
}
|
|
2847
2846
|
return {};
|
|
2848
2847
|
}
|
|
2849
|
-
/**
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
* the same, and Mythos 5.1 shares Fable 5.1's capabilities. The same families
|
|
2854
|
-
* also refuse `thinking: {type: "disabled"}`.
|
|
2855
|
-
*/
|
|
2856
|
-
const FORCED_TOOL_CHOICE_REJECTING_FAMILIES = [
|
|
2857
|
-
/sonnet[-_.]?5[-_.]5(?![0-9])/i,
|
|
2858
|
-
/opus[-_.]?5[-_.]5(?![0-9])/i,
|
|
2859
|
-
/(?:fable|mythos)[-_.]?5[-_.]1(?![0-9])/i,
|
|
2860
|
-
];
|
|
2861
|
-
/**
|
|
2862
|
-
* Of those, the ones that accept `thinking: {type: "between_tools"}` as their
|
|
2863
|
-
* lowest setting. The rest think adaptively, always on, and take no
|
|
2864
|
-
* `thinking` field in its place.
|
|
2865
|
-
*/
|
|
2866
|
-
const BETWEEN_TOOLS_THINKING_FAMILIES = [
|
|
2867
|
-
/sonnet[-_.]?5[-_.]5(?![0-9])/i,
|
|
2868
|
-
];
|
|
2848
|
+
/** Claude models that answer a forced `tool_choice` with a 400 (model-families.json). */
|
|
2849
|
+
const FORCED_TOOL_CHOICE_REJECTING_FAMILIES = getModelFamilyPatterns("forcedToolChoiceRejected");
|
|
2850
|
+
/** Of those, the ones whose lowest thinking setting is `between_tools`. */
|
|
2851
|
+
const BETWEEN_TOOLS_THINKING_FAMILIES = getModelFamilyPatterns("betweenToolsThinking");
|
|
2869
2852
|
function matchesClaudeFamily(families, model) {
|
|
2870
2853
|
const normalizedModel = (model ?? "").toLowerCase();
|
|
2871
2854
|
if (!normalizedModel) {
|
package/dist/neurolink.js
CHANGED
|
@@ -4884,6 +4884,7 @@ Current user's request: ${currentInput}`;
|
|
|
4884
4884
|
// dropped on every generate() call regardless of provider, while
|
|
4885
4885
|
// stream() (which spreads its options) already forwarded it.
|
|
4886
4886
|
topP: options.topP,
|
|
4887
|
+
stopSequences: options.stopSequences,
|
|
4887
4888
|
maxTokens: options.maxTokens,
|
|
4888
4889
|
systemPrompt: options.systemPrompt,
|
|
4889
4890
|
schema: options.schema,
|
|
@@ -9,8 +9,7 @@ import { transformToolExecutions } from "../../utils/transformationUtils.js";
|
|
|
9
9
|
import { composeAbortSignals } from "../../utils/timeout.js";
|
|
10
10
|
import { createBedrockLoopAdapter } from "./loopAdapter.js";
|
|
11
11
|
import { bedrockChunksToV3Stream, bedrockConversationFromV3Prompt, bedrockV3StreamToChunks, buildV3PromptFromBedrock, isTextOnlyBedrockConversation, unsentBedrockMiddlewareOptions, unwrapBedrockToolInputSchema, } from "./modelBridge.js";
|
|
12
|
-
import {
|
|
13
|
-
import { classifyProviderError } from "../../utils/errorClassifier.js";
|
|
12
|
+
import { ProviderError } from "../../types/index.js";
|
|
14
13
|
import { isAbortError, withTimeout } from "../../utils/errorHandling.js";
|
|
15
14
|
import { abortSignalOf, pauseDeadlineOf } from "../../utils/async/index.js";
|
|
16
15
|
import { ImageProcessor } from "../../utils/imageProcessor.js";
|
|
@@ -22,6 +21,11 @@ import { convertZodToJsonSchema } from "../../utils/schemaConversion.js";
|
|
|
22
21
|
import { SpanKind, SpanStatusCode } from "@opentelemetry/api";
|
|
23
22
|
import { bedrockTracer } from "./constants.js";
|
|
24
23
|
import { loadBedrockControl } from "./utils.js";
|
|
24
|
+
import { classifyWithProviderRules } from "../rules/errorRules.js";
|
|
25
|
+
import { getProviderErrorRules } from "../rules/registry.js";
|
|
26
|
+
import { getRequestDefault } from "../rules/requestDefaults.js";
|
|
27
|
+
const BEDROCK_ERROR_RULES = getProviderErrorRules("bedrock");
|
|
28
|
+
const DEFAULT_TEMPERATURE = getRequestDefault("bedrock", "temperature");
|
|
25
29
|
/**
|
|
26
30
|
* The only image formats Nova Multimodal Embeddings accepts.
|
|
27
31
|
*
|
|
@@ -357,7 +361,7 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
357
361
|
const maxSteps = options.maxSteps || DEFAULT_MAX_STEPS;
|
|
358
362
|
const tools = await this.resolveTurnTools(options.tools, options.disableTools);
|
|
359
363
|
const toolConfig = this.formatToolsForBedrock(tools);
|
|
360
|
-
const sampling = resolveSamplingParams(this.providerName, this.modelName || this.getDefaultModel(), { temperature: options.temperature ??
|
|
364
|
+
const sampling = resolveSamplingParams(this.providerName, this.modelName || this.getDefaultModel(), { temperature: options.temperature ?? DEFAULT_TEMPERATURE }, "bedrock.converse");
|
|
361
365
|
const systemPromptText = options.systemPrompt ||
|
|
362
366
|
"You are a helpful assistant with access to external tools. Use tools when necessary to provide accurate information.";
|
|
363
367
|
// Builds a fresh adapter per turn — the generate model's `doGenerate` may
|
|
@@ -1211,7 +1215,7 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
1211
1215
|
// discovery, so nothing here would need re-resolving per step.
|
|
1212
1216
|
const tools = await this.resolveTurnTools(options.tools, options.disableTools);
|
|
1213
1217
|
const toolConfig = this.formatToolsForBedrock(tools);
|
|
1214
|
-
const sampling = resolveSamplingParams(this.providerName, this.modelName || this.getDefaultModel(), { temperature: options.temperature ??
|
|
1218
|
+
const sampling = resolveSamplingParams(this.providerName, this.modelName || this.getDefaultModel(), { temperature: options.temperature ?? DEFAULT_TEMPERATURE }, "bedrock.converseStream");
|
|
1215
1219
|
const systemPromptText = options.systemPrompt ||
|
|
1216
1220
|
"You are a helpful assistant with access to external tools. Use tools when necessary to provide accurate information.";
|
|
1217
1221
|
// executeStream() falls back to non-streaming generate() when the first
|
|
@@ -1488,39 +1492,7 @@ export class AmazonBedrockProvider extends BaseProvider {
|
|
|
1488
1492
|
}
|
|
1489
1493
|
}
|
|
1490
1494
|
formatProviderError(error) {
|
|
1491
|
-
|
|
1492
|
-
{
|
|
1493
|
-
match: (ctx) => /AccessDeniedException/i.test(ctx.message),
|
|
1494
|
-
errorClass: AuthenticationError,
|
|
1495
|
-
message: "AWS Bedrock access denied. Check your credentials and permissions.",
|
|
1496
|
-
},
|
|
1497
|
-
{
|
|
1498
|
-
// Checked before the generic ValidationException fallback — a
|
|
1499
|
-
// throttling error can be shaped like a validation error in some
|
|
1500
|
-
// AWS SDK error message templates, but .name/.code are authoritative.
|
|
1501
|
-
match: (ctx) => ctx.errorName === "ThrottlingException" ||
|
|
1502
|
-
ctx.errorCode === "ThrottlingException",
|
|
1503
|
-
errorClass: RateLimitError,
|
|
1504
|
-
message: (ctx) => `Bedrock rate limit (throttled): ${ctx.message}`,
|
|
1505
|
-
},
|
|
1506
|
-
{
|
|
1507
|
-
match: (ctx) => /ValidationException/i.test(ctx.message),
|
|
1508
|
-
errorClass: ProviderError,
|
|
1509
|
-
message: (ctx) => `Validation error: ${ctx.message}`,
|
|
1510
|
-
},
|
|
1511
|
-
{
|
|
1512
|
-
match: () => true,
|
|
1513
|
-
errorClass: ProviderError,
|
|
1514
|
-
message: (ctx) => `AWS Bedrock error: ${ctx.message}`,
|
|
1515
|
-
},
|
|
1516
|
-
];
|
|
1517
|
-
// this.providerName resolves to the literal "bedrock" (getProviderName()
|
|
1518
|
-
// returns it directly, and the constructor only overrides providerName
|
|
1519
|
-
// when an explicit providerName is passed in) — verified matches the
|
|
1520
|
-
// pre-migration hardcoded "bedrock" literal in the throttling branch, so
|
|
1521
|
-
// a single classifyProviderError call using this.providerName for every
|
|
1522
|
-
// rule (rather than a per-rule literal) is not a behavior change.
|
|
1523
|
-
return classifyProviderError(error, rules, this.providerName, this.modelName);
|
|
1495
|
+
return classifyWithProviderRules(error, BEDROCK_ERROR_RULES, this.providerName, this.modelName);
|
|
1524
1496
|
}
|
|
1525
1497
|
/**
|
|
1526
1498
|
* Generate embeddings for text or multi-modal input using Amazon Bedrock.
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
import { ConverseCommand, ConverseStreamCommand, } from "@aws-sdk/client-bedrock-runtime";
|
|
20
20
|
import { withTimeout } from "../../utils/errorHandling.js";
|
|
21
21
|
import { withInferenceProfileFallback } from "./inferenceProfile.js";
|
|
22
|
+
import { getFinishReasonMap, translateFinishReason, } from "../rules/finishReasons.js";
|
|
23
|
+
const BEDROCK_FINISH_REASONS = getFinishReasonMap("bedrock", "converse");
|
|
22
24
|
const STEP_TIMEOUT_MS = 120_000;
|
|
23
25
|
function newToolUseId() {
|
|
24
26
|
return `tool_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
|
|
@@ -286,17 +288,7 @@ export function createBedrockLoopAdapter(config) {
|
|
|
286
288
|
return [...conversation, assistantMessage, toolResultMessage];
|
|
287
289
|
},
|
|
288
290
|
mapFinishReason(rawStopReason, hadToolCallsAtCap) {
|
|
289
|
-
|
|
290
|
-
case "end_turn":
|
|
291
|
-
case "stop_sequence":
|
|
292
|
-
return "stop";
|
|
293
|
-
case "max_tokens":
|
|
294
|
-
return "length";
|
|
295
|
-
case "tool_use":
|
|
296
|
-
return "tool-calls";
|
|
297
|
-
default:
|
|
298
|
-
return hadToolCallsAtCap ? "tool-calls" : "stop";
|
|
299
|
-
}
|
|
291
|
+
return (translateFinishReason(BEDROCK_FINISH_REASONS, rawStopReason, hadToolCallsAtCap) ?? "stop");
|
|
300
292
|
},
|
|
301
293
|
};
|
|
302
294
|
}
|
|
@@ -244,6 +244,12 @@ export class AmazonSageMakerProvider extends BaseProvider {
|
|
|
244
244
|
...(options.temperature !== undefined
|
|
245
245
|
? { temperature: options.temperature }
|
|
246
246
|
: {}),
|
|
247
|
+
...(options.topP !== undefined && options.topP !== null
|
|
248
|
+
? { topP: options.topP }
|
|
249
|
+
: {}),
|
|
250
|
+
...(options.stopSequences && options.stopSequences.length > 0
|
|
251
|
+
? { stopSequences: options.stopSequences }
|
|
252
|
+
: {}),
|
|
247
253
|
...(options.abortSignal ? { abortSignal: options.abortSignal } : {}),
|
|
248
254
|
...(options.toolTimeoutMs !== undefined
|
|
249
255
|
? { toolTimeoutMs: options.toolTimeoutMs }
|