ACT丶流星雨 63539bb867 修正命名
2026-03-28 17:47:02 +08:00

36 lines
1.3 KiB
TypeScript
Raw 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.

import express from "express";
import u from "@/utils";
import { z } from "zod";
import { success, error } from "@/lib/responseFormat";
import { validateFields } from "@/middleware/middleware";
import fs from "fs/promises";
import path from "path";
const router = express.Router();
const resolveSkillFilePath = (type: string, relativePath: string) => {
const normalizedPath = (relativePath || "").replace(/\\/g, "/");
const isPrefixedReferencePath = normalizedPath.startsWith("references/");
if (type === "references" && !isPrefixedReferencePath) {
return path.join(u.getPath(["skills", "references"]), normalizedPath);
}
return path.join(u.getPath("skills"), normalizedPath);
};
export default router.post(
"/",
validateFields({
content: z.string(),
}),
async (req, res) => {
const { content } = req.body;
const result = await u.Ai.Text("universalAi").invoke({
system:
"你是一个文档摘要助手。根据给定的文档内容生成一句简洁的中文描述不超过100字概括文档的核心主题和用途。只输出描述文本不要添加任何前缀或格式。",
messages: [{ role: "user", content: `内容:\n${content}` }],
});
const description = result.text.trim();
res.status(200).send(success(description));
},
);