fix(pkb): fix create KB and upload issues - remove simulated upload, fix department mapping, add upload modal

Fixed issues:
- Remove simulateUpload function from DashboardPage Step 3
- Map department to description field when creating KB
- Add upload modal in WorkspacePage knowledge assets tab
- Fix DocumentUpload import path (../../stores to ../stores)

Known issue: Dify API validation error during document upload (file uploaded but DB record failed, needs investigation)

Testing: KB creation works, upload dialog opens correctly
This commit is contained in:
2026-01-13 13:17:20 +08:00
parent d595037316
commit 4088275290
280 changed files with 4344 additions and 150 deletions

View File

@@ -1,36 +1,44 @@
/**
* RVW稿件审查模块 - 方法学评估服务
* @module rvw/services/methodologyService
*
* Phase 3.5.5 改造:使用 PromptService 替代文件读取
* - 支持灰度预览(调试者看 DRAFT普通用户看 ACTIVE
* - 三级容灾(数据库→缓存→兜底)
*/
import fs from 'fs/promises';
import path from 'path';
import { fileURLToPath } from 'url';
import { LLMFactory } from '../../../common/llm/adapters/LLMFactory.js';
import { ModelType } from '../../../common/llm/adapters/types.js';
import { logger } from '../../../common/logging/index.js';
import { prisma } from '../../../config/database.js';
import { getPromptService } from '../../../common/prompt/index.js';
import { MethodologyReview } from '../types/index.js';
import { parseJSONFromLLMResponse } from './utils.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Prompt文件路径
const PROMPT_PATH = path.join(__dirname, '../../../../prompts/review_methodology_system.txt');
/**
* 方法学评估
* @param text 稿件文本
* @param modelType 模型类型
* @param userId 用户ID用于灰度预览判断
* @returns 评估结果
*/
export async function reviewMethodology(
text: string,
modelType: ModelType = 'deepseek-v3'
modelType: ModelType = 'deepseek-v3',
userId?: string
): Promise<MethodologyReview> {
try {
// 1. 取系统Prompt
const systemPrompt = await fs.readFile(PROMPT_PATH, 'utf-8');
// 1. 从 PromptService 获取系统Prompt(支持灰度预览)
const promptService = getPromptService(prisma);
const { content: systemPrompt, isDraft } = await promptService.get(
'RVW_METHODOLOGY',
{},
{ userId }
);
if (isDraft) {
logger.info('[RVW:Methodology] 使用 DRAFT 版本 Prompt调试模式', { userId });
}
// 2. 构建消息
const messages = [
@@ -71,3 +79,4 @@ export async function reviewMethodology(