chore: save local changes

This commit is contained in:
2026-01-05 22:32:08 +08:00
parent bc281b8e0a
commit ec48709755
42 changed files with 5576 additions and 254 deletions

View File

@@ -1,34 +1,68 @@
"""Expert Transformation Agent 提示詞模組"""
"""Expert Transformation Agent prompts module - Bilingual support"""
from typing import List, Optional
from .language_config import LanguageType
def get_expert_generation_prompt(
query: str,
categories: List[str],
expert_count: int,
custom_experts: Optional[List[str]] = None
custom_experts: Optional[List[str]] = None,
lang: LanguageType = "zh"
) -> str:
"""Step 0: 生成專家團隊(不依賴主題,純隨機多元)"""
"""Step 0: Generate expert team (not dependent on topic, purely random and diverse)"""
import time
import random
custom_text = ""
if custom_experts and len(custom_experts) > 0:
custom_text = f"(已指定:{', '.join(custom_experts[:expert_count])}"
# 加入時間戳和隨機數來增加多樣性
# Add timestamp and random number for diversity
seed = int(time.time() * 1000) % 10000
diversity_hints = [
"冷門、非主流、跨領域",
"罕見職業、新興領域、邊緣學科",
"非傳統、創新、小眾專業",
"未來趨向、實驗性、非常規",
"跨文化、混合領域、獨特視角"
]
hint = random.choice(diversity_hints)
return f"""/no_think
if lang == "en":
custom_text = ""
if custom_experts and len(custom_experts) > 0:
custom_text = f" (Specified: {', '.join(custom_experts[:expert_count])})"
diversity_hints = [
"obscure, non-mainstream, cross-disciplinary",
"rare occupations, emerging fields, fringe disciplines",
"unconventional, innovative, niche specialties",
"future-oriented, experimental, non-traditional",
"cross-cultural, hybrid fields, unique perspectives"
]
hint = random.choice(diversity_hints)
return f"""/no_think
Randomly assemble a team of {expert_count} experts from completely different fields{custom_text}.
[Innovation Requirements] (Random seed: {seed})
- Prioritize {hint} experts
- Avoid common professions (such as doctors, engineers, teachers, lawyers, etc.)
- Each expert must be from a completely unrelated field
- The rarer and more innovative, the better
Return JSON:
{{"experts": [{{"id": "expert-0", "name": "profession", "domain": "field", "perspective": "viewpoint"}}, ...]}}
Rules:
- id should be expert-0 to expert-{expert_count - 1}
- name is the profession name (not a person's name), 2-5 words
- domain should be specific and unique, no duplicate types"""
else:
custom_text = ""
if custom_experts and len(custom_experts) > 0:
custom_text = f"(已指定:{', '.join(custom_experts[:expert_count])}"
diversity_hints = [
"冷門、非主流、跨領域",
"罕見職業、新興領域、邊緣學科",
"非傳統、創新、小眾專業",
"未來趨向、實驗性、非常規",
"跨文化、混合領域、獨特視角"
]
hint = random.choice(diversity_hints)
return f"""/no_think
隨機組建 {expert_count} 個來自完全不同領域的專家團隊{custom_text}
【創新要求】(隨機種子:{seed}
@@ -50,13 +84,39 @@ def get_expert_keyword_generation_prompt(
category: str,
attribute: str,
experts: List[dict], # List[ExpertProfile]
keywords_per_expert: int = 1
keywords_per_expert: int = 1,
lang: LanguageType = "zh"
) -> str:
"""Step 1: 專家視角關鍵字生成"""
# 建立專家列表,格式更清晰
"""Step 1: Expert perspective keyword generation"""
# Build expert list in clearer format
experts_list = "\n".join([f"- {exp['id']}: {exp['name']}" for exp in experts])
return f"""/no_think
if lang == "en":
return f"""/no_think
You need to play the role of the following experts to generate innovative keywords for an attribute:
[Expert List]
{experts_list}
[Task]
Attribute: "{attribute}" (Category: {category})
For each expert, please:
1. First understand the professional background, knowledge domain, and work content of that profession
2. Think about "{attribute}" from that profession's unique perspective
3. Generate {keywords_per_expert} innovative keyword(s) related to that specialty (2-6 words)
Keywords must reflect that expert's professional thinking style, for example:
- Accountant viewing "movement""cash flow", "cost-benefit"
- Architect viewing "movement""circulation design", "spatial flow"
- Psychologist viewing "movement""behavioral motivation", "emotional transition"
Return JSON:
{{"keywords": [{{"keyword": "term", "expert_id": "expert-X", "expert_name": "name"}}, ...]}}
Total of {len(experts) * keywords_per_expert} keywords needed, each keyword must be clearly related to the corresponding expert's professional field."""
else:
return f"""/no_think
你需要扮演以下專家,為屬性生成創新關鍵字:
【專家名單】
@@ -86,13 +146,29 @@ def get_single_description_prompt(
keyword: str,
expert_id: str,
expert_name: str,
expert_domain: str
expert_domain: str,
lang: LanguageType = "zh"
) -> str:
"""Step 2: 為單一關鍵字生成描述"""
# 如果 domain 是通用的,就只用職業名稱
domain_text = f"{expert_domain}領域)" if expert_domain and expert_domain != "Professional Field" else ""
"""Step 2: Generate description for a single keyword"""
if lang == "en":
# If domain is generic, just use profession name
domain_text = f" ({expert_domain} field)" if expert_domain and expert_domain != "Professional Field" else ""
return f"""/no_think
return f"""/no_think
You are a {expert_name}{domain_text}.
Task: Generate an innovative application description for "{query}".
Keyword: {keyword}
From your professional perspective, explain how to apply the concept of "{keyword}" to "{query}". The description should be specific, creative, 15-30 words.
Return JSON only, no other text:
{{"description": "your innovative application description"}}"""
else:
# 如果 domain 是通用的,就只用職業名稱
domain_text = f"{expert_domain}領域)" if expert_domain and expert_domain != "Professional Field" else ""
return f"""/no_think
你是一位{expert_name}{domain_text}
任務:為「{query}」生成一段創新應用描述。