Skip to content

Commit 576cac3

Browse files
committed
fix: 默认工作未能正常计算向量
1 parent e8d12c0 commit 576cac3

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/lib/rag.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99

1010
// 重新导出initVectorDb,使其可在其他模块中导入
1111
export { initVectorDb };
12-
import { getWorkspacePath } from "./workspace";
12+
import { getFilePathOptions, getWorkspacePath } from "./workspace";
1313
import { DirTree } from "@/stores/article";
1414
import { toast } from "@/hooks/use-toast";
1515
import { join } from "@tauri-apps/api/path";
@@ -110,10 +110,14 @@ export async function processMarkdownFile(
110110
fileContent?: string
111111
): Promise<boolean> {
112112
try {
113-
// 如果未提供文件内容,则读取文件
114-
const content = fileContent || await readTextFile(filePath);
115-
116-
// 分块处理文本
113+
const workspace = await getWorkspacePath()
114+
let content = ''
115+
if (workspace.isCustom) {
116+
content = fileContent || await readTextFile(filePath)
117+
} else {
118+
const { path, baseDir } = await getFilePathOptions(filePath)
119+
content = fileContent || await readTextFile(path, { baseDir })
120+
}
117121
const chunks = chunkText(content);
118122

119123
// 文件名(不含路径)

0 commit comments

Comments
 (0)