@juspay/neurolink
Version:
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
26 lines (25 loc) • 1.08 kB
JavaScript
export const LEGACY_ANTHROPIC_ACCOUNT_KEY = "anthropic:legacy-default";
export const ENV_ANTHROPIC_ACCOUNT_KEY = "anthropic:env";
export function normalizeAnthropicAccountKey(value) {
const trimmed = value.trim().toLowerCase();
return trimmed.startsWith("anthropic:") ? trimmed : `anthropic:${trimmed}`;
}
export function anthropicAccountKeysEqual(left, right) {
return (normalizeAnthropicAccountKey(left) === normalizeAnthropicAccountKey(right));
}
export function createAccountAllowlist(values) {
if (values === undefined) {
return undefined;
}
return new Set(values
.map(normalizeAnthropicAccountKey)
.filter((value) => value !== "anthropic:"));
}
export function isAccountAllowed(accountKey, allowlist) {
return (allowlist === undefined ||
allowlist.has(normalizeAnthropicAccountKey(accountKey)));
}
export function shouldLoadFallbackCredential(storedAnthropicAccountCount, fallbackAccountKey, allowlist) {
return (storedAnthropicAccountCount === 0 &&
isAccountAllowed(fallbackAccountKey, allowlist));
}