feat: Add external expert sources (Wikidata SPARQL + ConceptNet API)
- Add expert_cache.py: TTL-based in-memory cache (1 hour default) - Add expert_source_service.py: WikidataProvider and ConceptNetProvider - Wikidata SPARQL queries for occupations with Chinese labels - ConceptNet API queries for occupation-related concepts - Random selection from cached pool - Update schemas.py: Add ExpertSource enum (llm/wikidata/conceptnet) - Update ExpertTransformationRequest with expert_source and expert_language - Update router: Conditionally use external sources with LLM fallback - New SSE events: expert_source, expert_fallback - Update frontend types with ExpertSource 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -206,6 +206,13 @@ class ExpertTransformationDAGResult(BaseModel):
|
||||
results: List[ExpertTransformationCategoryResult]
|
||||
|
||||
|
||||
class ExpertSource(str, Enum):
|
||||
"""專家來源類型"""
|
||||
LLM = "llm"
|
||||
WIKIDATA = "wikidata"
|
||||
CONCEPTNET = "conceptnet"
|
||||
|
||||
|
||||
class ExpertTransformationRequest(BaseModel):
|
||||
"""Expert Transformation Agent 請求"""
|
||||
query: str
|
||||
@@ -217,6 +224,10 @@ class ExpertTransformationRequest(BaseModel):
|
||||
keywords_per_expert: int = 1 # 每個專家為每個屬性生成幾個關鍵字 (1-3)
|
||||
custom_experts: Optional[List[str]] = None # 用戶指定專家 ["藥師", "工程師"]
|
||||
|
||||
# Expert source parameters
|
||||
expert_source: ExpertSource = ExpertSource.LLM # 專家來源
|
||||
expert_language: str = "zh" # 外部來源的語言
|
||||
|
||||
# LLM parameters
|
||||
model: Optional[str] = None
|
||||
temperature: Optional[float] = 0.7
|
||||
|
||||
Reference in New Issue
Block a user