diff --git a/api/modules/ai/routes.ts b/api/modules/ai/routes.ts index 83a39db..fc90237 100644 --- a/api/modules/ai/routes.ts +++ b/api/modules/ai/routes.ts @@ -1,16 +1,13 @@ import express, { type Request, type Response } from 'express' import { spawn } from 'child_process' import path from 'path' -import { fileURLToPath } from 'url' import fs from 'fs/promises' import fsSync from 'fs' import { asyncHandler } from '../../utils/asyncHandler.js' import { successResponse } from '../../utils/response.js' import { resolveNotebookPath } from '../../utils/pathSafety.js' import { ValidationError, NotFoundError, InternalError } from '../../../shared/errors/index.js' - -const __filename = fileURLToPath(import.meta.url) -const __dirname = path.dirname(__filename) +import { PROJECT_ROOT } from '../../config/paths.js' const router = express.Router() @@ -89,8 +86,7 @@ router.post( const content = await fs.readFile(fullPath, 'utf-8') - const projectRoot = path.resolve(__dirname, '..', '..', '..') - const scriptPath = path.join(projectRoot, 'tools', 'doubao', 'main.py') + const scriptPath = path.join(PROJECT_ROOT, 'tools', 'doubao', 'main.py') if (!fsSync.existsSync(scriptPath)) { throw new InternalError(`Python script not found: ${scriptPath}`)