a lightweight npm package to keep llm calls within the relevant keywords.
AI-powered chatbots can be abused with irrelevant queries, making LLM cost higher and expensive. Use this simple package to keep your LLM calls within relevant keywords.
- Install the package
npm i closecallimport isPromptRelevant from "closecall";
const keywords = ["Soccer", "game", "summer", "play"]
var prompt = "I want to play soccer";
const MakeAPICall = async () => {
const isRelevant = await isPromptRelevant(prompt, keywords);
if(!isRelevant) {
throw new Error("Can't make API call with irrelevant prompt");
} else {
// make api call
}
console.log(isRelevant)
}under MIT License