Files
woniu336 141ed9f4a8 feat(llm): DeepSeek Flash + 思考模式;本地密钥加载器
- llm_profiles 增加 thinking / reasoning_effort(migrations/0002),
  ensureD1Schema 容忍 ALTER 重复列,已有库平滑升级
- /api/read 按 profile 组装 thinking / reasoning_effort;只转发 delta.content,
  思考链 reasoning_content 不下发;max_tokens 4096
- 后台 LLM 表单新增「思考模式」「思考强度」,列表显示当前设置;测试连通沿用同一配置
- scripts/load-secrets.mjs:启动前读取 .llm.local(gitignore),
  dev / dev:bg / dev:vinext / build:vinext / start:vinext 共用
- 解卦面板显示「研墨中 · Ns」,思考模式首字慢时有提示
- 新增 llm-request 纯函数与 4 项测试;总 68 项测试通过

本地实测:DeepSeek Flash + thinking=high,/api/read 约 23s、840 字、四段齐全;
UI 4 标题/5 段、0 错误。密钥仅存于 .llm.local(不进仓库/D1)。
2026-11-05 14:36:38 +08:00

47 lines
1.5 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
/**
* vinext/vite 启动器(Node 侧)。
*
* 做两件事:
* 1. 读取本地密钥文件 `.llm.local`(gitignore),补齐 process.env;
* vinext 的 cloudflare.config.ts 在 Node 侧执行,会把这里的变量映射成文本绑定,
* nodejs_compat 再映射到 workerd 的 process.env。
* 2. 清掉宿主泄漏的 `__NEXT_PRIVATE_*`(否则 dev/build 会被当成 standalone 配置)。
*
* node scripts/vinext.mjs dev --port 3001 --strictPort
* node scripts/vinext.mjs build
* node scripts/vinext.mjs preview --port 4173
*/
import { spawn } from 'node:child_process';
import path from 'node:path';
import process from 'node:process';
import { fileURLToPath } from 'node:url';
import { loadLocalSecrets } from './load-secrets.mjs';
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
loadLocalSecrets(projectRoot);
const env = { ...process.env };
for (const key of Object.keys(env)) {
if (key.startsWith('__NEXT_PRIVATE_')) delete env[key];
}
const args = process.argv.slice(2);
const viteBin = path.join(projectRoot, 'node_modules', 'vite', 'bin', 'vite.js');
const child = spawn(process.execPath, [viteBin, ...args], {
cwd: projectRoot,
env,
stdio: 'inherit',
windowsHide: true,
});
child.once('exit', (code, signal) => {
if (signal) process.kill(process.pid, signal);
else process.exit(code ?? 0);
});
child.once('error', (err) => {
console.error(`[vinext] 启动失败:${err.message}`);
process.exit(1);
});