tt-help-cli-ycl 1.4.27 → 1.4.28
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/package.json +1 -1
- package/scripts/search-authors.mjs +21 -0
- package/scripts/sync-raw-jobs.mjs +450 -181
- package/src/cli/raw-sync.js +2 -5
- package/src/cli/search.js +160 -0
- package/src/lib/args.js +81 -8
- package/src/lib/constants.js +24 -5
- package/src/lib/search-collector.js +194 -0
- package/src/lib/target-locations.js +1 -0
- package/src/main.js +3 -0
- package/src/npm-main.js +3 -0
- package/src/watch/data-store.js +266 -577
- package/src/watch/db-columns.js +1 -0
- package/src/watch/db-crud.js +27 -3
- package/src/watch/db-raw-jobs.js +3 -3
- package/src/watch/db-schema.js +100 -0
- package/src/watch/db-stats.js +46 -23
- package/src/watch/db-tags.js +100 -1
- package/src/watch/llm-config.js +145 -1
- package/src/watch/llm-scoring.js +60 -117
- package/src/watch/public/app.js +5 -5
- package/src/watch/public/index.html +4 -5
- package/src/watch/public/style.css +16 -0
- package/src/watch/server.js +170 -59
- package/src/watch/tag-service.js +11 -67
package/src/watch/tag-service.js
CHANGED
|
@@ -35,74 +35,18 @@ export function getLang(country) {
|
|
|
35
35
|
// ====== LLM 调用 ======
|
|
36
36
|
|
|
37
37
|
export async function callLLM(prompt, temperature = 0.7) {
|
|
38
|
-
|
|
39
|
-
await import("./llm-config.js");
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
models[i] !== null
|
|
50
|
-
? models[i]
|
|
51
|
-
: (await import("./llm-config.js")).getLlmModel();
|
|
52
|
-
const { fetch } = await import("undici");
|
|
53
|
-
|
|
54
|
-
console.error(
|
|
55
|
-
`[callLLM] → ${url} model=${model} (${i + 1}/${models.length})`,
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
let response;
|
|
59
|
-
try {
|
|
60
|
-
response = await fetch(url, {
|
|
61
|
-
method: "POST",
|
|
62
|
-
headers: {
|
|
63
|
-
"Content-Type": "application/json",
|
|
64
|
-
Authorization: `Bearer ${apiKey}`,
|
|
65
|
-
},
|
|
66
|
-
body: JSON.stringify({
|
|
67
|
-
model,
|
|
68
|
-
messages: [{ role: "user", content: prompt }],
|
|
69
|
-
max_tokens: 1024,
|
|
70
|
-
temperature,
|
|
71
|
-
enable_thinking: false,
|
|
72
|
-
}),
|
|
73
|
-
});
|
|
74
|
-
} catch (e) {
|
|
75
|
-
lastError = e.message;
|
|
76
|
-
console.error(`[callLLM] ${model} 网络失败: ${e.message},尝试下一个`);
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const status = response.status;
|
|
81
|
-
const result = await response.json().catch(() => null);
|
|
82
|
-
|
|
83
|
-
if (status !== 200 || !result || !result.choices?.[0]?.message?.content) {
|
|
84
|
-
const errMsg = result?.error?.message || `HTTP ${status}`;
|
|
85
|
-
lastError = errMsg;
|
|
86
|
-
console.error(`[callLLM] ${model} 失败: ${errMsg},尝试下一个`);
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const content = result.choices[0].message.content;
|
|
91
|
-
if (i > 0) {
|
|
92
|
-
console.error(`[callLLM] ✅ auto 切换成功: ${model}`);
|
|
93
|
-
}
|
|
94
|
-
// 记录成功的模型,下次优先用它
|
|
95
|
-
if (isAutoMode()) {
|
|
96
|
-
const { recordAutoSuccess } = await import("./llm-config.js");
|
|
97
|
-
recordAutoSuccess(model);
|
|
98
|
-
}
|
|
99
|
-
return content;
|
|
38
|
+
try {
|
|
39
|
+
const { llmFetch } = await import("./llm-config.js");
|
|
40
|
+
return await llmFetch({
|
|
41
|
+
messages: [{ role: "user", content: prompt }],
|
|
42
|
+
max_tokens: 1024,
|
|
43
|
+
temperature,
|
|
44
|
+
enable_thinking: false,
|
|
45
|
+
});
|
|
46
|
+
} catch (e) {
|
|
47
|
+
console.error(`[callLLM] ${e.message}`);
|
|
48
|
+
return "";
|
|
100
49
|
}
|
|
101
|
-
|
|
102
|
-
console.error(
|
|
103
|
-
`[callLLM] ❌ 全部 ${models.length} 个模型均失败,最后错误: ${lastError}`,
|
|
104
|
-
);
|
|
105
|
-
return "";
|
|
106
50
|
}
|
|
107
51
|
|
|
108
52
|
export function normalizeTag(t) {
|