Commit 66405d43 by Archer Committed by GitHub

perf: llm.txt file (#4574)

* update doc

* update shell

* update husky

* update doc

* perf: llm.txt
parent 3196470e
......@@ -27,6 +27,7 @@ weight: 794
3. 路径组件支持配置最后一步是否可点击。
4. 知识库工具调用结果,自动补充图片域名。
5. Github action runner 升级成 unbuntu24
6. 去除飞书、公众号等三方渠道,回复时,可能前后多一个换行的问题。
## 🐛 修复
......
......@@ -7,7 +7,7 @@ toc: true
weight: 226
---
FastGPT 从 V4 版本开始采用新的交互方式来构建 AI 应用。使用了 Flow 节点编排(工作流)的方式来实现复杂工作流,提高可玩性和扩展性。但同时也提高了上手的门槛,有一定开发背景的用户使用起来会比较容易。
FastGPT 从 V4.0 版本开始采用新的交互方式来构建 AI 应用。使用了 Flow 节点编排(工作流)的方式来实现复杂工作流,提高可玩性和扩展性。但同时也提高了上手的门槛,有一定开发背景的用户使用起来会比较容易。
[查看视频教程](https://www.bilibili.com/video/BV1is421u7bQ/)
......
......@@ -7,7 +7,7 @@ const projectName = "FastGPT";
const projectDescription = "FastGPT 文档";
// 文档目录,使用相对路径
const docsDir = path.join(__dirname, '../../content/zh-cn/docs');
const docsDir = path.join(__dirname, './content/zh-cn/docs');
// 基础 URL
const baseUrl = "https://doc.fastgpt.cn/docs/";
......@@ -21,7 +21,7 @@ function getMdInfo(filePath) {
// 找到前置元数据的起始和结束位置
const startIndex = content.indexOf('---');
const endIndex = content.indexOf('---', startIndex + 3);
if (startIndex!== -1 && endIndex!== -1) {
if (startIndex !== -1 && endIndex !== -1) {
const frontMatterStr = content.slice(startIndex + 3, endIndex).trim();
// 使用 yaml 解析前置元数据
const frontMatter = yaml.load(frontMatterStr);
......@@ -47,6 +47,10 @@ function walkDir(dir) {
if (entry.isDirectory()) {
walkDir(entryPath);
} else if (entry.name.endsWith('.md')) {
if (entry.name === "_index.md") {
continue;
}
const relativePath = path.relative(docsDir, entryPath);
const sectionName = path.dirname(relativePath) || 'Home';
if (!llmsTxtContent.includes(`## ${sectionName}`)) {
......@@ -64,7 +68,7 @@ function walkDir(dir) {
walkDir(docsDir);
// 保存 llms.txt
const saveDir = path.join(__dirname, '../');
const saveDir = path.join(__dirname, './static');
if (!fs.existsSync(saveDir)) {
fs.mkdirSync(saveDir, { recursive: true });
}
......@@ -80,11 +84,15 @@ function collectMdContent(dir) {
if (entry.isDirectory()) {
collectMdContent(entryPath);
} else if (entry.name.endsWith('.md')) {
if (entry.name === "_index.md") {
continue;
}
const content = fs.readFileSync(entryPath, 'utf8');
// 找到前置元数据的起始和结束位置
const startIndex = content.indexOf('---');
const endIndex = content.indexOf('---', startIndex + 3);
if (startIndex!== -1 && endIndex!== -1) {
if (startIndex !== -1 && endIndex !== -1) {
const frontMatterStr = content.slice(startIndex + 3, endIndex).trim();
// 使用 yaml 解析前置元数据
const frontMatter = yaml.load(frontMatterStr);
......@@ -105,4 +113,3 @@ collectMdContent(docsDir);
// 保存 llms - full.txt
const llmsFullTxtSavePath = path.join(saveDir, 'llms-full.txt');
fs.writeFileSync(llmsFullTxtSavePath, llmsFullTxtContent, 'utf8');
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed. Click to expand it.
......@@ -6,6 +6,7 @@
"prepare": "husky install",
"format-code": "prettier --config \"./.prettierrc.js\" --write \"./**/src/**/*.{ts,tsx,scss}\"",
"format-doc": "zhlint --dir ./docSite *.md --fix",
"gen:llms": "node ./docSite/doc-generate-llms.js",
"gen:theme-typings": "chakra-cli tokens packages/web/styles/theme.ts --out node_modules/.pnpm/node_modules/@chakra-ui/styled-system/dist/theming.types.d.ts",
"postinstall": "pnpm gen:theme-typings",
"initIcon": "node ./scripts/icon/init.js",
......@@ -31,7 +32,7 @@
},
"lint-staged": {
"./**/**/*.{ts,tsx,scss}": "npm run format-code",
"./docSite/**/**/*.md": "npm run format-doc"
"./docSite/**/**/*.md": "npm run format-doc && npm run gen:llms"
},
"resolutions": {
"mdast-util-gfm-autolink-literal": "2.0.0"
......@@ -39,10 +40,5 @@
"engines": {
"node": ">=18.16.0",
"pnpm": ">=9.0.0"
},
"husky": {
"hooks": {
"pre-commit": "node docSite/static/js/doc-generate-llms.js"
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment