@overandoutnerd/dumbledore-bot-core 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +171 -5
- package/package.json +16 -3
package/README.md
CHANGED
|
@@ -1,14 +1,180 @@
|
|
|
1
1
|
# Dumbledore Bot Core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A TypeScript library for searching and retrieving Albus Dumbledore quotes using semantic similarity powered by Gemini embeddings.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
The package includes:
|
|
6
|
+
|
|
7
|
+
- Dumbledore quote dataset
|
|
8
|
+
- Dumbledore GIF dataset
|
|
9
|
+
- Precomputed quote embeddings
|
|
10
|
+
- Semantic quote search
|
|
11
|
+
- Random quote selection
|
|
12
|
+
- Random GIF selection
|
|
7
13
|
|
|
8
14
|
## Installation
|
|
9
15
|
|
|
10
|
-
|
|
16
|
+
```bash
|
|
17
|
+
npm install @overandoutnerd/dumbledore-bot-core
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- Node.js 18+
|
|
23
|
+
- Gemini API key
|
|
11
24
|
|
|
12
25
|
## Usage
|
|
13
26
|
|
|
14
|
-
|
|
27
|
+
### Get a Relevant Quote
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import {
|
|
31
|
+
getRelevantQuote,
|
|
32
|
+
} from "@overandoutnerd/dumbledore-bot-core";
|
|
33
|
+
|
|
34
|
+
const quote =
|
|
35
|
+
await getRelevantQuote(
|
|
36
|
+
"dumbledore, is sirius innocent?",
|
|
37
|
+
process.env.GEMINI_API_KEY!,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
console.log(quote);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Get Top Matches
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import {
|
|
47
|
+
getTopMatches,
|
|
48
|
+
} from "@overandoutnerd/dumbledore-bot-core";
|
|
49
|
+
|
|
50
|
+
const matches =
|
|
51
|
+
await getTopMatches(
|
|
52
|
+
"tell me about sirius black",
|
|
53
|
+
process.env.GEMINI_API_KEY!,
|
|
54
|
+
5,
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
console.log(matches);
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Example output:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
[
|
|
64
|
+
{
|
|
65
|
+
text: "Sirius has not acted like an innocent man.",
|
|
66
|
+
score: 0.82,
|
|
67
|
+
},
|
|
68
|
+
]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Get a Random Quote
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import {
|
|
75
|
+
getRandomQuote,
|
|
76
|
+
} from "@overandoutnerd/dumbledore-bot-core";
|
|
77
|
+
|
|
78
|
+
const quote =
|
|
79
|
+
getRandomQuote();
|
|
80
|
+
|
|
81
|
+
console.log(quote);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Get a Random GIF
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import {
|
|
88
|
+
getRandomGif,
|
|
89
|
+
} from "@overandoutnerd/dumbledore-bot-core";
|
|
90
|
+
|
|
91
|
+
const gifUrl =
|
|
92
|
+
getRandomGif();
|
|
93
|
+
|
|
94
|
+
console.log(gifUrl);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Access All Quotes
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
import {
|
|
101
|
+
QUOTES,
|
|
102
|
+
} from "@overandoutnerd/dumbledore-bot-core";
|
|
103
|
+
|
|
104
|
+
console.log(
|
|
105
|
+
QUOTES.length,
|
|
106
|
+
);
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Access All GIFs
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import {
|
|
113
|
+
GIFS,
|
|
114
|
+
} from "@overandoutnerd/dumbledore-bot-core";
|
|
115
|
+
|
|
116
|
+
console.log(
|
|
117
|
+
GIFS.length,
|
|
118
|
+
);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## API
|
|
122
|
+
|
|
123
|
+
### getRelevantQuote
|
|
124
|
+
|
|
125
|
+
Returns a semantically relevant quote.
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
getRelevantQuote(
|
|
129
|
+
message: string,
|
|
130
|
+
apiKey: string,
|
|
131
|
+
): Promise<string>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### getTopMatches
|
|
135
|
+
|
|
136
|
+
Returns the highest-scoring quote matches.
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
getTopMatches(
|
|
140
|
+
message: string,
|
|
141
|
+
apiKey: string,
|
|
142
|
+
limit?: number,
|
|
143
|
+
): Promise<QuoteMatch[]>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### getRandomQuote
|
|
147
|
+
|
|
148
|
+
Returns a random quote.
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
getRandomQuote(): string
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### getRandomGif
|
|
155
|
+
|
|
156
|
+
Returns a random GIF URL.
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
getRandomGif(): string
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### QUOTES
|
|
163
|
+
|
|
164
|
+
Array containing all quotes in the dataset.
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
const QUOTES: string[]
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### GIFS
|
|
171
|
+
|
|
172
|
+
Array containing all GIF URLs in the dataset.
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
const GIFS: string[]
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## License
|
|
179
|
+
|
|
180
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@overandoutnerd/dumbledore-bot-core",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Semantic Dumbledore quote search powered by Gemini embeddings",
|
|
5
|
+
"license": "MIT",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"main": "./dist/index.js",
|
|
7
8
|
"types": "./dist/index.d.ts",
|
|
8
9
|
"files": [
|
|
9
|
-
"dist"
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
10
12
|
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"dumbledore",
|
|
15
|
+
"harry-potter",
|
|
16
|
+
"quotes",
|
|
17
|
+
"semantic-search",
|
|
18
|
+
"embeddings",
|
|
19
|
+
"gemini",
|
|
20
|
+
"discord-bot",
|
|
21
|
+
"reddit-bot"
|
|
22
|
+
],
|
|
23
|
+
"author": "Abdul Lateef",
|
|
11
24
|
"scripts": {
|
|
12
25
|
"build": "tsc",
|
|
13
26
|
"prepublishOnly": "npm run build"
|