@juspay/neurolink 12.50.0 → 12.51.0
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/browser/neurolink.min.js +666 -666
- package/dist/cli/commands/setup.d.ts +7 -5
- package/dist/cli/commands/setup.js +10 -8
- package/dist/constants/enums.d.ts +7 -15
- package/dist/constants/enums.js +8 -16
- package/dist/factories/providerDescriptors.d.ts +17 -3
- package/dist/factories/providerDescriptors.js +81 -56
- package/dist/factories/providerRegistry.d.ts +9 -1
- package/dist/factories/providerRegistry.js +19 -9
- package/dist/models/manifestRegistry.js +40 -3
- package/dist/providers/catalog/index.generated.d.ts +3 -1
- package/dist/providers/catalog/index.generated.js +11 -0
- package/dist/providers/catalog/laya.json +107 -0
- package/dist/providers/catalog/loader.d.ts +7 -4
- package/dist/providers/catalog/loader.js +10 -3
- package/dist/providers/catalog/provider-catalog.schema.json +218 -11
- package/dist/providers/catalog/schema.d.ts +11 -9
- package/dist/providers/catalog/schema.js +333 -59
- package/dist/providers/configuredDecision.d.ts +23 -0
- package/dist/providers/configuredDecision.js +111 -0
- package/dist/providers/decide/baseUrl.d.ts +2 -0
- package/dist/providers/decide/baseUrl.js +14 -0
- package/dist/providers/decide/errors.d.ts +8 -0
- package/dist/providers/decide/errors.js +57 -0
- package/dist/providers/decide/formatters.d.ts +2 -0
- package/dist/providers/decide/formatters.js +4 -0
- package/dist/providers/decide/paths.d.ts +1 -0
- package/dist/providers/decide/paths.js +21 -0
- package/dist/providers/decide/template.d.ts +3 -0
- package/dist/providers/decide/template.js +13 -0
- package/dist/types/providerCatalog.d.ts +74 -1
- package/dist/types/providerCatalog.generated.d.ts +2 -2
- package/dist/types/providers.d.ts +12 -9
- package/dist/utils/modelChoices.js +11 -25
- package/dist/utils/providerConfig.d.ts +0 -5
- package/dist/utils/providerConfig.js +0 -17
- package/docs-site/static/search-index.json +7 -7
- package/package.json +6 -2
- package/dist/models/manifests/laya.d.ts +0 -12
- package/dist/models/manifests/laya.js +0 -54
- package/dist/providers/laya.d.ts +0 -40
- package/dist/providers/laya.js +0 -152
package/dist/providers/laya.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { LayaModels } from "../constants/enums.js";
|
|
2
|
-
import { logger } from "../utils/logger.js";
|
|
3
|
-
import { redactUrlForError } from "../utils/logSanitize.js";
|
|
4
|
-
import { getProviderModel } from "../utils/providerConfig.js";
|
|
5
|
-
import { describeValidationErrors, isRecord, redactCredentials, SystemOneDecisionProvider, } from "./systemOneDecision.js";
|
|
6
|
-
/**
|
|
7
|
-
* Normalise the two envelopes a Laya failure can arrive in.
|
|
8
|
-
*
|
|
9
|
-
* LiteLLM's own, `{"error":{"message","type","code"}}`, for anything the proxy
|
|
10
|
-
* rejects before Laya sees it (a bad key, a rate limit). FastAPI's, from
|
|
11
|
-
* Laya's server: `{"detail":"..."}` for its own checks (question types, the
|
|
12
|
-
* question cap) and `{"detail":[{loc,msg,input}]}` for request validation.
|
|
13
|
-
*/
|
|
14
|
-
function parseLayaError(status, body, requestId) {
|
|
15
|
-
const retryable = status === 429 || status >= 500;
|
|
16
|
-
const kind = status === 401 || status === 403
|
|
17
|
-
? "authentication"
|
|
18
|
-
: status === 413
|
|
19
|
-
? "max_tokens_exceeded"
|
|
20
|
-
: status === 429
|
|
21
|
-
? "rate_limit"
|
|
22
|
-
: status === 503
|
|
23
|
-
? "overloaded"
|
|
24
|
-
: status >= 500
|
|
25
|
-
? "server"
|
|
26
|
-
: "invalid_request";
|
|
27
|
-
const proxyError = isRecord(body) && isRecord(body.error) ? body.error : undefined;
|
|
28
|
-
if (proxyError &&
|
|
29
|
-
typeof proxyError.message === "string" &&
|
|
30
|
-
proxyError.message.length > 0) {
|
|
31
|
-
return {
|
|
32
|
-
kind,
|
|
33
|
-
message: proxyError.message,
|
|
34
|
-
status,
|
|
35
|
-
requestId,
|
|
36
|
-
retryable,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
const detail = isRecord(body) ? body.detail : undefined;
|
|
40
|
-
if (Array.isArray(detail)) {
|
|
41
|
-
return {
|
|
42
|
-
kind: "invalid_request",
|
|
43
|
-
message: `Request failed validation — ${describeValidationErrors(detail)}`,
|
|
44
|
-
status,
|
|
45
|
-
requestId,
|
|
46
|
-
retryable: false,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if (typeof detail === "string" && detail.length > 0) {
|
|
50
|
-
return { kind, message: detail, status, requestId, retryable };
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
kind,
|
|
54
|
-
message: `Laya request failed with HTTP ${status}`,
|
|
55
|
-
status,
|
|
56
|
-
requestId,
|
|
57
|
-
retryable,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Laya Provider — the `decide` inference type only.
|
|
62
|
-
*
|
|
63
|
-
* Laya is Convai Innovations' open-weights "System One" decision model: the
|
|
64
|
-
* same typed `noul` / `choice` / `score` questions as TypeSafe's Jev, answered
|
|
65
|
-
* by an encoder in one forward pass, on the same wire. The request loop,
|
|
66
|
-
* retries, auth circuit breaker and answer parsing are shared with every
|
|
67
|
-
* decision provider in {@link SystemOneDecisionProvider}.
|
|
68
|
-
*
|
|
69
|
-
* Its encoders read far less than Jev: 1,024 tokens on the `typed-decisions`
|
|
70
|
-
* and `multilingual` checkpoints, 512 on `english`. The descriptor's
|
|
71
|
-
* `decisionLimits` refuses what does not fit rather than letting the server
|
|
72
|
-
* cut the state off silently.
|
|
73
|
-
*
|
|
74
|
-
* @see https://github.com/NandhaKishorM/laya
|
|
75
|
-
*/
|
|
76
|
-
export class LayaProvider extends SystemOneDecisionProvider {
|
|
77
|
-
apiKey;
|
|
78
|
-
baseURL;
|
|
79
|
-
constructor(modelName, sdk, _region, credentials) {
|
|
80
|
-
super(modelName, "laya", sdk);
|
|
81
|
-
this.apiKey =
|
|
82
|
-
credentials?.apiKey?.trim() || (process.env.LAYA_API_KEY?.trim() ?? "");
|
|
83
|
-
// No built-in endpoint: Laya is self-hosted or reached through a proxy
|
|
84
|
-
// (a Laya server, or a LiteLLM pass-through route to one), so the base URL
|
|
85
|
-
// comes only from config. `||`, not `??`, so a blank one counts as unset.
|
|
86
|
-
this.baseURL = (credentials?.baseURL?.trim() ||
|
|
87
|
-
process.env.LAYA_BASE_URL?.trim() ||
|
|
88
|
-
"").replace(/\/+$/, "");
|
|
89
|
-
// A self-hosted LAYA_BASE_URL can carry `user:pass@` or a `?token=`.
|
|
90
|
-
logger.debug("Laya Provider initialized (decide only)", {
|
|
91
|
-
modelName: this.modelName,
|
|
92
|
-
baseURL: this.baseURL ? redactUrlForError(this.baseURL) : "(not set)",
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
getDefaultModel() {
|
|
96
|
-
return getProviderModel("LAYA_MODEL", LayaModels.TYPED_DECISIONS);
|
|
97
|
-
}
|
|
98
|
-
vendorLabel() {
|
|
99
|
-
return "Laya";
|
|
100
|
-
}
|
|
101
|
-
vendorDisplayName() {
|
|
102
|
-
return "Laya";
|
|
103
|
-
}
|
|
104
|
-
decisionApiKey() {
|
|
105
|
-
return this.apiKey;
|
|
106
|
-
}
|
|
107
|
-
missingKeyMessage() {
|
|
108
|
-
return "Laya requires an API key. Set LAYA_API_KEY or pass credentials.laya.apiKey.";
|
|
109
|
-
}
|
|
110
|
-
missingConfigMessage() {
|
|
111
|
-
return this.baseURL
|
|
112
|
-
? undefined
|
|
113
|
-
: "Laya requires a base URL. Set LAYA_BASE_URL or pass credentials.laya.baseURL.";
|
|
114
|
-
}
|
|
115
|
-
decisionEndpoint() {
|
|
116
|
-
return `${this.baseURL}/predict`;
|
|
117
|
-
}
|
|
118
|
-
decisionHeaders() {
|
|
119
|
-
return {
|
|
120
|
-
Authorization: `Bearer ${this.apiKey}`,
|
|
121
|
-
"Content-Type": "application/json",
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
/** `auto` means "let Laya's router choose", which it does when no model is named. */
|
|
125
|
-
buildDecisionBody(state, questions, model) {
|
|
126
|
-
return model === LayaModels.AUTO
|
|
127
|
-
? { state, questions }
|
|
128
|
-
: { model, state, questions };
|
|
129
|
-
}
|
|
130
|
-
parseDecisionError(status, payload, requestId) {
|
|
131
|
-
const parsed = parseLayaError(status, payload, requestId);
|
|
132
|
-
const message = redactCredentials(parsed.message, this.apiKey);
|
|
133
|
-
return {
|
|
134
|
-
...parsed,
|
|
135
|
-
message: message || `Laya request failed with HTTP ${status}`,
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
readRequestId(headers) {
|
|
139
|
-
return headers.get("x-litellm-call-id") ?? undefined;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* The checkpoint that actually answered is `routing.model` — the one Laya's
|
|
143
|
-
* router picked when the request said `auto`.
|
|
144
|
-
*/
|
|
145
|
-
resolveResponseModel(payload, requestedModel) {
|
|
146
|
-
const routing = payload.routing;
|
|
147
|
-
if (isRecord(routing) && typeof routing.model === "string") {
|
|
148
|
-
return routing.model;
|
|
149
|
-
}
|
|
150
|
-
return super.resolveResponseModel(payload, requestedModel);
|
|
151
|
-
}
|
|
152
|
-
}
|