feat: Add curated expert occupations with local data sources

- Add curated occupations seed files (210 entries in zh/en) with specific domains
- Add DBpedia occupations data (2164 entries) for external source option
- Refactor expert_source_service to read from local JSON files
- Improve keyword generation prompts to leverage expert domain context
- Add architecture analysis documentation (ARCHITECTURE_ANALYSIS.md)
- Fix expert source selection bug (proper handling of empty custom_experts)
- Update frontend to support curated/dbpedia/wikidata expert sources

Key changes:
- backend/app/data/: Local occupation data files
- backend/app/services/expert_source_service.py: Simplified local file reading
- backend/app/prompts/expert_transformation_prompt.py: Better domain-aware prompts
- Removed expert_cache.py (no longer needed with local files)

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-04 16:34:35 +08:00
parent 8777e27cbb
commit 5571076406
15 changed files with 9970 additions and 380 deletions

View File

@@ -53,19 +53,32 @@ def get_expert_keyword_generation_prompt(
keywords_per_expert: int = 1
) -> str:
"""Step 1: 專家視角關鍵字生成"""
experts_info = ", ".join([f"{exp['id']}:{exp['name']}({exp['domain']})" for exp in experts])
# 建立專家列表,格式更清晰
experts_list = "\n".join([f"- {exp['id']}: {exp['name']}" for exp in experts])
return f"""/no_think
專家團隊:{experts_info}
屬性:「{attribute}」({category}
你需要扮演以下專家,為屬性生成創新關鍵字:
每位專家從自己的專業視角為此屬性生成 {keywords_per_expert} 個創新關鍵字2-6字
關鍵字要反映該專家領域的獨特思考方式。
【專家名單】
{experts_list}
【任務】
屬性:「{attribute}」(類別:{category}
請為每位專家:
1. 先理解該職業的專業背景、知識領域、工作內容
2. 從該職業的獨特視角思考「{attribute}
3. 生成 {keywords_per_expert} 個與該專業相關的創新關鍵字2-6字
關鍵字必須反映該專家的專業思維方式,例如:
- 會計師 看「移動」→「資金流動」「成本效益」
- 建築師 看「移動」→「動線設計」「空間流動」
- 心理師 看「移動」→「行為動機」「情緒轉變」
回傳 JSON
{{"keywords": [{{"keyword": "詞彙", "expert_id": "expert-X", "expert_name": "名稱"}}, ...]}}
共需 {len(experts) * keywords_per_expert} 個關鍵字。"""
共需 {len(experts) * keywords_per_expert} 個關鍵字,每個關鍵字必須明顯與對應專家的專業領域相關"""
def get_single_description_prompt(
@@ -76,12 +89,17 @@ def get_single_description_prompt(
expert_domain: str
) -> str:
"""Step 2: 為單一關鍵字生成描述"""
# 如果 domain 是通用的,就只用職業名稱
domain_text = f"{expert_domain}" if expert_domain and expert_domain != "Professional Field" else ""
return f"""/no_think
物件:「{query}
專家:{expert_name}{expert_domain}
專家:{expert_name}{domain_text}
關鍵字:{keyword}
從這位專家的視角生成一段創新應用描述15-30字說明如何將「{keyword}」的概念應用到「{query}」上。
你是一位{expert_name}。從你的專業視角生成一段創新應用描述15-30字說明如何將「{keyword}」的概念應用到「{query}」上。
描述要體現{expert_name}的專業思維和獨特觀點。
回傳 JSON
{{"description": "應用描述"}}"""