@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
161 lines (160 loc) • 3.97 kB
TypeScript
/**
* @file Scorer Builder
* Fluent builder API for creating custom scorers
*/
import type { ScorerCategory, ScorerInput, ScorerRule, ScorerType, ScorerFunction } from "../../types/index.js";
import type { BaseScorer } from "./baseScorer.js";
/**
* Fluent builder for creating custom scorers
*/
export declare class ScorerBuilder {
private _id;
private _name;
private _description?;
private _type;
private _category;
private _version;
private _requiredInputs;
private _optionalInputs;
private _threshold;
private _weight;
private _timeout;
private _retries;
private _scorerFn?;
private _rules;
private _subScorers;
private _aggregation;
private _subScorerWeights;
constructor(id: string, name: string);
/**
* Create a new scorer builder
*/
static create(id: string, name: string): ScorerBuilder;
/**
* Set scorer description
*/
description(desc: string): this;
/**
* Set scorer type
*/
type(type: ScorerType): this;
/**
* Set scorer category
*/
category(category: ScorerCategory): this;
/**
* Set scorer version
*/
version(version: string): this;
/**
* Set required inputs
*/
requireInputs(...inputs: (keyof ScorerInput)[]): this;
/**
* Set optional inputs
*/
optionalInputs(...inputs: (keyof ScorerInput)[]): this;
/**
* Set pass/fail threshold
*/
threshold(threshold: number): this;
/**
* Set weight for aggregation
*/
weight(weight: number): this;
/**
* Set execution timeout
*/
timeout(ms: number): this;
/**
* Set retry count
*/
retries(count: number): this;
/**
* Set the scoring function
*/
scoringFunction(fn: ScorerFunction): this;
/**
* Add a sub-scorer for composition
*/
addScorer(scorer: BaseScorer, weight?: number): this;
/**
* Set aggregation method for composed scorers
*/
aggregateWith(method: "average" | "min" | "max" | "weighted"): this;
/**
* Add a regex check rule
*/
matchesPattern(pattern: string | RegExp, options?: {
id?: string;
weight?: number;
}): this;
/**
* Add a keyword check rule
*/
containsKeyword(keyword: string, options?: {
id?: string;
weight?: number;
}): this;
/**
* Add a length check rule
*/
hasLength(options: {
minWords?: number;
maxWords?: number;
minChars?: number;
maxChars?: number;
id?: string;
weight?: number;
}): this;
/**
* Add a custom rule
*/
customRule(rule: ScorerRule): this;
/**
* Build the scorer
*/
build(): BaseScorer;
/**
* Build configuration object
*/
private _buildConfig;
/**
* Build a rule-based scorer from accumulated rules
*/
private _buildRuleScorer;
/**
* Evaluate a single rule
*/
private _evaluateRule;
}
/**
* Quick builder factory functions
*/
export declare const Scorers: {
/**
* Create a new scorer builder
*/
create: (id: string, name: string) => ScorerBuilder;
/**
* Create a simple pass/fail scorer based on a condition
*/
passIf: (id: string, name: string, condition: (input: ScorerInput) => boolean) => ScorerBuilder;
/**
* Create a scorer that checks for required content
*/
requiresContent: (id: string, name: string, keywords: string[]) => ScorerBuilder;
/**
* Create a scorer with length constraints
*/
withLength: (id: string, name: string, options: {
minWords?: number;
maxWords?: number;
minChars?: number;
maxChars?: number;
}) => ScorerBuilder;
/**
* Create a scorer that combines multiple scorers
*/
combine: (id: string, name: string, scorers: BaseScorer[]) => ScorerBuilder;
};