npm.io
1.0.8 • Published yesterday

@overandoutnerd/dumbledore-bot-core

Licence
MIT
Version
1.0.8
Deps
1
Size
32.0 MB
Vulns
0
Weekly
7

Dumbledore Bot Core

A TypeScript library for searching and retrieving Albus Dumbledore quotes using semantic similarity powered by Gemini embeddings.

The package includes:

  • Dumbledore quote dataset
  • Dumbledore GIF dataset
  • Precomputed quote embeddings
  • Semantic quote search
  • Random quote selection
  • Random GIF selection

Installation

npm install @overandoutnerd/dumbledore-bot-core

Requirements

  • Node.js 18+
  • Gemini API key

Usage

Get a Relevant Quote
import {
    getRelevantQuote,
} from "@overandoutnerd/dumbledore-bot-core";

const quote =
    await getRelevantQuote(
        "dumbledore, is sirius innocent?",
        process.env.GEMINI_API_KEY!,
    );

console.log(quote);
Get Top Matches
import {
    getTopMatches,
} from "@overandoutnerd/dumbledore-bot-core";

const matches =
    await getTopMatches(
        "tell me about sirius black",
        process.env.GEMINI_API_KEY!,
        5,
    );

console.log(matches);

Example output:

[
    {
        text: "Sirius has not acted like an innocent man.",
        score: 0.82,
    },
]
Get a Random Quote
import {
    getRandomQuote,
} from "@overandoutnerd/dumbledore-bot-core";

const quote =
    getRandomQuote();

console.log(quote);
Get a Random GIF
import {
    getRandomGif,
} from "@overandoutnerd/dumbledore-bot-core";

const gifUrl =
    getRandomGif();

console.log(gifUrl);
Access All Quotes
import {
    QUOTES,
} from "@overandoutnerd/dumbledore-bot-core";

console.log(
    QUOTES.length,
);
Access All GIFs
import {
    GIFS,
} from "@overandoutnerd/dumbledore-bot-core";

console.log(
    GIFS.length,
);

API

getRelevantQuote

Returns a semantically relevant quote.

getRelevantQuote(
    message: string,
    apiKey: string,
): Promise<string>
getTopMatches

Returns the highest-scoring quote matches.

getTopMatches(
    message: string,
    apiKey: string,
    limit?: number,
): Promise<QuoteMatch[]>
getRandomQuote

Returns a random quote.

getRandomQuote(): string
getRandomGif

Returns a random GIF URL.

getRandomGif(): string
QUOTES

Array containing all quotes in the dataset.

const QUOTES: string[]
GIFS

Array containing all GIF URLs in the dataset.

const GIFS: string[]

License

MIT

Keywords