@kelceyp/caw-server 1.0.211 → 1.0.213
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/dist/caw-stub.js +4 -0
- package/dist/embedding-worker.js +7 -14
- package/dist/main.js +356 -353
- package/dist/public_html/coffee-cup.png +0 -0
- package/dist/public_html/coffee-illustration.png +0 -0
- package/dist/public_html/main.js +387 -369
- package/dist/public_html/styles.css +1 -1
- package/package.json +2 -2
package/dist/caw-stub.js
ADDED
package/dist/embedding-worker.js
CHANGED
|
@@ -21,15 +21,8 @@
|
|
|
21
21
|
|
|
22
22
|
import { createInterface } from 'readline';
|
|
23
23
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
const formatTimestamp = () => {
|
|
27
|
-
const now = new Date();
|
|
28
|
-
const h = now.getHours();
|
|
29
|
-
const ampm = h >= 12 ? 'pm' : 'am';
|
|
30
|
-
const h12 = h % 12 || 12;
|
|
31
|
-
return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}` +
|
|
32
|
-
` ${pad(h12)}:${pad(now.getMinutes())}:${pad(now.getSeconds())}.${pad3(now.getMilliseconds())} ${ampm}`;
|
|
24
|
+
const logStderr = (level, msg) => {
|
|
25
|
+
process.stderr.write(JSON.stringify({ level, msg }) + '\n');
|
|
33
26
|
};
|
|
34
27
|
|
|
35
28
|
const MODEL_NAME = process.env.EMBEDDING_MODEL || 'nomic-ai/nomic-embed-text-v1.5';
|
|
@@ -61,17 +54,17 @@ const run = async () => {
|
|
|
61
54
|
},
|
|
62
55
|
progress_callback: (progress) => {
|
|
63
56
|
if (progress.status === 'download') {
|
|
64
|
-
|
|
57
|
+
logStderr('debug', `Downloading: ${progress.file} (${Math.round((progress.loaded / progress.total) * 100)}%)`);
|
|
65
58
|
} else if (progress.status === 'ready') {
|
|
66
59
|
const suffix = progress.file ? `: ${progress.file}` : '';
|
|
67
|
-
|
|
60
|
+
logStderr('debug', `Ready${suffix}`);
|
|
68
61
|
}
|
|
69
62
|
}
|
|
70
63
|
});
|
|
71
64
|
|
|
72
65
|
// Log loaded model details and baseline memory
|
|
73
66
|
const rss = Math.round(process.memoryUsage().rss / 1024 / 1024);
|
|
74
|
-
|
|
67
|
+
logStderr('info', `Model loaded. RSS: ${rss}MB`);
|
|
75
68
|
|
|
76
69
|
sendLine({ ready: true });
|
|
77
70
|
} catch (err) {
|
|
@@ -116,7 +109,7 @@ const run = async () => {
|
|
|
116
109
|
try {
|
|
117
110
|
output = await pipe(texts, paddingOptions);
|
|
118
111
|
} catch (_paddingErr) {
|
|
119
|
-
|
|
112
|
+
logStderr('warn', 'padding options unsupported, retrying without padding');
|
|
120
113
|
output = await pipe(texts, { pooling: 'mean', normalize: false });
|
|
121
114
|
}
|
|
122
115
|
} else {
|
|
@@ -126,7 +119,7 @@ const run = async () => {
|
|
|
126
119
|
embedCallCount++;
|
|
127
120
|
const embedRss = Math.round(process.memoryUsage().rss / 1024 / 1024);
|
|
128
121
|
const shapeStr = maxLength !== undefined ? `[${texts.length}×${maxLength}]` : `[${texts.length}×var]`;
|
|
129
|
-
|
|
122
|
+
logStderr('debug', `Embed #${embedCallCount}: shape=${shapeStr}, RSS: ${embedRss}MB`);
|
|
130
123
|
sendLine({ vectors });
|
|
131
124
|
} catch (err) {
|
|
132
125
|
sendLine({ error: `Embedding failed: ${err.message}` });
|