api-server/src/modules/ai/prompts/schemas/learning-trend.schema.ts
wangdl 4b8653080e
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 43s
feat: #67 GET /activity/trend 新增 dailySeries 时间序列数据
返回格式新增 dailySeries 字段 [{date, value, label}],支持 iOS 折线图/柱状图渲染。
数据来源:按日聚合 LearningActivity.durationSeconds。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-05 20:12:18 +08:00

50 lines
1.9 KiB
TypeScript
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.

import { z } from 'zod';
export const TrendItemSchema = z.object({
metric: z.string().min(1).max(100),
direction: z.enum(['improving', 'declining', 'stable']),
currentValue: z.string().max(200),
previousValue: z.string().max(200).optional(),
detail: z.string().max(500),
});
export const DailySeriesItemSchema = z.object({
date: z.string(),
value: z.number(),
label: z.string(),
});
export const LearningTrendResultSchema = z.object({
periodSummary: z.string().min(1).max(2000),
overallScore: z.number().int().min(0).max(100),
overallDirection: z.enum(['improving', 'declining', 'stable']),
trends: z.array(TrendItemSchema).max(10).default([]),
strengths: z.array(z.string().max(500)).max(10).default([]),
weaknesses: z.array(z.string().max(500)).max(10).default([]),
recommendations: z.array(z.string().max(500)).max(10).default([]),
nextFocusAreas: z.array(z.string().max(200)).max(5).default([]),
dailySeries: z.array(DailySeriesItemSchema).default([]),
});
export type LearningTrendResult = z.infer<typeof LearningTrendResultSchema>;
export type DailySeriesItem = z.infer<typeof DailySeriesItemSchema>;
export const LEARNING_TREND_OUTPUT_SCHEMA_DESC = `{
"periodSummary": "过去7天你的学习时长为320分钟完成了45次主动回忆和120张复习卡片。整体掌握水平有所提升。",
"overallScore": 72,
"overallDirection": "improving",
"trends": [
{
"metric": "主动回忆平均得分",
"direction": "improving",
"currentValue": "78分",
"previousValue": "65分",
"detail": "本周主动回忆得分持续上升,尤其在后半周表现更好"
}
],
"strengths": ["学习频率保持稳定", "复习完成率高"],
"weaknesses": ["主动回忆提交量偏低", "部分知识点反复出错"],
"recommendations": ["建议每天至少完成3次主动回忆", "重点关注\"X概念\"的复习"],
"nextFocusAreas": ["主动回忆量提升", "薄弱知识点巩固"]
}`;