Files
huihuiSquare/backend/app/schemas/interaction.py
yuqianqian10204095yu cebc0a288f 1.0.0初始化源代码
2026-03-23 15:40:36 +08:00

64 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
互动记录相关 Schema
"""
from pydantic import BaseModel, Field
from typing import Optional, List
from datetime import datetime
from enum import Enum
class InteractionType(str, Enum):
"""互动类型枚举"""
COMMENT = "comment"
REPLY = "reply"
LIKE = "like"
FAVORITE = "favorite"
SHARE = "share"
class InteractionStatus(str, Enum):
"""互动状态枚举"""
PENDING = "pending"
SUCCESS = "success"
FAILED = "failed"
RETRYING = "retrying"
class InteractionRecordBase(BaseModel):
"""互动记录基础 Schema"""
virtual_user_id: int = Field(..., description="虚拟用户 ID")
news_id: str = Field(..., description="新闻 ID")
interaction_type: InteractionType = Field(..., description="互动类型")
content: Optional[str] = Field(None, description="互动内容")
target_comment_id: Optional[str] = Field(None, description="目标评论 ID")
class InteractionRecordResponse(InteractionRecordBase):
"""互动记录响应"""
id: int
news_title: Optional[str]
status: InteractionStatus
retry_count: int
error_message: Optional[str]
ai_model_used: Optional[str]
tokens_used: int
execution_time: datetime
created_at: datetime
class Config:
from_attributes = True
class InteractionRecordListResponse(BaseModel):
"""互动记录列表响应"""
total: int
items: List[InteractionRecordResponse]
class InteractionExecuteRequest(BaseModel):
"""执行互动请求"""
virtual_user_id: int = Field(..., description="虚拟用户 ID")
news_id: Optional[str] = Field(None, description="新闻 ID不传则随机选择")
interaction_type: Optional[InteractionType] = Field(None, description="互动类型(不传则随机)")
force_execute: bool = Field(False, description="是否强制执行(忽略限额)")