Skip to content
中文

RankedList ​

KIT · interface · Type contract

One retriever's ordered result, optionally weighted.

Import ​

ts
import type { RankedList } from '@jangts/agent-core/kits/rank-fusion';
js
/** @typedef {import('@jangts/agent-core/kits/rank-fusion').RankedList} RankedList */

Other public entry points:@jangts/agent-core/types, @jangts/agent-core/kits, @jangts/agent-core/kits/rank-fusion.

Definition ​

ts
interface RankedList

Field structure ​

FieldTypeRequiredDescription
sourceIdstringRequiredRead-only. Unique source name; duplicate names are rejected because they would double-count.
idsreadonly string[]RequiredRead-only. Ids in descending relevance; duplicates inside one list are ignored after the first.
weightnumber | undefinedOptionalRead-only. Relative source weight, strictly positive; defaults to 1.

Examples ​

First use the default fusion parameters ​

Beginner · Node.js

ts
import { reciprocalRankFusion } from '@jangts/agent-core/kits/rank-fusion';
const result = reciprocalRankFusion([
  { sourceId: 'text', ids: ['workflow', 'model'] },
  { sourceId: 'vector', ids: ['model', 'workflow'] },
], { limit: 5 });
console.log(result);
js
import { reciprocalRankFusion } from '@jangts/agent-core/kits/rank-fusion';
const result = reciprocalRankFusion([
    { sourceId: 'text', ids: ['workflow', 'model'] },
    { sourceId: 'vector', ids: ['model', 'workflow'] },
], { limit: 5 });
console.log(result);

Add source weights and the smoothing parameter to the same function ​

Configuration · Node.js

ts
import { reciprocalRankFusion } from '@jangts/agent-core/kits/rank-fusion';
const result = reciprocalRankFusion([
  { sourceId: 'text', ids: ['workflow', 'model'], weight: 2 },
  { sourceId: 'vector', ids: ['model', 'workflow'], weight: 1 },
], { limit: 2, k: 30 });
console.log(result[0].contributions);
js
import { reciprocalRankFusion } from '@jangts/agent-core/kits/rank-fusion';
const result = reciprocalRankFusion([
    { sourceId: 'text', ids: ['workflow', 'model'], weight: 2 },
    { sourceId: 'vector', ids: ['model', 'workflow'], weight: 1 },
], { limit: 2, k: 30 });
console.log(result[0].contributions);

API reference, usage examples and developer guides.