@deepsweet/mdn 0.1.1 → 0.1.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 +1 -1
- package/dist/index.js +22 -3
- package/package.json +4 -9
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ See [dataset repo](https://huggingface.co/datasets/deepsweet/mdn) on HuggigFace
|
|
|
22
22
|
### 1. Download dataset and embedding model
|
|
23
23
|
|
|
24
24
|
```sh
|
|
25
|
-
npx @deepsweet/mdn download
|
|
25
|
+
npx -y @deepsweet/mdn download
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
Both [dataset](https://huggingface.co/datasets/deepsweet/mdn) (\~260 MB) and the [embedding model GGUF file](https://huggingface.co/deepsweet/bge-m3-GGUF-Q4_K_M) (\~438 MB) will be downloaded directly from HugginFace and stored in its default cache location (typically `~/.cache/huggingface/`), just like the `hf download` command does.
|
package/dist/index.js
CHANGED
|
@@ -95,16 +95,19 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
95
95
|
import { z as z2 } from "zod";
|
|
96
96
|
|
|
97
97
|
// src/llama.ts
|
|
98
|
-
import { getLlama } from "node-llama-cpp";
|
|
98
|
+
import { getLlama, LlamaLogLevel } from "node-llama-cpp";
|
|
99
99
|
var MAX_TOKENS = 8192;
|
|
100
100
|
var getLlamaContext = async (modelPath) => {
|
|
101
|
-
const llama = await getLlama();
|
|
101
|
+
const llama = await getLlama({ logLevel: LlamaLogLevel.error });
|
|
102
102
|
const model = await llama.loadModel({ modelPath });
|
|
103
103
|
const context = await model.createEmbeddingContext({
|
|
104
104
|
contextSize: MAX_TOKENS,
|
|
105
105
|
batchSize: MAX_TOKENS,
|
|
106
106
|
threads: 0
|
|
107
107
|
});
|
|
108
|
+
context.onDispose.createOnceListener(() => {
|
|
109
|
+
model.dispose().then(() => llama.dispose()).catch(console.error);
|
|
110
|
+
});
|
|
108
111
|
return context;
|
|
109
112
|
};
|
|
110
113
|
|
|
@@ -131,7 +134,7 @@ var createReranker = async () => {
|
|
|
131
134
|
|
|
132
135
|
// package.json
|
|
133
136
|
var name = "@deepsweet/mdn";
|
|
134
|
-
var version = "0.1.
|
|
137
|
+
var version = "0.1.3";
|
|
135
138
|
|
|
136
139
|
// src/server.ts
|
|
137
140
|
var startMcpServer = async () => {
|
|
@@ -171,6 +174,22 @@ var startMcpServer = async () => {
|
|
|
171
174
|
};
|
|
172
175
|
});
|
|
173
176
|
const transport = new StdioServerTransport;
|
|
177
|
+
const dispose = async () => {
|
|
178
|
+
if (llamaTimeout !== null) {
|
|
179
|
+
clearTimeout(llamaTimeout);
|
|
180
|
+
}
|
|
181
|
+
if (llamaContext !== null) {
|
|
182
|
+
await llamaContext.dispose();
|
|
183
|
+
}
|
|
184
|
+
db.close();
|
|
185
|
+
await server.close();
|
|
186
|
+
};
|
|
187
|
+
transport.onclose = () => {
|
|
188
|
+
dispose().catch(console.error);
|
|
189
|
+
};
|
|
190
|
+
transport.onerror = (err) => {
|
|
191
|
+
console.log(err);
|
|
192
|
+
};
|
|
174
193
|
await server.connect(transport);
|
|
175
194
|
};
|
|
176
195
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepsweet/mdn",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -14,26 +14,21 @@
|
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@huggingface/hub": "^2.11.0",
|
|
17
|
-
"@lancedb/lancedb": "0.27.2
|
|
17
|
+
"@lancedb/lancedb": "^0.27.2",
|
|
18
18
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
19
19
|
"apache-arrow": "18.1.0",
|
|
20
20
|
"node-llama-cpp": "^3.18.1",
|
|
21
21
|
"zod": "^4.3.6"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@stylistic/eslint-plugin": "^5.10.0",
|
|
24
|
+
"@deepsweet/eslint-config": "^0.1.0",
|
|
26
25
|
"@types/bun": "^1.3.11",
|
|
27
26
|
"dedent": "^1.7.2",
|
|
28
27
|
"eslint": "^10.1.0",
|
|
29
|
-
"eslint-plugin-import": "^2.32.0",
|
|
30
|
-
"eslint-plugin-perfectionist": "^5.7.0",
|
|
31
|
-
"globals": "^17.4.0",
|
|
32
28
|
"gray-matter": "^4.0.3",
|
|
33
29
|
"marked": "^17.0.5",
|
|
34
30
|
"rimraf": "^6.1.3",
|
|
35
|
-
"typescript": "^6.0.2"
|
|
36
|
-
"typescript-eslint": "^8.58.0"
|
|
31
|
+
"typescript": "^6.0.2"
|
|
37
32
|
},
|
|
38
33
|
"scripts": {
|
|
39
34
|
"chunk": "bun scripts/chunk.ts",
|