feat(AI服务):lpt-ai 独立服务初始版本
- Fastify + TypeScript,OpenAI 兼容接口对接 SiliconFlow - POST /ai/aggregate-report:残片聚合为学习报告(支持预期对比) - POST /ai/generate-mind-map:生成思维导图缩进大纲(与后端解析格式一致) - Key 从环境变量读取且日志脱敏,未配置时返回 503 由调用方降级 - prompt 模板集中管理,vitest 单元测试
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import Fastify from "fastify";
|
||||
import { aiRoutes } from "./routes/ai.js";
|
||||
|
||||
const app = Fastify({
|
||||
logger: {
|
||||
level: "info",
|
||||
redact: ["req.headers.authorization"], // 永不记录密钥
|
||||
},
|
||||
});
|
||||
|
||||
await app.register(aiRoutes);
|
||||
|
||||
const port = Number(process.env.PORT ?? 5199);
|
||||
|
||||
try {
|
||||
await app.listen({ port, host: "0.0.0.0" });
|
||||
app.log.info(`lpt-ai 服务已启动,端口 ${port}`);
|
||||
} catch (err) {
|
||||
app.log.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user