backup: 完成 HR_position_ 表格前綴重命名與欄位對照表整理

變更內容:
- 所有資料表加上 HR_position_ 前綴
- 整理完整欄位顯示名稱與 ID 對照表
- 模組化 JS 檔案 (admin.js, ai.js, csv.js 等)
- 專案結構優化 (docs/, scripts/, tests/ 等)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-09 12:05:20 +08:00
parent a068ef9704
commit a6af297623
82 changed files with 8685 additions and 4933 deletions

View File

@@ -59,8 +59,14 @@ export async function callClaudeAPI(prompt, api = 'ollama') {
// 清理 JSON 代碼塊標記和其他格式
let responseText = data.text;
// 移除 DeepSeek-R1 等模型的思考標籤 <think>...</think>
responseText = responseText.replace(/<think>[\s\S]*?<\/think>/gi, '');
// 移除 Markdown 代碼塊標記
responseText = responseText.replace(/```json\n?/g, '').replace(/```\n?/g, '').trim();
responseText = responseText.replace(/```json\n?/gi, '').replace(/```\n?/g, '').trim();
// 移除可能的前導文字(如 "Here is the JSON:" 等)
responseText = responseText.replace(/^[\s\S]*?(?=\{)/i, '');
// 嘗試提取 JSON 內容(如果包含其他文字)
// 查找第一個 { 和最後一個 }
@@ -77,7 +83,18 @@ export async function callClaudeAPI(prompt, api = 'ollama') {
} catch (parseError) {
// JSON 解析失敗,拋出更詳細的錯誤
console.error('JSON 解析失敗,原始響應:', responseText);
throw new Error(`LLM 返回的內容不是有效的 JSON 格式。\n\n原始響應前 200 字符:\n${responseText.substring(0, 200)}...`);
// 嘗試修復常見的 JSON 問題
try {
// 移除控制字符
const cleanedText = responseText
.replace(/[\x00-\x1F\x7F]/g, '') // 移除控制字符
.replace(/,\s*}/g, '}') // 移除末尾逗號
.replace(/,\s*]/g, ']'); // 移除陣列末尾逗號
return JSON.parse(cleanedText);
} catch (retryError) {
throw new Error(`LLM 返回的內容不是有效的 JSON 格式。\n\n原始響應前 300 字符:\n${responseText.substring(0, 300)}...`);
}
}
} catch (error) {
console.error('Error calling LLM API:', error);