@juspay/neurolink 13.17.0 → 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 +3 -3
- package/dist/browser/neurolink.min.js +399 -399
- package/dist/core/nativeGenerateLoop.js +5 -0
- package/dist/models/modelRegistry.js +8 -0
- package/dist/neurolink.js +1 -0
- package/dist/providers/amazonSagemaker.js +6 -0
- package/dist/providers/anthropic/client.js +22 -10
- package/dist/providers/googleVertex/client.d.ts +7 -0
- package/dist/providers/googleVertex/client.js +35 -16
- package/dist/providers/openaiChatCompletionsBase.js +19 -4
- package/dist/providers/rules/anthropic.json +5 -1
- package/dist/providers/rules/model-families.json +8 -2
- package/dist/providers/rules/requestFields.d.ts +5 -2
- package/dist/providers/rules/requestFields.js +7 -3
- package/dist/providers/rules/schema.d.ts +8 -0
- package/dist/providers/rules/schema.js +7 -0
- package/dist/types/generate.d.ts +2 -0
- package/dist/types/providerRules.d.ts +7 -0
- package/package.json +1 -1
|
@@ -717,6 +717,7 @@ function generateObservedStep(args, request) {
|
|
|
717
717
|
modelParameters: {
|
|
718
718
|
temperature: args.temperature,
|
|
719
719
|
maxTokens: args.maxOutputTokens,
|
|
720
|
+
topP: args.topP,
|
|
720
721
|
},
|
|
721
722
|
input: { messages: args.conversation },
|
|
722
723
|
}, async (span) => {
|
|
@@ -845,6 +846,10 @@ async function runGenerateSteps(args, toolExecutionSummaries, stepSpans) {
|
|
|
845
846
|
...(args.temperature !== undefined
|
|
846
847
|
? { temperature: args.temperature }
|
|
847
848
|
: {}),
|
|
849
|
+
...(args.topP !== undefined ? { topP: args.topP } : {}),
|
|
850
|
+
...(args.stopSequences && args.stopSequences.length > 0
|
|
851
|
+
? { stopSequences: args.stopSequences }
|
|
852
|
+
: {}),
|
|
848
853
|
...(args.abortSignal ? { abortSignal: args.abortSignal } : {}),
|
|
849
854
|
});
|
|
850
855
|
let res;
|
|
@@ -2792,6 +2792,7 @@ export function modelSupports(capability, provider, model) {
|
|
|
2792
2792
|
* Model families that reject classic sampling parameters (`temperature` /
|
|
2793
2793
|
* `topP`) in favour of reasoning-effort controls (model-families.json).
|
|
2794
2794
|
*/
|
|
2795
|
+
const SAMPLING_EXCLUSIVE_FAMILIES = getModelFamilyPatterns("samplingExclusive");
|
|
2795
2796
|
const SAMPLING_PARAM_REJECTING_FAMILIES = getModelFamilyPatterns("samplingParamsRejected");
|
|
2796
2797
|
/**
|
|
2797
2798
|
* Whether a model accepts classic sampling parameters
|
|
@@ -2824,6 +2825,13 @@ export function modelSupportsSamplingParams(provider, model) {
|
|
|
2824
2825
|
*/
|
|
2825
2826
|
export function resolveSamplingParams(provider, model, params, site) {
|
|
2826
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
|
+
}
|
|
2827
2835
|
return params;
|
|
2828
2836
|
}
|
|
2829
2837
|
if (params.temperature !== undefined || params.topP !== undefined) {
|
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,
|
|
@@ -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 }
|
|
@@ -1398,10 +1398,10 @@ export class AnthropicProvider extends BaseProvider {
|
|
|
1398
1398
|
// let Anthropic's thinking defaults stand.
|
|
1399
1399
|
...toWireParams("anthropic", {
|
|
1400
1400
|
maxTokens,
|
|
1401
|
-
temperature:
|
|
1402
|
-
topP:
|
|
1401
|
+
temperature: samplingParams.temperature,
|
|
1402
|
+
topP: samplingParams.topP,
|
|
1403
1403
|
stopSequences: options.stopSequences,
|
|
1404
|
-
}),
|
|
1404
|
+
}, { thinkingOn }),
|
|
1405
1405
|
...(tools ? { tools } : {}),
|
|
1406
1406
|
...(toolChoice ? { tool_choice: toolChoice } : {}),
|
|
1407
1407
|
...(thinking ? { thinking } : {}),
|
|
@@ -1790,6 +1790,12 @@ export class AnthropicProvider extends BaseProvider {
|
|
|
1790
1790
|
...(options.temperature !== undefined
|
|
1791
1791
|
? { temperature: options.temperature }
|
|
1792
1792
|
: {}),
|
|
1793
|
+
...(options.topP !== undefined && options.topP !== null
|
|
1794
|
+
? { topP: options.topP }
|
|
1795
|
+
: {}),
|
|
1796
|
+
...(options.stopSequences && options.stopSequences.length > 0
|
|
1797
|
+
? { stopSequences: options.stopSequences }
|
|
1798
|
+
: {}),
|
|
1793
1799
|
...(options.abortSignal ? { abortSignal: options.abortSignal } : {}),
|
|
1794
1800
|
...(options.toolTimeoutMs !== undefined
|
|
1795
1801
|
? { toolTimeoutMs: options.toolTimeoutMs }
|
|
@@ -2193,9 +2199,15 @@ export class AnthropicProvider extends BaseProvider {
|
|
|
2193
2199
|
messages: conversation,
|
|
2194
2200
|
});
|
|
2195
2201
|
const cachedConversation = applyAnthropicHistoryCacheBreakpoints(conversation, ANTHROPIC_MAX_CACHE_BREAKPOINTS - cacheMarkersUsed);
|
|
2196
|
-
const streamSamplingParams = resolveSamplingParams("anthropic", modelId,
|
|
2197
|
-
|
|
2198
|
-
|
|
2202
|
+
const streamSamplingParams = resolveSamplingParams("anthropic", modelId, {
|
|
2203
|
+
...(options.temperature !== undefined &&
|
|
2204
|
+
options.temperature !== null
|
|
2205
|
+
? { temperature: options.temperature }
|
|
2206
|
+
: {}),
|
|
2207
|
+
...(options.topP !== undefined && options.topP !== null
|
|
2208
|
+
? { topP: options.topP }
|
|
2209
|
+
: {}),
|
|
2210
|
+
}, "anthropic.executeStream");
|
|
2199
2211
|
const maxTokens = resolveClaudeMaxTokens(modelId, options.maxTokens);
|
|
2200
2212
|
const thinking = fitThinkingToRequest(requestedThinking, anthropicToolChoice, maxTokens, conversation);
|
|
2201
2213
|
// See the generate path: `disabled` is sent, but only ON constrains sampling.
|
|
@@ -2215,10 +2227,10 @@ export class AnthropicProvider extends BaseProvider {
|
|
|
2215
2227
|
// `thinking` is rejected outright.
|
|
2216
2228
|
...toWireParams("anthropic", {
|
|
2217
2229
|
maxTokens,
|
|
2218
|
-
temperature:
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
}),
|
|
2230
|
+
temperature: streamSamplingParams.temperature,
|
|
2231
|
+
topP: streamSamplingParams.topP,
|
|
2232
|
+
stopSequences: options.stopSequences,
|
|
2233
|
+
}, { thinkingOn }),
|
|
2222
2234
|
...(cachedTools && cachedTools.length > 0
|
|
2223
2235
|
? { tools: cachedTools }
|
|
2224
2236
|
: {}),
|
|
@@ -270,6 +270,13 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
270
270
|
* tool use — it forces the opposite — so it is not gated here, consistent
|
|
271
271
|
* with oauthFetch.ts leaving `"none"` alone too.
|
|
272
272
|
*/
|
|
273
|
+
/**
|
|
274
|
+
* max_tokens, sampling and thinking for a forced finalization call, sized to
|
|
275
|
+
* its own token limit. Thinking is rebuilt for that limit, so the sampling
|
|
276
|
+
* the first request left out while thinking was on is sent again when
|
|
277
|
+
* thinking no longer fits.
|
|
278
|
+
*/
|
|
279
|
+
private buildClaudeFinalizationParams;
|
|
273
280
|
private buildClaudeThinkingParam;
|
|
274
281
|
private executeNativeAnthropicStream;
|
|
275
282
|
/**
|
|
@@ -3172,6 +3172,23 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
3172
3172
|
* tool use — it forces the opposite — so it is not gated here, consistent
|
|
3173
3173
|
* with oauthFetch.ts leaving `"none"` alone too.
|
|
3174
3174
|
*/
|
|
3175
|
+
/**
|
|
3176
|
+
* max_tokens, sampling and thinking for a forced finalization call, sized to
|
|
3177
|
+
* its own token limit. Thinking is rebuilt for that limit, so the sampling
|
|
3178
|
+
* the first request left out while thinking was on is sent again when
|
|
3179
|
+
* thinking no longer fits.
|
|
3180
|
+
*/
|
|
3181
|
+
buildClaudeFinalizationParams(options, maxTokens, forcesToolChoice, sampling) {
|
|
3182
|
+
const thinking = this.buildClaudeThinkingParam(options, maxTokens, forcesToolChoice);
|
|
3183
|
+
return {
|
|
3184
|
+
...toWireParams("anthropic", {
|
|
3185
|
+
maxTokens,
|
|
3186
|
+
temperature: sampling.temperature,
|
|
3187
|
+
topP: sampling.topP,
|
|
3188
|
+
}, { thinkingOn: thinking?.type === "enabled" }),
|
|
3189
|
+
thinking,
|
|
3190
|
+
};
|
|
3191
|
+
}
|
|
3175
3192
|
buildClaudeThinkingParam(
|
|
3176
3193
|
// Structural, not TextGenerationOptions: the streaming caller passes
|
|
3177
3194
|
// StreamOptions, and only these two fields are read.
|
|
@@ -3442,7 +3459,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
3442
3459
|
temperature: streamSampling.temperature,
|
|
3443
3460
|
topP: streamSampling.topP,
|
|
3444
3461
|
stopSequences: options.stopSequences,
|
|
3445
|
-
}),
|
|
3462
|
+
}, { thinkingOn: streamThinking?.type === "enabled" }),
|
|
3446
3463
|
};
|
|
3447
3464
|
// ── Real-time streaming via stream.on('text', ...) ────────────────────
|
|
3448
3465
|
//
|
|
@@ -3952,12 +3969,11 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
3952
3969
|
}, async () => {
|
|
3953
3970
|
const finalizationStream = await client.messages.stream({
|
|
3954
3971
|
...requestParams,
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
//
|
|
3959
|
-
|
|
3960
|
-
thinking: this.buildClaudeThinkingParam(options, terminalMaxTokens, forceFinalResult),
|
|
3972
|
+
// Resized, not inherited: terminalMaxTokens can sit below the budget
|
|
3973
|
+
// requestParams' thinking was sized for, and the sampling the first
|
|
3974
|
+
// request left out while thinking was on returns when thinking no
|
|
3975
|
+
// longer fits at this size.
|
|
3976
|
+
...this.buildClaudeFinalizationParams(options, terminalMaxTokens, forceFinalResult, streamSampling),
|
|
3961
3977
|
...(forceFinalResult && {
|
|
3962
3978
|
tool_choice: {
|
|
3963
3979
|
type: "tool",
|
|
@@ -4102,7 +4118,9 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
4102
4118
|
...requestParams,
|
|
4103
4119
|
...toWireParams("anthropic", {
|
|
4104
4120
|
maxTokens: terminalMaxTokens,
|
|
4105
|
-
|
|
4121
|
+
temperature: streamSampling.temperature,
|
|
4122
|
+
topP: streamSampling.topP,
|
|
4123
|
+
}, { thinkingOn: backstopThinking?.type === "enabled" }),
|
|
4106
4124
|
// Assigned outright, never a conditional spread: spreading
|
|
4107
4125
|
// requestParams above may already carry a `thinking` sized
|
|
4108
4126
|
// for the original max_tokens, and only adding a key when
|
|
@@ -4655,7 +4673,7 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
4655
4673
|
temperature: generateSampling.temperature,
|
|
4656
4674
|
topP: generateSampling.topP,
|
|
4657
4675
|
stopSequences: options.stopSequences,
|
|
4658
|
-
}),
|
|
4676
|
+
}, { thinkingOn: generateThinking?.type === "enabled" }),
|
|
4659
4677
|
};
|
|
4660
4678
|
// Handle tool calling loop with max steps
|
|
4661
4679
|
const maxSteps = options.maxSteps || DEFAULT_MAX_STEPS;
|
|
@@ -5061,12 +5079,11 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
5061
5079
|
messages: cachedFinal.messages,
|
|
5062
5080
|
}, () => withTimeout(client.messages.create({
|
|
5063
5081
|
...requestParams,
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
//
|
|
5068
|
-
|
|
5069
|
-
thinking: this.buildClaudeThinkingParam(options, terminalMaxTokens, forceFinalResult),
|
|
5082
|
+
// Resized, not inherited: terminalMaxTokens can sit below the budget
|
|
5083
|
+
// requestParams' thinking was sized for, and the sampling the first
|
|
5084
|
+
// request left out while thinking was on returns when thinking no
|
|
5085
|
+
// longer fits at this size.
|
|
5086
|
+
...this.buildClaudeFinalizationParams(options, terminalMaxTokens, forceFinalResult, generateSampling),
|
|
5070
5087
|
...(forceFinalResult && {
|
|
5071
5088
|
tool_choice: {
|
|
5072
5089
|
type: "tool",
|
|
@@ -5186,7 +5203,9 @@ export class GoogleVertexProvider extends BaseProvider {
|
|
|
5186
5203
|
...requestParams,
|
|
5187
5204
|
...toWireParams("anthropic", {
|
|
5188
5205
|
maxTokens: terminalMaxTokens,
|
|
5189
|
-
|
|
5206
|
+
temperature: generateSampling.temperature,
|
|
5207
|
+
topP: generateSampling.topP,
|
|
5208
|
+
}, { thinkingOn: backstopThinking?.type === "enabled" }),
|
|
5190
5209
|
// Assigned outright, never a conditional spread: spreading
|
|
5191
5210
|
// requestParams above may already carry a `thinking` sized
|
|
5192
5211
|
// for the original max_tokens, and only adding a key when
|
|
@@ -996,6 +996,12 @@ export class OpenAIChatCompletionsProvider extends BaseProvider {
|
|
|
996
996
|
...(options.temperature !== undefined
|
|
997
997
|
? { temperature: options.temperature }
|
|
998
998
|
: {}),
|
|
999
|
+
...(options.topP !== undefined && options.topP !== null
|
|
1000
|
+
? { topP: options.topP }
|
|
1001
|
+
: {}),
|
|
1002
|
+
...(options.stopSequences && options.stopSequences.length > 0
|
|
1003
|
+
? { stopSequences: options.stopSequences }
|
|
1004
|
+
: {}),
|
|
999
1005
|
...(options.abortSignal ? { abortSignal: options.abortSignal } : {}),
|
|
1000
1006
|
...(options.toolTimeoutMs !== undefined
|
|
1001
1007
|
? { toolTimeoutMs: options.toolTimeoutMs }
|
|
@@ -1650,10 +1656,11 @@ export class OpenAIChatCompletionsProvider extends BaseProvider {
|
|
|
1650
1656
|
// `transformParams` can rewrite the prompt before a byte is sent, and
|
|
1651
1657
|
// `wrapStream` can observe, filter, or replace the stream outright.
|
|
1652
1658
|
//
|
|
1653
|
-
// Honoured on the way back in: `prompt`, `maxOutputTokens`, `temperature
|
|
1654
|
-
// and `
|
|
1655
|
-
// gets a WARN rather than a silent drop,
|
|
1656
|
-
// list here would diverge from
|
|
1659
|
+
// Honoured on the way back in: `prompt`, `maxOutputTokens`, `temperature`,
|
|
1660
|
+
// `topP` and `stopSequences`. `tools` is offered read-only — a
|
|
1661
|
+
// middleware that rewrites it gets a WARN rather than a silent drop,
|
|
1662
|
+
// because re-deriving the wire tool list here would diverge from
|
|
1663
|
+
// `buildToolsForOpenAI`.
|
|
1657
1664
|
const v3Tools = openAITools?.map((t) => ({
|
|
1658
1665
|
type: "function",
|
|
1659
1666
|
name: t.function.name,
|
|
@@ -1670,6 +1677,9 @@ export class OpenAIChatCompletionsProvider extends BaseProvider {
|
|
|
1670
1677
|
? { temperature: options.temperature }
|
|
1671
1678
|
: {}),
|
|
1672
1679
|
...(options.topP !== undefined ? { topP: options.topP } : {}),
|
|
1680
|
+
...(options.stopSequences && options.stopSequences.length > 0
|
|
1681
|
+
? { stopSequences: options.stopSequences }
|
|
1682
|
+
: {}),
|
|
1673
1683
|
};
|
|
1674
1684
|
let loopPromise;
|
|
1675
1685
|
// The wire conversation only exists once `doStream` actually runs, and it
|
|
@@ -1717,6 +1727,11 @@ export class OpenAIChatCompletionsProvider extends BaseProvider {
|
|
|
1717
1727
|
? { temperature: params.temperature }
|
|
1718
1728
|
: {}),
|
|
1719
1729
|
...(typeof params?.topP === "number" ? { topP: params.topP } : {}),
|
|
1730
|
+
// An empty list is kept, so a middleware can clear the caller's stop
|
|
1731
|
+
// sequences as well as replace them.
|
|
1732
|
+
...(Array.isArray(params?.stopSequences)
|
|
1733
|
+
? { stopSequences: params.stopSequences }
|
|
1734
|
+
: {}),
|
|
1720
1735
|
};
|
|
1721
1736
|
loopPromise = this.runStreamLoop({
|
|
1722
1737
|
maxSteps,
|
|
@@ -92,7 +92,8 @@
|
|
|
92
92
|
"stopSequences": "stop_sequences"
|
|
93
93
|
},
|
|
94
94
|
"requestFieldNotes": {
|
|
95
|
-
"scope": "The Anthropic Messages wire, used by direct Anthropic and by Claude on Vertex. toWireParams() writes a request from neutral names; unset values and empty lists are left out."
|
|
95
|
+
"scope": "The Anthropic Messages wire, used by direct Anthropic and by Claude on Vertex. toWireParams() writes a request from neutral names; unset values and empty lists are left out.",
|
|
96
|
+
"omitWhileThinking": "Extended thinking fixes sampling: Anthropic rejects any temperature but 1 while thinking is on, and does not honour top_p there, so both are left out of a thinking request."
|
|
96
97
|
},
|
|
97
98
|
"toolResults": {
|
|
98
99
|
"errorTemplate": "Error executing tool {name}: {error}",
|
|
@@ -100,5 +101,8 @@
|
|
|
100
101
|
},
|
|
101
102
|
"contextTexts": {
|
|
102
103
|
"elisionNote": "[Earlier tool exchanges were removed to fit the context window.]"
|
|
104
|
+
},
|
|
105
|
+
"requestFieldRules": {
|
|
106
|
+
"omitWhileThinking": ["temperature", "topP"]
|
|
103
107
|
}
|
|
104
108
|
}
|
|
@@ -24,7 +24,12 @@
|
|
|
24
24
|
"thinkingConfig": ["^gemini-3", "^gemini-2\\.5-pro", "^gemini-2\\.5-flash"],
|
|
25
25
|
"promptCaching": ["^gemini-3", "^gemini-2\\.5", "^gpt-4", "^claude-3"],
|
|
26
26
|
"restrictedOutput": ["^gemini-3"],
|
|
27
|
-
"maxCompletionTokens": ["^(o\\d|gpt-5)"]
|
|
27
|
+
"maxCompletionTokens": ["^(o\\d|gpt-5)"],
|
|
28
|
+
"samplingExclusive": [
|
|
29
|
+
"opus[-_.]?4[-_.]?[1-6](?![0-9])",
|
|
30
|
+
"sonnet[-_.]?4[-_.]?[5-9](?![0-9])",
|
|
31
|
+
"haiku[-_.]?4[-_.]?[5-9](?![0-9])"
|
|
32
|
+
]
|
|
28
33
|
},
|
|
29
34
|
"modelFamilyNotes": {
|
|
30
35
|
"samplingParamsRejected": "Reject temperature/topP in favour of reasoning-effort controls: Claude Sonnet 5, Opus 4.7+ (including Opus 5) and the Fable/Mythos 5 tier, notably as served through Vertex. Patterns, because gateway ids carry arbitrary prefixes and suffixes (vertex_ai/claude-sonnet-5@20260203).",
|
|
@@ -34,7 +39,8 @@
|
|
|
34
39
|
"gemini3": "Gemini 3 and 3.x: thinking takes thinkingLevel.",
|
|
35
40
|
"gemini25": "Gemini 2.5: rejects thinkingLevel with 400 \"thinking_level not supported\"; takes thinkingBudget.",
|
|
36
41
|
"maxCompletionTokens": "Reasoning-class OpenAI models (o-series, gpt-5+) reject max_tokens and take max_completion_tokens. Matched against the id after its last '/'.",
|
|
37
|
-
"restrictedOutput": "Output capped at gemini.json reasoning.restrictedOutputTokenLimit, as are the imageGeneration models (matched as prefixes)."
|
|
42
|
+
"restrictedOutput": "Output capped at gemini.json reasoning.restrictedOutputTokenLimit, as are the imageGeneration models (matched as prefixes).",
|
|
43
|
+
"samplingExclusive": "Accept temperature or top_p but reject both in one request with a 400 (\"temperature and top_p cannot both be specified for this model\"): Claude Opus 4.1 to 4.6, Sonnet 4.5+ and Haiku 4.5+ (docs.claude.com, what's new in Claude Sonnet 4.5). When a caller sets both, temperature is kept. Opus 4.7+ and Sonnet 5 reject sampling entirely (samplingParamsRejected)."
|
|
38
44
|
},
|
|
39
45
|
"modelFamilyLabels": {
|
|
40
46
|
"rules": [
|
|
@@ -9,9 +9,12 @@ import type { ProviderContextTexts, ProviderRequestFields, ProviderToolResultRul
|
|
|
9
9
|
export declare function getRequestFields(id: string): ProviderRequestFields;
|
|
10
10
|
/**
|
|
11
11
|
* Request parameters under the provider's wire names. Unset values and empty
|
|
12
|
-
* lists are left out, as every request builder did by hand
|
|
12
|
+
* lists are left out, as every request builder did by hand, and so is any
|
|
13
|
+
* parameter the rules file omits while extended thinking is on.
|
|
13
14
|
*/
|
|
14
|
-
export declare function toWireParams(id: string, values: ProviderWireParamValues
|
|
15
|
+
export declare function toWireParams(id: string, values: ProviderWireParamValues, context?: {
|
|
16
|
+
thinkingOn?: boolean;
|
|
17
|
+
}): Record<string, unknown>;
|
|
15
18
|
/** How a failed tool call is reported back to the model. */
|
|
16
19
|
export declare function getToolResultRules(id: string): ProviderToolResultRules;
|
|
17
20
|
/** Fixed texts inserted into the conversation. */
|
|
@@ -11,14 +11,18 @@ export function getRequestFields(id) {
|
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Request parameters under the provider's wire names. Unset values and empty
|
|
14
|
-
* lists are left out, as every request builder did by hand
|
|
14
|
+
* lists are left out, as every request builder did by hand, and so is any
|
|
15
|
+
* parameter the rules file omits while extended thinking is on.
|
|
15
16
|
*/
|
|
16
|
-
export function toWireParams(id, values) {
|
|
17
|
+
export function toWireParams(id, values, context = {}) {
|
|
17
18
|
const names = getRequestFields(id);
|
|
19
|
+
const omitted = new Set(context.thinkingOn
|
|
20
|
+
? (getProviderRules(id).requestFieldRules?.omitWhileThinking ?? [])
|
|
21
|
+
: []);
|
|
18
22
|
const out = {};
|
|
19
23
|
for (const key of Object.keys(values)) {
|
|
20
24
|
const value = values[key];
|
|
21
|
-
if (value === undefined || value === null) {
|
|
25
|
+
if (value === undefined || value === null || omitted.has(key)) {
|
|
22
26
|
continue;
|
|
23
27
|
}
|
|
24
28
|
if (Array.isArray(value) && value.length === 0) {
|
|
@@ -213,6 +213,14 @@ export declare const providerRulesFileSchema: z.ZodObject<{
|
|
|
213
213
|
topP: z.ZodString;
|
|
214
214
|
stopSequences: z.ZodString;
|
|
215
215
|
}, z.core.$strict>>;
|
|
216
|
+
requestFieldRules: z.ZodOptional<z.ZodObject<{
|
|
217
|
+
omitWhileThinking: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
218
|
+
maxTokens: "maxTokens";
|
|
219
|
+
temperature: "temperature";
|
|
220
|
+
topP: "topP";
|
|
221
|
+
stopSequences: "stopSequences";
|
|
222
|
+
}>>>;
|
|
223
|
+
}, z.core.$strict>>;
|
|
216
224
|
requestFieldNotes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
217
225
|
toolResults: z.ZodOptional<z.ZodObject<{
|
|
218
226
|
errorTemplate: z.ZodString;
|
|
@@ -327,6 +327,13 @@ export const providerRulesFileSchema = z.strictObject({
|
|
|
327
327
|
stopSequences: z.string().min(1),
|
|
328
328
|
})
|
|
329
329
|
.optional(),
|
|
330
|
+
requestFieldRules: z
|
|
331
|
+
.strictObject({
|
|
332
|
+
omitWhileThinking: z
|
|
333
|
+
.array(z.enum(["maxTokens", "temperature", "topP", "stopSequences"]))
|
|
334
|
+
.optional(),
|
|
335
|
+
})
|
|
336
|
+
.optional(),
|
|
330
337
|
requestFieldNotes: z.record(z.string().min(1), z.string().min(1)).optional(),
|
|
331
338
|
toolResults: z
|
|
332
339
|
.strictObject({
|
package/dist/types/generate.d.ts
CHANGED
|
@@ -1890,6 +1890,8 @@ export type NativeGenerateLoopArgs = {
|
|
|
1890
1890
|
maxSteps: number;
|
|
1891
1891
|
maxOutputTokens?: number;
|
|
1892
1892
|
temperature?: number;
|
|
1893
|
+
topP?: number;
|
|
1894
|
+
stopSequences?: string[];
|
|
1893
1895
|
abortSignal?: AbortSignal;
|
|
1894
1896
|
/** Per-tool-execution cap, forwarded into `guardToolExecutor`. `null` for no bound. */
|
|
1895
1897
|
toolTimeoutMs?: number | null;
|
|
@@ -171,6 +171,8 @@ export type ProviderRulesFile = {
|
|
|
171
171
|
requestDefaultNotes?: Record<string, string>;
|
|
172
172
|
/** Wire names of request parameters, by neutral name. */
|
|
173
173
|
requestFields?: ProviderRequestFields;
|
|
174
|
+
/** Conditions under which a request parameter is left out. */
|
|
175
|
+
requestFieldRules?: ProviderRequestFieldRules;
|
|
174
176
|
/** Why the request field names read as they do. */
|
|
175
177
|
requestFieldNotes?: Record<string, string>;
|
|
176
178
|
/** How a failed tool call is reported back to the model. */
|
|
@@ -189,6 +191,11 @@ export type ProviderRequestFields = {
|
|
|
189
191
|
topP: string;
|
|
190
192
|
stopSequences: string;
|
|
191
193
|
};
|
|
194
|
+
/** Conditions under which a request parameter is left out. */
|
|
195
|
+
export type ProviderRequestFieldRules = {
|
|
196
|
+
/** Neutral names left out while extended thinking is on. */
|
|
197
|
+
omitWhileThinking?: Array<keyof ProviderWireParamValues>;
|
|
198
|
+
};
|
|
192
199
|
/** Neutral request parameter values for `toWireParams`. */
|
|
193
200
|
export type ProviderWireParamValues = {
|
|
194
201
|
maxTokens?: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "13.17.
|
|
3
|
+
"version": "13.17.1",
|
|
4
4
|
"packageManager": "pnpm@10.34.9+sha512.f49b5a8ea0fdedb44bb3c0c1d6575092a53c2950d95b7ad15df11f17974877a2de3a01c07e934e9b28ce716e51c09a94962c7306d09be2e1e4b18a8c8762fd32",
|
|
5
5
|
"description": "The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002/call) for routing, tool selection and context budgeting. MCP-native (4 transports), voice TTS/STT/realtime, RAG, agents, memory, compaction, 9 observability exporters. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · TypeSafe Jev and more.",
|
|
6
6
|
"author": {
|