@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
87 lines (86 loc) • 2.79 kB
TypeScript
/**
* @file Custom Scorer Utilities
* Helper functions for creating custom scorers
*/
import type { ScorerFunction, ScorerCategory, ScorerConfig, ScorerInput, ScorerMetadata, ScorerType } from "../../types/index.js";
import { BaseScorer } from "./baseScorer.js";
/**
* Create scorer metadata with defaults
*/
export declare function createScorerMetadata(id: string, name: string, options?: {
description?: string;
type?: ScorerType;
category?: ScorerCategory;
version?: string;
requiredInputs?: (keyof ScorerInput)[];
optionalInputs?: (keyof ScorerInput)[];
defaultConfig?: ScorerConfig;
}): ScorerMetadata;
/**
* Create a simple function-based scorer
*/
export declare function createFunctionScorer(id: string, name: string, scorerFn: ScorerFunction, options?: {
description?: string;
category?: ScorerCategory;
type?: ScorerType;
version?: string;
requiredInputs?: (keyof ScorerInput)[];
optionalInputs?: (keyof ScorerInput)[];
config?: ScorerConfig;
}): BaseScorer;
/**
* Create a regex-based scorer
*/
export declare function createRegexScorer(id: string, name: string, options: {
pattern: string | RegExp;
flags?: string;
shouldMatch?: boolean;
description?: string;
config?: ScorerConfig;
}): BaseScorer;
/**
* Create a keyword presence scorer
*/
export declare function createKeywordScorer(id: string, name: string, options: {
requiredKeywords?: string[];
forbiddenKeywords?: string[];
caseInsensitive?: boolean;
description?: string;
config?: ScorerConfig;
}): BaseScorer;
/**
* Create a length-based scorer
*/
export declare function createSimpleLengthScorer(id: string, name: string, options: {
minWords?: number;
maxWords?: number;
minChars?: number;
maxChars?: number;
description?: string;
config?: ScorerConfig;
}): BaseScorer;
/**
* Compose multiple scorers into a single scorer with aggregation
*/
export declare function composeScorers(id: string, name: string, scorers: BaseScorer[], options?: {
aggregation?: "average" | "min" | "max" | "weighted";
weights?: number[];
description?: string;
config?: ScorerConfig;
}): BaseScorer;
/**
* Create a conditional scorer that only runs if a condition is met
*/
export declare function createConditionalScorer(id: string, name: string, condition: (input: ScorerInput) => boolean, scorer: BaseScorer, options?: {
defaultScore?: number;
defaultReasoning?: string;
description?: string;
config?: ScorerConfig;
}): BaseScorer;
/**
* Create a scorer that inverts the score (10 - score)
*/
export declare function createInvertedScorer(id: string, name: string, scorer: BaseScorer, options?: {
description?: string;
config?: ScorerConfig;
}): BaseScorer;