数据库与模型:新增多版迁移(章节证据快照、对话血缘、记忆事实/时间线 lineage 等),把「成稿 ↔ 对话/记忆」的溯源信息落到表结构里。 业务链路:会话与 WS、回忆录/故事流水线、记忆写入与 enrichment 等跟着接上线索与快照;新增章节证据快照与评测侧 EvalTraceService 等模块,方便组评审用的证据包。 内部评测:自动化 run 与手工 memoir 评审共用可追溯证据;rubric/ judge 相关脚本与文档有配套调整。 app-eval-web:Memoir/实验详情里能展开看证据摘要与 evidence_trace(含对话轮次 id);Vite 代理与 development.sh 注入的 API 端口与当前默认内部评测端口一致,避免改端口后页面连错服务。 工程杂项:GitHub Actions / 仓库说明有更新;各适配器与支付/配额/plan 等多处为小改动或跟随主改动的收尾;新增/扩充了?
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
"""Plan service — 套餐定义与查询。"""
|
||
|
||
from app.features.plan.catalog import (
|
||
AVAILABLE_PLANS,
|
||
ENABLE_TEST_PLAN,
|
||
TEST_PLAN,
|
||
get_plan_by_type,
|
||
get_plans_for_api,
|
||
)
|
||
from app.features.plan.schemas import CurrentPlanResponse, PlanResponse
|
||
from app.features.quota.service import QuotaService
|
||
from app.features.user.models import User
|
||
|
||
__all__ = [
|
||
"AVAILABLE_PLANS",
|
||
"ENABLE_TEST_PLAN",
|
||
"TEST_PLAN",
|
||
"PlanService",
|
||
"get_plan_by_type",
|
||
"get_plans_for_api",
|
||
]
|
||
|
||
|
||
class PlanService:
|
||
def __init__(self, quota_service: QuotaService):
|
||
self._quota = quota_service
|
||
|
||
def get_plans_for_api(self) -> list[PlanResponse]:
|
||
"""对外套餐列表(供 payment 等 feature 通过注入使用,不直接 import plan.service)。"""
|
||
return get_plans_for_api()
|
||
|
||
async def get_current_plan_response(self, user: User) -> CurrentPlanResponse:
|
||
plan = get_plan_by_type(user.subscription_type)
|
||
segment_count, chapter_count = await self._quota.get_usage(user.id)
|
||
usage = {
|
||
"conversations": segment_count,
|
||
"chapters": chapter_count,
|
||
"max_conversations": plan.max_conversations,
|
||
"max_chapters": plan.max_chapters,
|
||
}
|
||
expires_at = None
|
||
if user.subscription_expires_at:
|
||
expires_at = user.subscription_expires_at.isoformat()
|
||
return CurrentPlanResponse(
|
||
plan_id=plan.id,
|
||
plan_name=plan.display_name,
|
||
subscription_type=user.subscription_type,
|
||
expires_at=expires_at,
|
||
features=plan.features,
|
||
usage=usage,
|
||
)
|