- Add random seed and diversity hints to expert generation prompt - Explicitly avoid common professions (醫生、工程師、教師、律師等) - Change description generation from batch to one-by-one for reliability - Increase default temperature from 0.7 to 0.95 for more creative output - Add description_progress SSE event for real-time feedback 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
88 lines
2.7 KiB
Python
88 lines
2.7 KiB
Python
"""Expert Transformation Agent 提示詞模組"""
|
||
|
||
from typing import List, Optional
|
||
|
||
|
||
def get_expert_generation_prompt(
|
||
query: str,
|
||
categories: List[str],
|
||
expert_count: int,
|
||
custom_experts: Optional[List[str]] = None
|
||
) -> str:
|
||
"""Step 0: 生成專家團隊(不依賴主題,純隨機多元)"""
|
||
import time
|
||
import random
|
||
|
||
custom_text = ""
|
||
if custom_experts and len(custom_experts) > 0:
|
||
custom_text = f"(已指定:{', '.join(custom_experts[:expert_count])})"
|
||
|
||
# 加入時間戳和隨機數來增加多樣性
|
||
seed = int(time.time() * 1000) % 10000
|
||
diversity_hints = [
|
||
"冷門、非主流、跨領域",
|
||
"罕見職業、新興領域、邊緣學科",
|
||
"非傳統、創新、小眾專業",
|
||
"未來趨向、實驗性、非常規",
|
||
"跨文化、混合領域、獨特視角"
|
||
]
|
||
hint = random.choice(diversity_hints)
|
||
|
||
return f"""/no_think
|
||
隨機組建 {expert_count} 個來自完全不同領域的專家團隊{custom_text}。
|
||
|
||
【創新要求】(隨機種子:{seed})
|
||
- 優先選擇{hint}的專家
|
||
- 避免常見職業(如醫生、工程師、教師、律師等)
|
||
- 每個專家必須來自完全不相關的領域
|
||
- 越罕見、越創新越好
|
||
|
||
回傳 JSON:
|
||
{{"experts": [{{"id": "expert-0", "name": "職業", "domain": "領域", "perspective": "角度"}}, ...]}}
|
||
|
||
規則:
|
||
- id 為 expert-0 到 expert-{expert_count - 1}
|
||
- name 填寫職業名稱(非人名),2-5字
|
||
- domain 要具體且獨特,不可重複類型"""
|
||
|
||
|
||
def get_expert_keyword_generation_prompt(
|
||
category: str,
|
||
attribute: str,
|
||
experts: List[dict], # List[ExpertProfile]
|
||
keywords_per_expert: int = 1
|
||
) -> str:
|
||
"""Step 1: 專家視角關鍵字生成"""
|
||
experts_info = ", ".join([f"{exp['id']}:{exp['name']}({exp['domain']})" for exp in experts])
|
||
|
||
return f"""/no_think
|
||
專家團隊:{experts_info}
|
||
屬性:「{attribute}」({category})
|
||
|
||
每位專家從自己的專業視角為此屬性生成 {keywords_per_expert} 個創新關鍵字(2-6字)。
|
||
關鍵字要反映該專家領域的獨特思考方式。
|
||
|
||
回傳 JSON:
|
||
{{"keywords": [{{"keyword": "詞彙", "expert_id": "expert-X", "expert_name": "名稱"}}, ...]}}
|
||
|
||
共需 {len(experts) * keywords_per_expert} 個關鍵字。"""
|
||
|
||
|
||
def get_single_description_prompt(
|
||
query: str,
|
||
keyword: str,
|
||
expert_id: str,
|
||
expert_name: str,
|
||
expert_domain: str
|
||
) -> str:
|
||
"""Step 2: 為單一關鍵字生成描述"""
|
||
return f"""/no_think
|
||
物件:「{query}」
|
||
專家:{expert_name}({expert_domain})
|
||
關鍵字:{keyword}
|
||
|
||
從這位專家的視角,生成一段創新應用描述(15-30字),說明如何將「{keyword}」的概念應用到「{query}」上。
|
||
|
||
回傳 JSON:
|
||
{{"description": "應用描述"}}"""
|