Files
study-tool/src/study_tool/models.py
T
study-tool aa48145557 feat: 故障推送 / 公需课自动重学 / 插件解耦,发版 v0.0.8
体检修复:启动日志不再打印 AUTH_TOKEN、密钥可清空、推送失败不占整段冷却、目录名与文案统一成 plugins/。
2026-11-01 17:47:22 +08:00

107 lines
2.7 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.
"""HTTP 请求模型(Pydantic)。"""
from pydantic import BaseModel
# models
class LoginIn(BaseModel):
username: str = ""
password: str = ""
account_id: str = "" # 只给账号 id 时,用户名/密码从 SQLite 里取,密码不出库
platform: str = "" # 没传 account_id 时按它选平台
class AccountIn(BaseModel):
id: str = ""
username: str = ""
platform: str = "" # 添加账号时选的平台
password: str | None = None # 不传 = 保留库里已有的密码
note: str = ""
user: str = ""
cookies: list = []
courses: list = []
selected: list = []
status: str = "idle"
lastError: str = ""
lastErrorAt: float = 0
optQuiz: bool = False
optFeedback: bool = True
loginAt: float = 0
created: float = 0
class CookiesIn(BaseModel):
cookies: list
platform: str = ""
class DiscoverIn(BaseModel):
cookies: list
plan_id: str
project_id: str
name: str = ""
platform: str = ""
class StudyIn(BaseModel):
key: str
username: str = ""
password: str = "" # 仅用于会话失效时自动重登,不落盘
cookies: list = []
courses: list = [] # [{name, plan_id, project_id}]
plan_id: str = ""
project_id: str = ""
workers: int = 40
cap_minutes: int = 90
quiz_key: dict | None = None
enable_quiz: bool = False # 默认关闭:答题正确率无法保证
enable_feedback: bool = True # 反馈表无对错,默认开启
class StopIn(BaseModel):
key: str
class CaptureIn(BaseModel):
key: str
cookies: list = []
minutes: int = 10 # 抓包最长分钟数(1~30)
class NotifyCfgIn(BaseModel):
"""故障推送配置;空串 / 0 / None 都表示「不改」,避免只保存模型设置时被清空。"""
base_url: str = ""
app_key: str = ""
app_secret: str = "" # 留空 = 保留原密钥,前端不回显明文
channel_name: str = ""
enabled: bool | None = None
on_error: bool | None = None
on_login: bool | None = None
on_progress: bool | None = None
on_retry: bool | None = None
retry_threshold: int = 0
cooldown_min: int = 0
clear_app_secret: bool = False # True = 清掉已保存的 app_secret
class LlmCfgIn(BaseModel):
base_url: str = ""
api_key: str = ""
model: str = ""
temperature: float = 0.2 # 0 = 不改
timeout: int = 120
clear_api_key: bool = False # True = 清掉已保存的 api_key
prompt: str = ""
study_mode: str = "" # "" = 不改;fast / normal
study_parallel: int = 0 # 0 = 不改;1~5
notify: NotifyCfgIn | None = None # 不传 = 不动推送配置
class LlmTestIn(BaseModel):
base_url: str = ""
api_key: str = ""
model: str = ""
timeout: int = 60