@bivelio/savings-layer 0.4.30 → 0.4.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +171 -8
- package/dist/adapters/anthropic-sdk.js +75 -69
- package/dist/gateway/bin.js +893 -719
- package/dist/index.d.ts +193 -22
- package/dist/index.js +1597 -1363
- package/package.json +6 -2
package/dist/index.d.ts
CHANGED
|
@@ -325,7 +325,7 @@ declare function precioDeLista(model: string, at?: Date | number): CostModel | u
|
|
|
325
325
|
* on the customer's machine. `test/version-declarada.test.ts` ties this
|
|
326
326
|
* constant to package.json so the two can never drift.
|
|
327
327
|
*/
|
|
328
|
-
declare const BV_SALA_VERSION = "0.4.
|
|
328
|
+
declare const BV_SALA_VERSION = "0.4.32";
|
|
329
329
|
|
|
330
330
|
/**
|
|
331
331
|
* Environment-agnostic UUID generation.
|
|
@@ -546,7 +546,11 @@ interface OutputContract {
|
|
|
546
546
|
/** Stable identifier, e.g. "research-answer:v3". */
|
|
547
547
|
contractId: string;
|
|
548
548
|
schema: JsonSchema;
|
|
549
|
-
/**
|
|
549
|
+
/**
|
|
550
|
+
* Hard ceiling on generated tokens for this contract. A free-text request (no
|
|
551
|
+
* schema) sets its ceiling with {@link SavingsRequest.maxOutputTokens}; when
|
|
552
|
+
* both are set, the smaller one is sent.
|
|
553
|
+
*/
|
|
550
554
|
maxOutputTokens?: number;
|
|
551
555
|
/** Version marker included in the exact-cache key. */
|
|
552
556
|
version?: string;
|
|
@@ -1103,17 +1107,58 @@ interface SavingsRequest {
|
|
|
1103
1107
|
/** Sampling controls that participate in the exact-cache key. */
|
|
1104
1108
|
temperature?: number;
|
|
1105
1109
|
seed?: number;
|
|
1110
|
+
/**
|
|
1111
|
+
* How hard a reasoning model should think, sent as OpenAI's `reasoning_effort`
|
|
1112
|
+
* by the OpenAI-compatible adapter (`"none"`, `"minimal"`, `"low"`,
|
|
1113
|
+
* `"medium"`, `"high"`, `"xhigh"`; the value travels as written). Nothing is
|
|
1114
|
+
* sent when absent: the layer never picks an effort for you.
|
|
1115
|
+
*
|
|
1116
|
+
* Required for the gpt-5.6 family with tools on Chat Completions: OpenAI
|
|
1117
|
+
* rejects function tools there unless it is `"none"` («Function tools with
|
|
1118
|
+
* reasoning_effort are not supported for gpt-5.6-sol in
|
|
1119
|
+
* /v1/chat/completions … set reasoning_effort to 'none'»). Gemini's
|
|
1120
|
+
* OpenAI-compatible endpoint maps it to its thinking level. A compatible
|
|
1121
|
+
* endpoint that rejects the field by name gets the request once more without
|
|
1122
|
+
* it (OpenAI's own API never: there its 400 is the answer). It is part of the
|
|
1123
|
+
* cache identity, like `temperature` and `seed`. The Anthropic adapter
|
|
1124
|
+
* ignores it.
|
|
1125
|
+
*/
|
|
1126
|
+
reasoningEffort?: ReasoningEffort;
|
|
1127
|
+
/**
|
|
1128
|
+
* Hard ceiling on generated tokens for this request, with or without an
|
|
1129
|
+
* output contract. It travels to every adapter: Anthropic `max_tokens`,
|
|
1130
|
+
* Chat Completions `max_completion_tokens` on OpenAI's own API and
|
|
1131
|
+
* `max_tokens` on any other OpenAI-compatible endpoint (see
|
|
1132
|
+
* `OpenAICompatibleOptions.maxTokensParam`). When `response.maxOutputTokens`
|
|
1133
|
+
* is also set, the smaller of the two is sent. Unset, nothing changes.
|
|
1134
|
+
*
|
|
1135
|
+
* It is a limit you set, not a saving: it never raises the estimated output
|
|
1136
|
+
* of an avoided call and is never credited as output avoided. An answer cut
|
|
1137
|
+
* by it (`finishReason: "length"`) is not cached. Must be a positive integer.
|
|
1138
|
+
*/
|
|
1139
|
+
maxOutputTokens?: number;
|
|
1106
1140
|
/** Tokenizer id to cost against; defaults to a model-derived estimate. */
|
|
1107
1141
|
tokenizer?: string;
|
|
1108
1142
|
/** Arbitrary structured payload to be serialized into the prompt. */
|
|
1109
1143
|
structuredData?: unknown;
|
|
1110
1144
|
}
|
|
1111
1145
|
/** A tool invocation the model requested (the provider-neutral shape). */
|
|
1146
|
+
/** OpenAI's `reasoning_effort` values; any other string travels as written. */
|
|
1147
|
+
type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | (string & {});
|
|
1112
1148
|
interface ToolCallRequest {
|
|
1113
1149
|
id?: string;
|
|
1114
1150
|
name: string;
|
|
1115
1151
|
/** Argumentos tal cual los serializó el modelo (JSON en crudo). */
|
|
1116
1152
|
arguments: string;
|
|
1153
|
+
/**
|
|
1154
|
+
* Provider data attached to this call that must travel back, untouched, when
|
|
1155
|
+
* the conversation returns it: Gemini 3's
|
|
1156
|
+
* `extra_content.google.thought_signature` through its OpenAI-compatible
|
|
1157
|
+
* endpoint, without which the next turn is rejected with a 400 («Function
|
|
1158
|
+
* call is missing a thought_signature»). Opaque: pass it back as received in
|
|
1159
|
+
* the assistant message's `toolCalls`. It is not part of any cache key.
|
|
1160
|
+
*/
|
|
1161
|
+
extraContent?: Record<string, unknown>;
|
|
1117
1162
|
}
|
|
1118
1163
|
/** Result returned to the caller. */
|
|
1119
1164
|
interface SavingsResult<T = unknown> {
|
|
@@ -1336,11 +1381,12 @@ interface QualityTruncationCheck {
|
|
|
1336
1381
|
/** The stop reason exactly as the provider named it; absent when it reported none. */
|
|
1337
1382
|
finishReason?: string;
|
|
1338
1383
|
/**
|
|
1339
|
-
* Whether you set the limit (`
|
|
1384
|
+
* Whether you set the limit (`maxOutputTokens` on the request or on
|
|
1385
|
+
* `response`). When false, any
|
|
1340
1386
|
* limit that applied was a provider or adapter default.
|
|
1341
1387
|
*/
|
|
1342
1388
|
capSetByCaller: boolean;
|
|
1343
|
-
/** The limit
|
|
1389
|
+
/** The limit that was sent (the smaller of the two when both were set). Present only when `capSetByCaller`. */
|
|
1344
1390
|
outputLimit?: number;
|
|
1345
1391
|
}
|
|
1346
1392
|
/** How a cache hit matched this request. */
|
|
@@ -1902,6 +1948,8 @@ interface CanonicalRequest {
|
|
|
1902
1948
|
contractId: string | null;
|
|
1903
1949
|
temperature: number | null;
|
|
1904
1950
|
seed: number | null;
|
|
1951
|
+
/** `reasoning_effort` declared by the caller; absent when it declared none. */
|
|
1952
|
+
reasoningEffort?: string;
|
|
1905
1953
|
tenantId: string;
|
|
1906
1954
|
authorizationScope: string;
|
|
1907
1955
|
/**
|
|
@@ -2180,6 +2228,8 @@ interface SemanticRecord {
|
|
|
2180
2228
|
temperature: number | null;
|
|
2181
2229
|
/** Sampling seed of the request, or null when it set none. */
|
|
2182
2230
|
seed: number | null;
|
|
2231
|
+
/** `reasoning_effort` of the request; absent when it declared none. */
|
|
2232
|
+
reasoningEffort?: string;
|
|
2183
2233
|
storedAtMs: number;
|
|
2184
2234
|
/**
|
|
2185
2235
|
* With calibration on: the highest score at which this stored answer was
|
|
@@ -2240,8 +2290,13 @@ interface SemanticCacheOptions {
|
|
|
2240
2290
|
*
|
|
2241
2291
|
* Pass your own for true semantics; the local one only sees LEXICAL closeness.
|
|
2242
2292
|
* Either way the deterministic guard below still rejects a candidate whose
|
|
2243
|
-
* numbers
|
|
2244
|
-
*
|
|
2293
|
+
* numbers (in digits or spelled out in en/es/ca: "three", "twice", "half"),
|
|
2294
|
+
* negation parity or content words differ beyond its overlap floor. It is a
|
|
2295
|
+
* lexical guard, not a proof: a one-word entity swap in a long query can
|
|
2296
|
+
* still clear the overlap floor, and through 0.4.30 a number written in words
|
|
2297
|
+
* cleared it too (GSM8K: 477 of 564 such variants got their original's
|
|
2298
|
+
* answer). Calibrate on your own traffic before trusting it with answers
|
|
2299
|
+
* that differ by one word.
|
|
2245
2300
|
*/
|
|
2246
2301
|
embed?: EmbeddingFn;
|
|
2247
2302
|
/**
|
|
@@ -2558,7 +2613,20 @@ interface ToolSelection {
|
|
|
2558
2613
|
setIsStable: boolean;
|
|
2559
2614
|
}
|
|
2560
2615
|
interface ToolSelectorOptions {
|
|
2561
|
-
/**
|
|
2616
|
+
/**
|
|
2617
|
+
* Max tools the selector keeps when it has a SIGNAL to select on: a catalogue
|
|
2618
|
+
* whose tools declare `intents` and/or `risk`, with the router on. Default 8.
|
|
2619
|
+
*
|
|
2620
|
+
* It never truncates a catalogue it cannot rank. A catalogue that declares no
|
|
2621
|
+
* `intents` and no `risk` (the usual case: MCP and OpenAI tool lists) and every
|
|
2622
|
+
* request with `savings: { router: false }` go to the provider WHOLE, exactly as
|
|
2623
|
+
* the caller sent them, and the layer credits nothing for the tool block:
|
|
2624
|
+
* cutting by position left the model unable to call the rest (on BFCL
|
|
2625
|
+
* multi-turn, gpt-4o-mini hit the reference call 8/10 times directly and 1/10
|
|
2626
|
+
* through the layer). When the selector does prune a typed catalogue, the
|
|
2627
|
+
* report's `tool-selector` trace lists what was left out and the SDK warns
|
|
2628
|
+
* (once per process, silenced by `silenceWarnings`).
|
|
2629
|
+
*/
|
|
2562
2630
|
maxTools?: number;
|
|
2563
2631
|
/** Tokenizer-aware scorer for tie-breaking (optional). */
|
|
2564
2632
|
scoreIntentMatch?: (text: string, tool: ToolDescriptor) => number;
|
|
@@ -2604,16 +2672,9 @@ declare class ToolSelector {
|
|
|
2604
2672
|
private readonly freezer;
|
|
2605
2673
|
constructor(opts?: ToolSelectorOptions);
|
|
2606
2674
|
/**
|
|
2607
|
-
*
|
|
2608
|
-
*
|
|
2609
|
-
*
|
|
2610
|
-
* Se usa cuando el llamante apaga el router (`savings:{router:false}`): sin
|
|
2611
|
-
* clasificación no hay de dónde derivar el riesgo, y filtrar sobre el
|
|
2612
|
-
* `defaultRoute()` tiraba en silencio las herramientas de escritura. Apagar el
|
|
2613
|
-
* router significa "yo elijo las herramientas", así que la relevancia pasa a
|
|
2614
|
-
* ser del llamante — pero el tope de presupuesto NO se levanta: mandar 200
|
|
2615
|
-
* esquemas al proveedor es un 400 seguro y una petición que antes funcionaba
|
|
2616
|
-
* pasaría a fallar en duro.
|
|
2675
|
+
* Every tool the caller passed, as passed: none left out, none credited.
|
|
2676
|
+
* Used when there is no signal to select on (`savings: { router: false }`,
|
|
2677
|
+
* or a catalogue with no `intents` and no `risk`).
|
|
2617
2678
|
*/
|
|
2618
2679
|
passthrough(tools: ToolDescriptor[] | undefined): ToolSelection;
|
|
2619
2680
|
select(text: string, tools: ToolDescriptor[] | undefined, execution: ExecutionClass,
|
|
@@ -3014,9 +3075,19 @@ interface ProviderRequest {
|
|
|
3014
3075
|
tools?: ToolDescriptor[];
|
|
3015
3076
|
/** Output contract to enforce via constrained decoding, when available. */
|
|
3016
3077
|
schema?: JsonSchema;
|
|
3078
|
+
/**
|
|
3079
|
+
* Output cap chosen by the caller: the smaller of `SavingsRequest.maxOutputTokens`
|
|
3080
|
+
* and `response.maxOutputTokens`. Each adapter maps it to its own field.
|
|
3081
|
+
*/
|
|
3017
3082
|
maxOutputTokens?: number;
|
|
3018
3083
|
temperature?: number;
|
|
3019
3084
|
seed?: number;
|
|
3085
|
+
/**
|
|
3086
|
+
* `SavingsRequest.reasoningEffort`, as the caller declared it. The
|
|
3087
|
+
* OpenAI-compatible adapter sends it as `reasoning_effort`; absent means
|
|
3088
|
+
* nothing is sent.
|
|
3089
|
+
*/
|
|
3090
|
+
reasoningEffort?: string;
|
|
3020
3091
|
/** Backend id selected by the constraints layer, for observability. */
|
|
3021
3092
|
constraintBackend?: string;
|
|
3022
3093
|
/**
|
|
@@ -3028,6 +3099,9 @@ interface ProviderRequest {
|
|
|
3028
3099
|
* boundary; adapters that cache automatically (OpenAI) may ignore it. The
|
|
3029
3100
|
* count is a claim about byte-for-byte stability, so a caller that rewrites an
|
|
3030
3101
|
* earlier turn must lower it.
|
|
3102
|
+
*
|
|
3103
|
+
* `0` claims only what renders BEFORE the messages: the tool catalogue. The
|
|
3104
|
+
* Anthropic adapter then marks the end of the `tools` block (its last tool).
|
|
3031
3105
|
*/
|
|
3032
3106
|
stablePrefixMessages?: number;
|
|
3033
3107
|
/**
|
|
@@ -3192,6 +3266,15 @@ interface ProviderResponse {
|
|
|
3192
3266
|
* podía distinguirlo y hacía exactamente eso.
|
|
3193
3267
|
*/
|
|
3194
3268
|
finishReason?: "stop" | "length" | "content_filter" | "tool_calls" | (string & {});
|
|
3269
|
+
/**
|
|
3270
|
+
* The provider's own reason behind `finishReason`, when it gave one: Gemini's
|
|
3271
|
+
* OpenAI-compatible endpoint stops a filtered answer with
|
|
3272
|
+
* `finish_reason: "content_filter: OTHER"` (or `PROHIBITED_CONTENT`,
|
|
3273
|
+
* `SAFETY`…), which the built-in adapter reports as `finishReason:
|
|
3274
|
+
* "content_filter"` and `finishReasonDetail: "OTHER"`. Informational: the
|
|
3275
|
+
* layer decides on `finishReason` alone.
|
|
3276
|
+
*/
|
|
3277
|
+
finishReasonDetail?: string;
|
|
3195
3278
|
/**
|
|
3196
3279
|
* The refusal message the model returned INSTEAD of an answer, exactly as the
|
|
3197
3280
|
* provider wrote it: OpenAI's `message.refusal` (Chat Completions with
|
|
@@ -3504,7 +3587,28 @@ interface SavingsLayerConfig {
|
|
|
3504
3587
|
provider: Provider;
|
|
3505
3588
|
tokenizer: TokenizerRegistry;
|
|
3506
3589
|
exactCache?: ExactCache;
|
|
3590
|
+
/**
|
|
3591
|
+
* WHERE reworded questions are looked up and stored. Giving the layer a cache
|
|
3592
|
+
* does NOT switch it on: a request still has to ask for it with
|
|
3593
|
+
* `savings.semanticCache`, or you set {@link semanticCacheDefault} to ask for
|
|
3594
|
+
* it on every request. A layer that has a cache and a request that neither
|
|
3595
|
+
* asks for it nor turns it off gets a one-time console warning (silenced by
|
|
3596
|
+
* `silenceWarnings`, or by setting `semanticCacheDefault`, `false` included).
|
|
3597
|
+
*/
|
|
3507
3598
|
semanticCache?: InMemorySemanticCache;
|
|
3599
|
+
/**
|
|
3600
|
+
* Default for `savings.semanticCache` on every request of this layer. A
|
|
3601
|
+
* request's own value always wins, `false` included. Unset, the semantic cache
|
|
3602
|
+
* is used only by requests that ask for it.
|
|
3603
|
+
*
|
|
3604
|
+
* OPT-IN, and deliberately a separate field from {@link semanticCache}: the
|
|
3605
|
+
* cache is the backend, this is the decision to serve answers to reworded
|
|
3606
|
+
* questions, which can serve a wrong answer. Prefer it with a cache built with
|
|
3607
|
+
* `calibration`, which serves nothing until your own traffic certifies a
|
|
3608
|
+
* floor. `false` states that you switch it on per request, and silences the
|
|
3609
|
+
* warning about a cache that no request uses.
|
|
3610
|
+
*/
|
|
3611
|
+
semanticCacheDefault?: boolean | "safe-only" | "include-agentic";
|
|
3508
3612
|
singleflight?: Singleflight;
|
|
3509
3613
|
resolvers?: ResolverRegistry;
|
|
3510
3614
|
router?: ExecutionRouter;
|
|
@@ -4307,6 +4411,13 @@ interface Policy {
|
|
|
4307
4411
|
* así que sin esto "hour" y "day" no significaban nada operativamente.
|
|
4308
4412
|
*/
|
|
4309
4413
|
maxCacheAgeMs: number | null;
|
|
4414
|
+
/**
|
|
4415
|
+
* The user turns touch a sensitive topic (self-harm or suicide, a mental
|
|
4416
|
+
* health crisis, a medical emergency), or null. With a topic, neither the
|
|
4417
|
+
* exact nor the semantic cache is used and no reference record is left: the
|
|
4418
|
+
* answer is measured and served, never replayed or credited as a saving.
|
|
4419
|
+
*/
|
|
4420
|
+
sensitiveTopic: "self-harm" | "mental-health-crisis" | "medical-emergency" | null;
|
|
4310
4421
|
reasons: string[];
|
|
4311
4422
|
}
|
|
4312
4423
|
declare function evaluatePolicy(c: CanonicalRequest): Policy;
|
|
@@ -4556,6 +4667,21 @@ declare function createMockProvider(options?: MockProviderOptions): Provider;
|
|
|
4556
4667
|
* `constraints.backend: "none"` rather than claiming a guarantee the provider
|
|
4557
4668
|
* never gave.
|
|
4558
4669
|
*
|
|
4670
|
+
* OpenAI-only request fields are sent only to OpenAI's own API
|
|
4671
|
+
* (`prompt_cache_key`, see {@link OpenAICompatibleOptions.sendPromptCacheKey}).
|
|
4672
|
+
* An optional field an endpoint still rejects by name with a 400/422
|
|
4673
|
+
* (`prompt_cache_key`, `service_tier`, `seed`) is dropped and the request
|
|
4674
|
+
* repeated once, and the model is remembered, as with `response_format`.
|
|
4675
|
+
*
|
|
4676
|
+
* Output is counted as the provider bills it: where `total_tokens` exceeds
|
|
4677
|
+
* `prompt_tokens + completion_tokens` (Gemini's OpenAI-compatible endpoint
|
|
4678
|
+
* leaves its thinking tokens out of `completion_tokens`), the difference is
|
|
4679
|
+
* added to the output and reported as reasoning. Against OpenAI's own API,
|
|
4680
|
+
* whose `completion_tokens` already include reasoning, nothing is added. A
|
|
4681
|
+
* content-filter stop with a reason (Gemini's `"content_filter: OTHER"`) is
|
|
4682
|
+
* reported as `finishReason: "content_filter"`, the reason in
|
|
4683
|
+
* `finishReasonDetail`.
|
|
4684
|
+
*
|
|
4559
4685
|
* Network calls use global `fetch` (Node >= 18) so there is no SDK dependency.
|
|
4560
4686
|
*/
|
|
4561
4687
|
interface OpenAICompatibleOptions {
|
|
@@ -4565,8 +4691,11 @@ interface OpenAICompatibleOptions {
|
|
|
4565
4691
|
* Strip the `provider/` prefix from model ids before sending (`openai/gpt-4o-mini`
|
|
4566
4692
|
* → `gpt-4o-mini`).
|
|
4567
4693
|
*
|
|
4568
|
-
* Default (undefined): strip when `baseUrl` is OpenAI's own API
|
|
4569
|
-
* OpenAI endpoint
|
|
4694
|
+
* Default (undefined): strip when `baseUrl` is OpenAI's own API, an Azure
|
|
4695
|
+
* OpenAI endpoint or Google's own Gemini API
|
|
4696
|
+
* (https://generativelanguage.googleapis.com, whose OpenAI-compatible
|
|
4697
|
+
* endpoint answers 404 «models/google/gemini-… is not found» to a prefixed
|
|
4698
|
+
* id), keep otherwise. OpenAI rejects a prefixed id with a 404
|
|
4570
4699
|
* ("model does not exist"), so the qualified ids the layer uses everywhere
|
|
4571
4700
|
* else — pricing, cache keys, the report — would break the very first call
|
|
4572
4701
|
* that reaches the provider. A gateway or a self-hosted server with a
|
|
@@ -4587,6 +4716,39 @@ interface OpenAICompatibleOptions {
|
|
|
4587
4716
|
* saving. Benchmarks that make real cost claims must set this.
|
|
4588
4717
|
*/
|
|
4589
4718
|
requireUsage?: boolean;
|
|
4719
|
+
/**
|
|
4720
|
+
* Which Chat Completions field carries the output cap (`maxOutputTokens`).
|
|
4721
|
+
*
|
|
4722
|
+
* Default (undefined): `max_completion_tokens` when `baseUrl` is OpenAI's own
|
|
4723
|
+
* API (https://api.openai.com), `max_tokens` everywhere else. OpenAI
|
|
4724
|
+
* deprecated `max_tokens` when it introduced `max_completion_tokens`
|
|
4725
|
+
* (2024-09-12) and its reasoning models (o-series, gpt-5.x) reject it with a
|
|
4726
|
+
* 400; `max_completion_tokens` is accepted by every current OpenAI chat
|
|
4727
|
+
* model. OpenAI-compatible servers (proxies, self-hosted inference servers,
|
|
4728
|
+
* routers, Azure with an older api-version, a local gateway) understand
|
|
4729
|
+
* `max_tokens`, and some silently IGNORE a field they do not know, which
|
|
4730
|
+
* would drop the cap without an error.
|
|
4731
|
+
*
|
|
4732
|
+
* With the default, a 400/422 that names the field sent as unsupported is
|
|
4733
|
+
* retried once with the other one (it is rejected before any token is
|
|
4734
|
+
* generated, so nothing is billed twice) and the model is remembered. An
|
|
4735
|
+
* explicit value always wins and is never switched.
|
|
4736
|
+
*/
|
|
4737
|
+
maxTokensParam?: "max_tokens" | "max_completion_tokens";
|
|
4738
|
+
/**
|
|
4739
|
+
* Whether to send `prompt_cache_key`, the routing hint OpenAI uses to land
|
|
4740
|
+
* requests that share a prefix on the same cache instance.
|
|
4741
|
+
*
|
|
4742
|
+
* Default (undefined): only when `baseUrl` is OpenAI's own API
|
|
4743
|
+
* (https://api.openai.com). The field is OpenAI's, and strict endpoints
|
|
4744
|
+
* reject what they do not know: Gemini's OpenAI-compatible endpoint answers
|
|
4745
|
+
* 400 «Unknown name "prompt_cache_key"», so from 0.4.1 to 0.4.31 every
|
|
4746
|
+
* request with a cached prefix failed there. Set `true` for a proxy or router
|
|
4747
|
+
* in front of OpenAI that forwards it (if the endpoint rejects it anyway,
|
|
4748
|
+
* the request is repeated once without it and the model is remembered), or
|
|
4749
|
+
* `false` to never send it.
|
|
4750
|
+
*/
|
|
4751
|
+
sendPromptCacheKey?: boolean;
|
|
4590
4752
|
}
|
|
4591
4753
|
/**
|
|
4592
4754
|
* ¿Cumple este esquema las reglas del modo `strict` de OpenAI?
|
|
@@ -4604,8 +4766,8 @@ interface OpenAICompatibleOptions {
|
|
|
4604
4766
|
declare function isStrictCompatible(schema: unknown): boolean;
|
|
4605
4767
|
/**
|
|
4606
4768
|
* Decides the id that travels on the wire. Explicit option wins; otherwise the
|
|
4607
|
-
* endpoint decides: OpenAI/Azure get the bare id,
|
|
4608
|
-
* the caller wrote. Exported for the pipeline-level test that pins the README
|
|
4769
|
+
* endpoint decides: OpenAI/Azure and Google's own Gemini API get the bare id,
|
|
4770
|
+
* everything else keeps what the caller wrote. Exported for the pipeline-level test that pins the README
|
|
4609
4771
|
* snippet; not part of the public API.
|
|
4610
4772
|
*/
|
|
4611
4773
|
declare function quitarPrefijoDeProveedor(model: string, explicito: boolean | undefined, baseUrl: string): string;
|
|
@@ -4616,6 +4778,8 @@ declare class OpenAICompatibleProvider implements Provider {
|
|
|
4616
4778
|
/** Models of this endpoint already known to reject `response_format`. */
|
|
4617
4779
|
private readonly sinResponseFormat;
|
|
4618
4780
|
private streamOptionsRejected;
|
|
4781
|
+
private readonly campoDeTopeAprendido;
|
|
4782
|
+
private readonly camposRechazados;
|
|
4619
4783
|
private readonly origen;
|
|
4620
4784
|
constructor(opts: OpenAICompatibleOptions);
|
|
4621
4785
|
generate(req: ProviderRequest, options?: ProviderStreamOptions): Promise<ProviderResponse>;
|
|
@@ -4629,6 +4793,10 @@ declare class OpenAICompatibleProvider implements Provider {
|
|
|
4629
4793
|
* as one text event.
|
|
4630
4794
|
*/
|
|
4631
4795
|
generateStream(req: ProviderRequest, options?: ProviderStreamOptions): AsyncGenerator<ProviderStreamEvent, void, undefined>;
|
|
4796
|
+
private campoDeTope;
|
|
4797
|
+
private corregirCampoDeTope;
|
|
4798
|
+
private corregirCampoOpcional;
|
|
4799
|
+
private campoAdmitido;
|
|
4632
4800
|
private enviar;
|
|
4633
4801
|
private construirCuerpo;
|
|
4634
4802
|
/** Translate a 2xx endpoint response into the provider-neutral shape. */
|
|
@@ -4732,6 +4900,8 @@ declare class AnthropicProvider implements Provider {
|
|
|
4732
4900
|
private readonly opts;
|
|
4733
4901
|
private readonly fetchImpl;
|
|
4734
4902
|
private readonly busquedas;
|
|
4903
|
+
private readonly sinToolChoiceForzado;
|
|
4904
|
+
private readonly sinMuestreo;
|
|
4735
4905
|
constructor(opts?: AnthropicOptions);
|
|
4736
4906
|
/** The id Anthropic's API sees: bare at `api.anthropic.com`, as written elsewhere. */
|
|
4737
4907
|
private modeloEnElCable;
|
|
@@ -4746,6 +4916,7 @@ declare class AnthropicProvider implements Provider {
|
|
|
4746
4916
|
* as one text event.
|
|
4747
4917
|
*/
|
|
4748
4918
|
generateStream(req: ProviderRequest, options?: ProviderStreamOptions): AsyncGenerator<ProviderStreamEvent, void, undefined>;
|
|
4919
|
+
private enviarConCorrecciones;
|
|
4749
4920
|
private enviar;
|
|
4750
4921
|
private construirCuerpo;
|
|
4751
4922
|
private reenvioDeBusquedas;
|
|
@@ -5630,4 +5801,4 @@ declare function toCsv(rows: readonly Readonly<Record<string, CsvValue>>[], opti
|
|
|
5630
5801
|
columns?: readonly string[];
|
|
5631
5802
|
}): string;
|
|
5632
5803
|
|
|
5633
|
-
export { type AnswerJudge, type AnswerSource, type AnthropicOptions, AnthropicProvider, BV_SALA_VERSION, type BatchCounts, type BatchItemResult, type BatchJob, type BatchJobStatus, type BatchRequest, type BatchResults, BatchSubmitError, type BatchSubmitOptions, type BatchSummary, type BivelioHandoff, CATALOGO, COMPACTION_TRANSFORMS, COMPACT_ROWS_INSTRUCTION, type CacheBreakpointStore, type CacheOutcome, type CachePlacement, type CacheTier, type CacheWriteReport, type CachedAnswer, type CalibrationObservation, CalibrationStateError, type CanonicalRequest, type ChatMessage, type CompactRowsDecodeOptions, type CompactRowsOptions, type CompactVerification, type CompactionTransform, type CompressionEconomics, type CompressionPolicyInput, type CompressionRequest, type CompressionResult, type Compressor, type ConstraintBackend, type ConstraintBackendId, type ConstraintPlan, type ConversationState, type CostBasis, type CostModel, type CsvValue, DEFAULT_COST_MODEL, DEFAULT_MAX_STALENESS_SECONDS, DEFAULT_MIN_SAVED_CHARS, type DeferredExecutionReport, type DeterministicResolver, EMBEDDED_PUBLIC_KEY, type EmbeddingFn, type EvidenceDoc, type ExactCache, ExactTokenizer, type ExecutionClass, ExecutionRouter, type FocusExportOptions, type FocusRow, type FormatChoice, FormatSelector, type FormatSelectorOptions, type HandoffFact, HeuristicEstimator, InMemoryCacheBreakpointStore, InMemoryExactCache, InMemorySemanticCache, InMemoryToolSetFreezer, type JsonSchema, type LangfuseGenerationUpdate, LicenseError, type LicenseGate, type LicenseKeyShape, type LicenseKeyset, type LicenseStatus, type LicenseTokenPayload, type LocalClassifier, MODELOS_POR_CODIFICACION, MODELS_BY_ENCODING, type MemoryDelta, type MessageRole, MockProvider, type MockProviderOptions, type ModelCascadeMode, type ModelCascadeReport, type ModelCascadeSettings, type OpenAICompatibleOptions, OpenAICompatibleProvider, type OutputContract, PRECIOS_AL_DIA, type Policy, type PriceLeverSaving, type PriceLeverSettings, type ProtectedSpan, type Provider, type ProviderRequest, type ProviderResponse, type ProviderStreamEvent, type ProviderStreamOptions, type ProviderToolSearch, type ProviderToolSearchUsage, type ProviderUsage, QUALITY_STATUSES, type QualityCacheMatch, type QualityCascadeCheck, type QualityLedger, type QualityRepairCheck, type QualitySchemaCheck, type QualityStatus, type QualityTruncationCheck, REFERENCE_MAX_AGE_MS, REFERENCE_MESSAGE_ALLOWANCE, REFERENCE_OUTPUT_SHARE, type ReferenceCredit, type ReferenceRejection, type RequestContext, type Reranker, type ResolvedDeps, type ResolvedGate, type ResolvedLicense, ResolverRegistry, type ResolverResult, type RetrievalOptions, type RetrievalOutcome, type RetrievalPlan, type Retriever, type RevocationListBody, type RevocationListVerification, type RevocationPollEvent, RevocationPoller, type RevocationPollerOptions, RevocationSnapshot, type RouteDecision, type SavingsAdapterLevers, type SavingsAdapterOptions, type SavingsAttributeOptions, type SavingsBatches, type SavingsCallOptions, type SavingsLayer, type SavingsLayerConfig, SavingsLedger, type SavingsRecord, type SavingsReport, type SavingsReportForExport, type SavingsRequest, type SavingsResult, type SavingsSeriesOptions, type SavingsSeriesRow, type SavingsSpanAttributes, type SavingsSpanOptions, type SavingsStream, type SavingsStreamEvent, type SavingsStreamOptions, type SavingsToggles, type SavingsTracingOptions, SchemaRegistry, type SemanticCacheOptions, type SemanticCalibrationBound, type SemanticCalibrationOptions, type SemanticCalibrationSegmentState, type SemanticCalibrationState, type SemanticCalibrationStatus, type SemanticHit, type SemanticLookup, type SemanticProbe, type SemanticRecord, type SemanticVerifier, type SerializationFormat, type Serializer, Singleflight, type SpanAttributeValue, type SpanLike, type SpanStartOptionsLike, StreamAbortedError, type StreamingReport, type TokenEstimator, TokenizerRegistry, type ToolCallRequest, type ToolDescriptor, type ToolOutputCompaction, type ToolOutputCompactionSettings, type ToolRisk, type ToolSearchMode, type ToolSearchOptions, type ToolSelection, ToolSelector, type ToolSelectorOptions, type ToolSetFreezer, TraceCollector, type TraceEvent, type TracerLike, type TracerProviderLike, UMBRAL_LOCAL, UsageEmitter, type UsageEmitterOptions, type ValidationError, type ValidationResult, type VerificationCheck, type VerificationExclusion, type VerificationOutcome, type VerificationReport, type VerificationSettings, type VerificationSide, type VerificationStratum, adaptiveK, arithmeticResolver, buildExactKey, buildInflightKey, calibrateSemanticFloor, canonicalize, compactRowsSerializer, compactToolOutput, compresionFiel, computeNextDelay, cosine, createCompactRowsSerializer, createDefaultResolvers, createHandoff, createMockProvider, createSavingsLayer, csvSerializer, decodeCompactRows, dedupe, defaultTokenizerRegistry, deriveSeatId, deriveStatus, detectCi, embebedorLocal, emptyState, encodeCompactRows, evalArithmetic, evaluatePolicy, executeRetrievalPlan, gateFromKey, heuristicEstimator, instrumentSavingsLayer, isKeyset, isStrictCompatible, jsonCompactSerializer, keyTokensMatch, licenseKeyShape, liveGateFromKey, mergeDelta, modelFamilyOf, multisetEqual, negationCount, noopCompressor, normalizeLicenseKey, normalizeText, numericTokens, precioDeLista, projectContext, providerNativeBackend, quitarPrefijoDeProveedor, randomId, recordSavingsOnSpan, registerExactTokenizer, registrarTokenizadorExacto, renderState, resolveConstraintBackend, resolveDependencies, resolveLicense, sameAnswer, savingsSpanAttributes, sha256, shouldCompress, stableStringify, toCsv, toFocusRows, toLangfuseGeneration, toSavingsSeries, uniformColumns, validateAgainstSchema, vectorLocal, verifyCompactSignature, verifyLicenseToken, verifyRevocationList, withProtectedSpans, words };
|
|
5804
|
+
export { type AnswerJudge, type AnswerSource, type AnthropicOptions, AnthropicProvider, BV_SALA_VERSION, type BatchCounts, type BatchItemResult, type BatchJob, type BatchJobStatus, type BatchRequest, type BatchResults, BatchSubmitError, type BatchSubmitOptions, type BatchSummary, type BivelioHandoff, CATALOGO, COMPACTION_TRANSFORMS, COMPACT_ROWS_INSTRUCTION, type CacheBreakpointStore, type CacheOutcome, type CachePlacement, type CacheTier, type CacheWriteReport, type CachedAnswer, type CalibrationObservation, CalibrationStateError, type CanonicalRequest, type ChatMessage, type CompactRowsDecodeOptions, type CompactRowsOptions, type CompactVerification, type CompactionTransform, type CompressionEconomics, type CompressionPolicyInput, type CompressionRequest, type CompressionResult, type Compressor, type ConstraintBackend, type ConstraintBackendId, type ConstraintPlan, type ConversationState, type CostBasis, type CostModel, type CsvValue, DEFAULT_COST_MODEL, DEFAULT_MAX_STALENESS_SECONDS, DEFAULT_MIN_SAVED_CHARS, type DeferredExecutionReport, type DeterministicResolver, EMBEDDED_PUBLIC_KEY, type EmbeddingFn, type EvidenceDoc, type ExactCache, ExactTokenizer, type ExecutionClass, ExecutionRouter, type FocusExportOptions, type FocusRow, type FormatChoice, FormatSelector, type FormatSelectorOptions, type HandoffFact, HeuristicEstimator, InMemoryCacheBreakpointStore, InMemoryExactCache, InMemorySemanticCache, InMemoryToolSetFreezer, type JsonSchema, type LangfuseGenerationUpdate, LicenseError, type LicenseGate, type LicenseKeyShape, type LicenseKeyset, type LicenseStatus, type LicenseTokenPayload, type LocalClassifier, MODELOS_POR_CODIFICACION, MODELS_BY_ENCODING, type MemoryDelta, type MessageRole, MockProvider, type MockProviderOptions, type ModelCascadeMode, type ModelCascadeReport, type ModelCascadeSettings, type OpenAICompatibleOptions, OpenAICompatibleProvider, type OutputContract, PRECIOS_AL_DIA, type Policy, type PriceLeverSaving, type PriceLeverSettings, type ProtectedSpan, type Provider, type ProviderRequest, type ProviderResponse, type ProviderStreamEvent, type ProviderStreamOptions, type ProviderToolSearch, type ProviderToolSearchUsage, type ProviderUsage, QUALITY_STATUSES, type QualityCacheMatch, type QualityCascadeCheck, type QualityLedger, type QualityRepairCheck, type QualitySchemaCheck, type QualityStatus, type QualityTruncationCheck, REFERENCE_MAX_AGE_MS, REFERENCE_MESSAGE_ALLOWANCE, REFERENCE_OUTPUT_SHARE, type ReasoningEffort, type ReferenceCredit, type ReferenceRejection, type RequestContext, type Reranker, type ResolvedDeps, type ResolvedGate, type ResolvedLicense, ResolverRegistry, type ResolverResult, type RetrievalOptions, type RetrievalOutcome, type RetrievalPlan, type Retriever, type RevocationListBody, type RevocationListVerification, type RevocationPollEvent, RevocationPoller, type RevocationPollerOptions, RevocationSnapshot, type RouteDecision, type SavingsAdapterLevers, type SavingsAdapterOptions, type SavingsAttributeOptions, type SavingsBatches, type SavingsCallOptions, type SavingsLayer, type SavingsLayerConfig, SavingsLedger, type SavingsRecord, type SavingsReport, type SavingsReportForExport, type SavingsRequest, type SavingsResult, type SavingsSeriesOptions, type SavingsSeriesRow, type SavingsSpanAttributes, type SavingsSpanOptions, type SavingsStream, type SavingsStreamEvent, type SavingsStreamOptions, type SavingsToggles, type SavingsTracingOptions, SchemaRegistry, type SemanticCacheOptions, type SemanticCalibrationBound, type SemanticCalibrationOptions, type SemanticCalibrationSegmentState, type SemanticCalibrationState, type SemanticCalibrationStatus, type SemanticHit, type SemanticLookup, type SemanticProbe, type SemanticRecord, type SemanticVerifier, type SerializationFormat, type Serializer, Singleflight, type SpanAttributeValue, type SpanLike, type SpanStartOptionsLike, StreamAbortedError, type StreamingReport, type TokenEstimator, TokenizerRegistry, type ToolCallRequest, type ToolDescriptor, type ToolOutputCompaction, type ToolOutputCompactionSettings, type ToolRisk, type ToolSearchMode, type ToolSearchOptions, type ToolSelection, ToolSelector, type ToolSelectorOptions, type ToolSetFreezer, TraceCollector, type TraceEvent, type TracerLike, type TracerProviderLike, UMBRAL_LOCAL, UsageEmitter, type UsageEmitterOptions, type ValidationError, type ValidationResult, type VerificationCheck, type VerificationExclusion, type VerificationOutcome, type VerificationReport, type VerificationSettings, type VerificationSide, type VerificationStratum, adaptiveK, arithmeticResolver, buildExactKey, buildInflightKey, calibrateSemanticFloor, canonicalize, compactRowsSerializer, compactToolOutput, compresionFiel, computeNextDelay, cosine, createCompactRowsSerializer, createDefaultResolvers, createHandoff, createMockProvider, createSavingsLayer, csvSerializer, decodeCompactRows, dedupe, defaultTokenizerRegistry, deriveSeatId, deriveStatus, detectCi, embebedorLocal, emptyState, encodeCompactRows, evalArithmetic, evaluatePolicy, executeRetrievalPlan, gateFromKey, heuristicEstimator, instrumentSavingsLayer, isKeyset, isStrictCompatible, jsonCompactSerializer, keyTokensMatch, licenseKeyShape, liveGateFromKey, mergeDelta, modelFamilyOf, multisetEqual, negationCount, noopCompressor, normalizeLicenseKey, normalizeText, numericTokens, precioDeLista, projectContext, providerNativeBackend, quitarPrefijoDeProveedor, randomId, recordSavingsOnSpan, registerExactTokenizer, registrarTokenizadorExacto, renderState, resolveConstraintBackend, resolveDependencies, resolveLicense, sameAnswer, savingsSpanAttributes, sha256, shouldCompress, stableStringify, toCsv, toFocusRows, toLangfuseGeneration, toSavingsSeries, uniformColumns, validateAgainstSchema, vectorLocal, verifyCompactSignature, verifyLicenseToken, verifyRevocationList, withProtectedSpans, words };
|