npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ai-compare-candidates

v0.0.14

Published

Compare and rank multiple candidate objects using artificial intelligence retrieval augmented generation, providing the rationale

Readme

ai-compare-candidates

Compare and rank multiple candidate objects using artificial intelligence retrieval augmented generation, providing the rationale

This package allows you to rank multiple candidate objects in a customised manner by providing a user-supplied function that converts each such object into a candidate document in the form of a string. It then uses a vector database and embedding to perform a similarity search retrieval of an initial number of candidates. This search is then refined into the same or a smaller number of candidates by feeding them into a large language model which will rank the candidates. The candidate documents or part thereof can also be summarised into a defined word limit.

Cloning of package

After performing a git clone:

  1. This assumes that you have a suitable node version installed. If you don't already have yarn installed globally:
npm install -g yarn
  1. Remove the line "packageManager": "[email protected]" and the preceding comma in package.json
  2. Remove the line yarnPath: .yarn/releases/yarn-4.12.0.cjs from .yarnrc.yml
yarn set version 4.12.0
yarn --immutable

Running of example

  1. If you don't already have @quasar/cli installed globally
npm install -g @quasar/cli
cd example
yarn workspaces focus
yarn dev

Usage

AICompareCandidates.compareCandidates<Candidate>({
	candidates,
	problemDescription='',
	generateSearchAreasInstruction=this.defaultGenerateSearchAreasInstruction.bind(this),
	parseSearchAreasResponse=this.defaultParseSearchAreasResponse.bind(this),
	convertCandidateToDocument=this.defaultConvertCandidateToDocument.bind(this),
	candidatesForInitialSelection=2,
	candidatesForFinalSelection=1,
	generateRankingInstruction=this.defaultGenerateRankingInstruction.bind(this),
	extractIdentifiersFromRationale=this.defaultExtractIdentifiersFromRationale.bind(this),
	extractIdentifierFromCandidateDocument=this.defaultExtractIdentifierFromCandidateDocument.bind(this),
	candidateIdentifierField=undefined,
	findCandidateFromIdentifier=this.defaultFindCandidateFromIdentifier.bind(this),
	getSummarisableSubstringIndices,
	generatePromptTemplate=this.defaultGeneratePromptTemplate.bind(this),
	skipRationale=false
}:AICompareCandidates.CompareArguments<Candidate>=<AICompareCandidates.CompareArguments<Candidate>>{}):Promise<AICompareCandidates.CompareCandidatesReturn<Candidate>|void>

candidates: Candidate objects as you define them

problemDescription: The prompt for description of the problem, i.e. how you would like the AI model to select the candidates.

generateSearchAreasInstruction: A function for generating the instruction for determining the relevant subject areas to use to search the vector database.

parseSearchAreasResponse: A function to parse the search areas response returned by the generator.

convertCandidateToDocument: A function to convert a candidate object to a candidate document, i.e. a string, which can be embedded in the vector database.

candidatesForInitialSelection: The number of candidates which should be returned by the initial vector database search.

candidatesForFinalSelection: The number of candidates which should be finally selected by the text generation ranking model.

generateRankingInstruction: A function for generating the instruction for ranking the candidates returned by the initial vector database search.

extractIdentifiersFromRationale: A function for extracting the correct candidate object identifiers from the entire rationale generated by the ranking model.

extractIdentifierFromCandidateDocument: A function for extracting the correct candidate object identifier from a candidate document string.

candidateIdentifierField: The field in the candidate object which is used to identify it, e.g. name or ID number.

findCandidateFromIdentifier: A function for finding a candidate object from a provided identifier field.

getSummarisableSubstringIndices: A function for identifying the substring indices of a candidate document string which can be summarised by the summarisation model.

generatePromptTemplate: A function for generating the template for the prompt to the generator.

skipRationale: Whether to skip rationale generation.