feat: 添加飞书用户模块和订阅功能支持 - 新增feishu_users模块用于处理飞书用户身份验证和权限管理 - 新增subscriptions模块用于处理订阅相关功能 - 新增personalization模块用于个性化服务 - 在alembic迁移配置中注册新的模型模块 - 在API路由器中添加feishu_users和subscriptions路由 - 实现事件调度服务的改进,包括错误处理和状态更新优化 - 添加飞书命令处理的权限检查机制 - 实现飞书应用票据事件处理 - 改进审计日志记录功能 ```
66 lines
1.6 KiB
Python
66 lines
1.6 KiB
Python
from datetime import datetime
|
|
from typing import Any
|
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
|
|
from app.modules.personalization.constants import PreferenceCategory, PreferenceSource
|
|
|
|
|
|
class PreferenceCreate(BaseModel):
|
|
category: PreferenceCategory
|
|
value: str = Field(..., min_length=1, max_length=1000)
|
|
source: PreferenceSource = PreferenceSource.EXPLICIT
|
|
|
|
|
|
class PreferenceUpdate(BaseModel):
|
|
category: PreferenceCategory | None = None
|
|
value: str | None = Field(default=None, min_length=1, max_length=1000)
|
|
|
|
|
|
class PreferenceRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
code: str
|
|
category: str
|
|
value: str
|
|
source: str
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
|
|
class ExtractedPreference(BaseModel):
|
|
category: PreferenceCategory
|
|
value: str = Field(..., min_length=1, max_length=1000)
|
|
|
|
|
|
class PreferenceExtractionPayload(BaseModel):
|
|
preferences: list[ExtractedPreference] = Field(default_factory=list, max_length=20)
|
|
|
|
|
|
class ConversationMessageRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
role: str
|
|
content: str
|
|
created_at: datetime
|
|
|
|
|
|
class ConversationRead(BaseModel):
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
code: str
|
|
chat_type: str
|
|
chat_key: str
|
|
messages: list[ConversationMessageRead] = Field(default_factory=list)
|
|
|
|
|
|
class ErasureConfirmation(BaseModel):
|
|
confirmation_code: str
|
|
expires_at: datetime
|
|
|
|
|
|
class ErasureResult(BaseModel):
|
|
anonymous_id: str
|
|
deleted: dict[str, int] = Field(default_factory=dict)
|
|
extra: dict[str, Any] = Field(default_factory=dict)
|