mirror of
https://github.com/stardrophere/InsightRadar.git
synced 2026-06-05 23:07:51 +08:00
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
from datetime import datetime
|
|
from typing import List, Optional
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
class UserTopicPreferenceCreate(BaseModel):
|
|
"""新增用户兴趣词请求体。"""
|
|
interested_keyword: str = Field(..., min_length=1, max_length=100, description="用户感兴趣的关键词")
|
|
|
|
|
|
class UserTopicPreferenceResponse(BaseModel):
|
|
"""用户兴趣词响应体。"""
|
|
id: int
|
|
user_id: int
|
|
interested_keyword: str
|
|
created_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class EventMatchSemanticHit(BaseModel):
|
|
"""语义命中的明细。"""
|
|
preference_keyword: str
|
|
topic_keyword: str
|
|
similarity: float
|
|
|
|
|
|
class MatchedEventResponse(BaseModel):
|
|
"""推荐事件响应体。"""
|
|
event_id: int
|
|
unified_title: str
|
|
summary: Optional[str]
|
|
hot_score: int
|
|
created_at: datetime
|
|
tags: List[str] = Field(default_factory=list)
|
|
match_score: float
|
|
exact_hits: List[str] = Field(default_factory=list)
|
|
semantic_hits: List[EventMatchSemanticHit] = Field(default_factory=list)
|
|
|
|
|
|
class UserPreferenceRecommendationResponse(BaseModel):
|
|
"""用户兴趣推荐结果。"""
|
|
user_id: int
|
|
total: int
|
|
data: List[MatchedEventResponse] = Field(default_factory=list)
|