https://github.com/0verread/closecall
a lightweight npm package to keep llm calls within the relevant keywords.
https://github.com/0verread/closecall
Last synced: about 1 year ago
JSON representation
a lightweight npm package to keep llm calls within the relevant keywords.
- Host: GitHub
- URL: https://github.com/0verread/closecall
- Owner: 0verread
- License: mit
- Created: 2024-07-15T18:26:30.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-21T19:49:40.000Z (almost 2 years ago)
- Last Synced: 2025-06-06T03:06:15.382Z (about 1 year ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/closecall
- Size: 70.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## closecall
a lightweight npm package to keep llm calls within the relevant keywords.
### Use case
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.
### Usage
1. Install the package
```bash
npm i closecall
```
```js
import 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)
}
```
### License
under [MIT](LICENSE) License