079project 8.0.0 → 9.1.0
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/LICENSE +165 -0
- package/README.en.md +81 -1
- package/README.md +85 -1
- package/Redis-8.0.3-Windows-x64-cygwin-with-Service/dump.rdb +0 -0
- package/groupWorker.cjs +253 -0
- package/inferenceWorker.cjs +94 -0
- package/main.cjs +1263 -173
- package/mainFailedOfJing1Xi4Hua4Zhi4Duan3Yu3.cjs +6320 -0
- package/optimization.cjs +720 -0
- package/package.json +3 -2
- package/test_automatic/answer.csv +401 -0
- package/test_automatic/generate_daily_qa.py +645 -0
- package/test_automatic/question.csv +401 -0
- package/test_automatic.cjs +441 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// 复用主实现(不会触发 bootstrap,因为主文件有 require.main 守护)
|
|
4
|
+
const core = require('./main.cjs');
|
|
5
|
+
|
|
6
|
+
const { LmdbStore, NamespacedStore, RuntimeState } = core;
|
|
7
|
+
|
|
8
|
+
const baseStoresCache = new Map(); // key -> { kvmStore, memeStore, sessionStore, config }
|
|
9
|
+
const runtimeCache = new Map(); // controllerName -> RuntimeState
|
|
10
|
+
|
|
11
|
+
const parseControllerName = (controllerName) => {
|
|
12
|
+
const name = String(controllerName || '').trim();
|
|
13
|
+
// expected: G1_AI3
|
|
14
|
+
const m = /^(G\d+)_AI(\d+)$/i.exec(name);
|
|
15
|
+
if (!m) {
|
|
16
|
+
return { groupId: 'G1', groupIndex: 1 };
|
|
17
|
+
}
|
|
18
|
+
return { groupId: String(m[1]).toUpperCase(), groupIndex: Math.max(1, Number(m[2]) || 1) };
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const getBaseStores = (config) => {
|
|
22
|
+
const lmdbRoot = config?.lmdbRoot;
|
|
23
|
+
const mapSizeBytes = config?.lmdbMapSizeBytes;
|
|
24
|
+
const key = `${lmdbRoot}|${mapSizeBytes}`;
|
|
25
|
+
if (baseStoresCache.has(key)) {
|
|
26
|
+
return baseStoresCache.get(key);
|
|
27
|
+
}
|
|
28
|
+
if (!lmdbRoot) {
|
|
29
|
+
throw new Error('missing-lmdbRoot');
|
|
30
|
+
}
|
|
31
|
+
const kvmStore = new LmdbStore({ name: 'kvm', rootDir: lmdbRoot, mapSizeBytes });
|
|
32
|
+
const memeStore = new LmdbStore({ name: 'meme_graph', rootDir: lmdbRoot, mapSizeBytes });
|
|
33
|
+
const sessionStore = new LmdbStore({ name: 'session', rootDir: lmdbRoot, mapSizeBytes });
|
|
34
|
+
const out = { kvmStore, memeStore, sessionStore, config };
|
|
35
|
+
baseStoresCache.set(key, out);
|
|
36
|
+
return out;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const getRuntime = ({ controllerName, config }) => {
|
|
40
|
+
const name = String(controllerName || '').trim();
|
|
41
|
+
if (!name) throw new Error('missing-controllerName');
|
|
42
|
+
if (runtimeCache.has(name)) {
|
|
43
|
+
return runtimeCache.get(name);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const base = getBaseStores(config);
|
|
47
|
+
const { groupId, groupIndex } = parseControllerName(name);
|
|
48
|
+
|
|
49
|
+
// 与 ControllerPool 的命名空间保持一致:${groupId}:kvm / ${groupId}:graph / ${groupId}:session
|
|
50
|
+
const sharedStores = {
|
|
51
|
+
kvmStore: new NamespacedStore(base.kvmStore, `${groupId}:kvm`),
|
|
52
|
+
memeStore: new NamespacedStore(base.memeStore, `${groupId}:graph`),
|
|
53
|
+
sessionStore: new NamespacedStore(base.sessionStore, `${groupId}:session`)
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const stores = {
|
|
57
|
+
...base,
|
|
58
|
+
...sharedStores,
|
|
59
|
+
config: { ...(config || {}), controllerName: name, groupId, groupIndex }
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const runtime = new RuntimeState(stores);
|
|
63
|
+
runtimeCache.set(name, runtime);
|
|
64
|
+
return runtime;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const respond = ({ controllerName, payload, config } = {}) => {
|
|
68
|
+
const runtime = getRuntime({ controllerName, config });
|
|
69
|
+
return runtime.processInput(payload || {});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
process.on('message', (msg) => {
|
|
73
|
+
if (!msg || typeof msg !== 'object') return;
|
|
74
|
+
const { id, cmd } = msg;
|
|
75
|
+
if (!id) return;
|
|
76
|
+
if (cmd !== 'respond') {
|
|
77
|
+
try {
|
|
78
|
+
process.send({ id, ok: false, error: 'unknown-cmd' });
|
|
79
|
+
} catch (_e) {
|
|
80
|
+
// ignore
|
|
81
|
+
}
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
const result = respond(msg);
|
|
86
|
+
process.send({ id, ok: true, result });
|
|
87
|
+
} catch (e) {
|
|
88
|
+
try {
|
|
89
|
+
process.send({ id, ok: false, error: e?.message || String(e) });
|
|
90
|
+
} catch (_e) {
|
|
91
|
+
// ignore
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|