fix-regex.js 728 B

12345678910111213141516171819202122
  1. const fs = require('fs');
  2. const file = 'src/modules/book-generator/langgraph-generator.ts';
  3. let content = fs.readFileSync(file, 'utf8');
  4. // 修复第790行的正则表达式问题
  5. const old = ` // 移除 <think>...</think> 标签
  6. const thinkMatch = cleanedStr.match(/</think>([\\s\\S]*)/);
  7. if (thinkMatch) {
  8. cleanedStr = thinkMatch[1].trim();
  9. }`;
  10. const new_ = ` // 移除思考标签(使用字符串查找)
  11. const thinkEndIdx = cleanedStr.indexOf('>>>>>>>');
  12. if (thinkEndIdx !== -1) {
  13. cleanedStr = cleanedStr.substring(thinkEndIdx + 8).trim();
  14. }`;
  15. content = content.replace(old, new_);
  16. fs.writeFileSync(file, content, 'utf8');
  17. console.log('✅ 已修复正则表达式问题');