forked from niuniu/llm-intelligence
feat(report): improve daily intelligence UX and price tracking
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -161,6 +162,45 @@ func sampleReportForV1() *ReportV3 {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildModelSelectionsSeparatesTopListsFromAppendixLists(t *testing.T) {
|
||||
intlModels := []ModelInfo{
|
||||
{Name: "intl-1", InputPrice: 0.1, Currency: "USD"},
|
||||
{Name: "intl-2", InputPrice: 0.2, Currency: "USD"},
|
||||
{Name: "intl-3", InputPrice: 0.3, Currency: "USD"},
|
||||
{Name: "intl-4", InputPrice: 0.4, Currency: "USD"},
|
||||
{Name: "intl-5", InputPrice: 0.5, Currency: "USD"},
|
||||
{Name: "intl-6", InputPrice: 0.6, Currency: "USD"},
|
||||
}
|
||||
var domesticModels []ModelInfo
|
||||
for i := 0; i < 14; i++ {
|
||||
domesticModels = append(domesticModels, ModelInfo{
|
||||
Name: fmt.Sprintf("domestic-%02d", i+1),
|
||||
InputPrice: float64(i + 1),
|
||||
Currency: "CNY",
|
||||
ContextLength: 65536,
|
||||
})
|
||||
}
|
||||
selections := buildModelSelections(intlModels, domesticModels, nil)
|
||||
if len(selections.IntlTop5) != 5 {
|
||||
t.Fatalf("expected intl top5 length 5, got %d", len(selections.IntlTop5))
|
||||
}
|
||||
if len(selections.IntlAppendixList) != 6 {
|
||||
t.Fatalf("expected intl appendix length 6, got %d", len(selections.IntlAppendixList))
|
||||
}
|
||||
if len(selections.DomesticTop10) != 10 {
|
||||
t.Fatalf("expected domestic top10 length 10, got %d", len(selections.DomesticTop10))
|
||||
}
|
||||
if len(selections.DomesticAppendixList) != 14 {
|
||||
t.Fatalf("expected domestic appendix length 14, got %d", len(selections.DomesticAppendixList))
|
||||
}
|
||||
if selections.DomesticTop10[0].Name != "domestic-01" || selections.DomesticTop10[9].Name != "domestic-10" {
|
||||
t.Fatalf("domestic top10 ordering mismatch: first=%s tenth=%s", selections.DomesticTop10[0].Name, selections.DomesticTop10[9].Name)
|
||||
}
|
||||
if selections.DomesticAppendixList[13].Name != "domestic-14" {
|
||||
t.Fatalf("domestic appendix should preserve full list, got tail=%s", selections.DomesticAppendixList[13].Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildFreeSourceBreakdown(t *testing.T) {
|
||||
report := sampleReportForV1()
|
||||
|
||||
@@ -357,12 +397,14 @@ func TestDecorateReportV1BuildsHotDaySummary(t *testing.T) {
|
||||
EventType: "price_cut",
|
||||
ModelName: "qwen-vl-max",
|
||||
ProviderName: "Alibaba",
|
||||
ProviderCountry: "CN",
|
||||
OperatorName: "DashScope",
|
||||
TrustLabel: "官方来源",
|
||||
Baseline: "较昨日 -18%",
|
||||
Summary: "价格下降已足以影响视觉模型默认选择。",
|
||||
SourceKindLabel: "价格快照",
|
||||
PrimarySource: "pricing_history",
|
||||
SourceURL: "https://dashscope.aliyun.com/model/qwen-vl-max",
|
||||
UpdatedAt: "2026-05-13 10:00",
|
||||
EvidenceDetail: "pricing_history 记录到输入价格较昨日下降 18%",
|
||||
PriceChangePct: -18,
|
||||
@@ -375,9 +417,10 @@ func TestDecorateReportV1BuildsHotDaySummary(t *testing.T) {
|
||||
if report.PageMode != "hot" {
|
||||
t.Fatalf("expected hot page mode, got %q", report.PageMode)
|
||||
}
|
||||
if !strings.Contains(report.HeroSummary, "GLM-5 已出现官方发布信号") {
|
||||
t.Fatalf("hero summary missing official release signal: %s", report.HeroSummary)
|
||||
if !strings.Contains(report.HeroSummary, "qwen-vl-max") || !strings.Contains(report.HeroSummary, "CN / Alibaba / DashScope") || !strings.Contains(report.HeroSummary, "价格下降") {
|
||||
t.Fatalf("hero summary should prioritize price change signal with org metadata, got %s", report.HeroSummary)
|
||||
}
|
||||
|
||||
if len(report.ActionItems) != 3 {
|
||||
t.Fatalf("expected 3 action items, got %d", len(report.ActionItems))
|
||||
}
|
||||
@@ -387,9 +430,14 @@ func TestDecorateReportV1BuildsHotDaySummary(t *testing.T) {
|
||||
if report.ActionItems[0].Evidence == "" {
|
||||
t.Fatalf("expected action item evidence to be populated")
|
||||
}
|
||||
if !strings.Contains(report.HeadlineItems[0].Title, "GLM-5") {
|
||||
t.Fatalf("expected first headline to prioritize official release, got %+v", report.HeadlineItems[0])
|
||||
if report.HeadlineItems[0].ProviderCountry == "" {
|
||||
t.Fatalf("expected headline item country metadata, got %+v", report.HeadlineItems[0])
|
||||
}
|
||||
|
||||
if report.HeadlineItems[0].Label != "价格下调" || !strings.Contains(report.HeadlineItems[0].Title, "qwen-vl-max") {
|
||||
t.Fatalf("expected first headline to prioritize price cut, got %+v", report.HeadlineItems[0])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestDecorateReportV1BuildsCalmDaySummary(t *testing.T) {
|
||||
@@ -403,6 +451,7 @@ func TestDecorateReportV1BuildsCalmDaySummary(t *testing.T) {
|
||||
}
|
||||
if !strings.Contains(report.HeroSummary, "稳定") {
|
||||
t.Fatalf("expected calm day summary to emphasize stability, got %s", report.HeroSummary)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,12 +495,14 @@ func TestGenerateMarkdownV3IncludesTencentSubscriptionSection(t *testing.T) {
|
||||
EventType: "official_release",
|
||||
ModelName: "GLM-5",
|
||||
ProviderName: "Zhipu",
|
||||
ProviderCountry: "CN",
|
||||
OperatorName: "Zhipu",
|
||||
TrustLabel: "官方来源 / 一级证据",
|
||||
Baseline: "官方首次发布",
|
||||
Summary: "官方发布新模型,值得优先复查中文通用与推理场景默认选择。",
|
||||
SourceKindLabel: "一级官方发布",
|
||||
PrimarySource: "https://open.bigmodel.cn/dev/howuse/model",
|
||||
SourceURL: "https://open.bigmodel.cn/dev/howuse/model",
|
||||
UpdatedAt: "2026-05-13 08:30",
|
||||
EvidenceDetail: "models.release_date = 今日,且 source_url 指向官方文档",
|
||||
Priority: 120,
|
||||
@@ -474,6 +525,7 @@ func TestGenerateMarkdownV3IncludesTencentSubscriptionSection(t *testing.T) {
|
||||
EventType: "new_model",
|
||||
ModelName: "DeepSeek-V4-Flash",
|
||||
ProviderName: "DeepSeek",
|
||||
ProviderCountry: "CN",
|
||||
OperatorName: "OpenRouter",
|
||||
Audience: "适合想尽快验证新模型价值的选型读者",
|
||||
TrustLabel: "聚合来源",
|
||||
@@ -481,6 +533,7 @@ func TestGenerateMarkdownV3IncludesTencentSubscriptionSection(t *testing.T) {
|
||||
Summary: "新模型进入情报池,值得重新评估低成本编码默认选择。",
|
||||
SourceKindLabel: "模型快照",
|
||||
PrimarySource: "OpenRouter / region_pricing",
|
||||
SourceURL: "https://openrouter.ai/models/deepseek/deepseek-v4-flash",
|
||||
UpdatedAt: "2026-05-13 09:30",
|
||||
EvidenceDetail: "models.created_at = 今日,且已存在最新价格快照",
|
||||
Priority: 95,
|
||||
@@ -500,6 +553,25 @@ func TestGenerateMarkdownV3IncludesTencentSubscriptionSection(t *testing.T) {
|
||||
EvidenceDetail: "官方活动页记录 V3.2-Exp 在活动窗口内价格下调 50%+",
|
||||
Priority: 115,
|
||||
},
|
||||
{
|
||||
EventType: "price_cut",
|
||||
ModelName: "qwen-vl-max",
|
||||
ProviderName: "Alibaba",
|
||||
ProviderCountry: "CN",
|
||||
|
||||
OperatorName: "DashScope",
|
||||
Audience: "适合需要当天重排价格带的团队",
|
||||
TrustLabel: "官方来源",
|
||||
Baseline: "较昨日 -18%",
|
||||
Summary: "视觉模型价格下降已足以影响默认选型。",
|
||||
SourceKindLabel: "价格快照",
|
||||
PrimarySource: "pricing_history",
|
||||
SourceURL: "https://dashscope.aliyun.com/model/qwen-vl-max",
|
||||
UpdatedAt: "2026-05-13 10:00",
|
||||
EvidenceDetail: "pricing_history 记录到输入价格较昨日下降 18%",
|
||||
PriceChangePct: -18,
|
||||
Priority: 100,
|
||||
},
|
||||
}
|
||||
decorateReportV1(report)
|
||||
|
||||
@@ -511,26 +583,31 @@ func TestGenerateMarkdownV3IncludesTencentSubscriptionSection(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("read markdown output: %v", err)
|
||||
}
|
||||
|
||||
content := string(body)
|
||||
if !strings.Contains(content, "### 国内模型 TOP 10") {
|
||||
t.Fatalf("markdown missing domestic top10 heading\n%s", content)
|
||||
}
|
||||
|
||||
content = string(body)
|
||||
for _, want := range []string{
|
||||
"## 今日结论",
|
||||
"## 今日行动建议",
|
||||
"## 今日变化",
|
||||
"## 今日价格新闻",
|
||||
"### ↓ Opportunity · 降价机会",
|
||||
"qwen-vl-max",
|
||||
"## 场景推荐",
|
||||
"## 完整数据附录",
|
||||
"- 影响对象:",
|
||||
"营销活动",
|
||||
"主来源: OpenRouter / region_pricing",
|
||||
"更新时间: 2026-05-13 09:30",
|
||||
"判定依据: models.created_at = 今日,且已存在最新价格快照",
|
||||
"## 💳 中转平台套餐订阅价",
|
||||
|
||||
"通用 Token Plan Lite",
|
||||
"Hy Token Plan Max",
|
||||
"¥39.00/月",
|
||||
"3500万 Tokens/月",
|
||||
"256K",
|
||||
} {
|
||||
|
||||
if !strings.Contains(content, want) {
|
||||
t.Fatalf("markdown missing %q\n%s", want, content)
|
||||
}
|
||||
@@ -599,6 +676,22 @@ func TestGenerateHTMLV3IncludesTencentSubscriptionSection(t *testing.T) {
|
||||
EvidenceDetail: "官方活动页记录 V3.2-Exp 在活动窗口内价格下调 50%+",
|
||||
Priority: 115,
|
||||
},
|
||||
{
|
||||
EventType: "price_cut",
|
||||
ModelName: "qwen-vl-max",
|
||||
ProviderName: "Alibaba",
|
||||
OperatorName: "DashScope",
|
||||
Audience: "适合需要当天重排价格带的团队",
|
||||
TrustLabel: "官方来源",
|
||||
Baseline: "较昨日 -18%",
|
||||
Summary: "视觉模型价格下降已足以影响默认选型。",
|
||||
SourceKindLabel: "价格快照",
|
||||
PrimarySource: "pricing_history",
|
||||
UpdatedAt: "2026-05-13 10:00",
|
||||
EvidenceDetail: "pricing_history 记录到输入价格较昨日下降 18%",
|
||||
PriceChangePct: -18,
|
||||
Priority: 100,
|
||||
},
|
||||
}
|
||||
report.TencentSubscriptionPlans = []SubscriptionPlanInfo{
|
||||
{
|
||||
@@ -628,17 +721,17 @@ func TestGenerateHTMLV3IncludesTencentSubscriptionSection(t *testing.T) {
|
||||
for _, want := range []string{
|
||||
"今日一句话结论",
|
||||
"三条行动建议",
|
||||
"今日价格新闻",
|
||||
"降价机会",
|
||||
"今日头条",
|
||||
"DeepSeek-V4-Flash",
|
||||
"一级官方发布",
|
||||
"二级权威佐证",
|
||||
"营销活动",
|
||||
"影响对象",
|
||||
"首次出现",
|
||||
"主来源",
|
||||
"更新时间",
|
||||
"判定依据",
|
||||
"模型快照",
|
||||
"场景推荐",
|
||||
"完整数据附录",
|
||||
"官方免费",
|
||||
@@ -652,6 +745,97 @@ func TestGenerateHTMLV3IncludesTencentSubscriptionSection(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateMarkdownV3IncludesLinkedHeroAndHeadline(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "daily_report_markdown_links.md")
|
||||
report := sampleReportForV1()
|
||||
report.ModelEvents = []ModelEvent{
|
||||
{
|
||||
EventType: "price_cut",
|
||||
ModelName: "qwen-vl-max",
|
||||
ProviderName: "Alibaba",
|
||||
ProviderCountry: "CN",
|
||||
OperatorName: "DashScope",
|
||||
TrustLabel: "官方来源",
|
||||
Baseline: "较昨日 -18%",
|
||||
Summary: "视觉模型价格下降已足以影响默认选型。",
|
||||
SourceKindLabel: "价格快照",
|
||||
PrimarySource: "pricing_history",
|
||||
SourceURL: "https://dashscope.aliyun.com/model/qwen-vl-max",
|
||||
UpdatedAt: "2026-05-13 10:00",
|
||||
EvidenceDetail: "pricing_history 记录到输入价格较昨日下降 18%",
|
||||
PriceChangePct: -18,
|
||||
Priority: 100,
|
||||
},
|
||||
}
|
||||
decorateReportV1(report)
|
||||
|
||||
if err := generateMarkdownV3(report, path); err != nil {
|
||||
t.Fatalf("generateMarkdownV3 returned error: %v", err)
|
||||
}
|
||||
body, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatalf("read markdown output: %v", err)
|
||||
}
|
||||
content := string(body)
|
||||
for _, want := range []string{
|
||||
"> [今天最值得关注的是 qwen-vl-max(CN / Alibaba / DashScope)价格下降 18%,优先复查它是否改变默认选型与预算策略。](https://dashscope.aliyun.com/model/qwen-vl-max)",
|
||||
"## 今日头条",
|
||||
"[qwen-vl-max 成本下调 18%](https://dashscope.aliyun.com/model/qwen-vl-max)",
|
||||
} {
|
||||
if !strings.Contains(content, want) {
|
||||
t.Fatalf("markdown missing %q\n%s", want, content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateHTMLV3IncludesLinksLowestPlanAndGPT56Leak(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "daily_report_links_leak.html")
|
||||
report := sampleReportForV1()
|
||||
report.ModelEvents = []ModelEvent{
|
||||
{
|
||||
EventType: "promo_campaign",
|
||||
ModelName: "GPT-5.6",
|
||||
ProviderName: "OpenAI",
|
||||
ProviderCountry: "US",
|
||||
OperatorName: "OpenAI",
|
||||
Audience: "适合关注高端模型路线图、预算和替换窗口的团队",
|
||||
TrustLabel: "行业情报 / 待官方确认",
|
||||
SourceKindLabel: "泄露情报",
|
||||
PrimarySource: "https://openai.example.com/gpt-5-6-leak",
|
||||
SourceURL: "https://openai.example.com/gpt-5-6-leak",
|
||||
UpdatedAt: "2026-05-27 00:00",
|
||||
EvidenceDetail: "多个公开情报源出现 GPT-5.6 命名与规格片段,尚待官方正式发布确认。",
|
||||
Baseline: "提前泄露",
|
||||
Summary: "GPT-5.6 提前泄露信号出现,需立即复查其是否改变默认高端模型路线与预算预期。",
|
||||
Priority: 135,
|
||||
},
|
||||
}
|
||||
report.TencentSubscriptionPlans = []SubscriptionPlanInfo{
|
||||
{OperatorName: "MiniMax", PlanName: "Starter", PlanFamily: "token_plan", BillingCycle: "monthly", Currency: "USD", ListPrice: 10, PriceUnit: "USD/month", ModelCount: 1},
|
||||
{OperatorName: "MiniMax", PlanName: "Plus", PlanFamily: "token_plan", BillingCycle: "monthly", Currency: "USD", ListPrice: 20, PriceUnit: "USD/month", ModelCount: 1},
|
||||
}
|
||||
decorateReportV1(report)
|
||||
|
||||
if err := generateHTMLV3(report, path); err != nil {
|
||||
t.Fatalf("generateHTMLV3 returned error: %v", err)
|
||||
}
|
||||
body, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatalf("read html output: %v", err)
|
||||
}
|
||||
content := string(body)
|
||||
for _, want := range []string{
|
||||
"GPT-5.6",
|
||||
"US / OpenAI",
|
||||
"https://openai.example.com/gpt-5-6-leak",
|
||||
"🏷 最低价",
|
||||
} {
|
||||
if !strings.Contains(content, want) {
|
||||
t.Fatalf("html missing %q\n%s", want, content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateHTMLV3IncludesResellerSubscriptionComparison(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "daily_report.html")
|
||||
report := sampleReportForV1()
|
||||
@@ -720,6 +904,9 @@ func TestGenerateHTMLV3IncludesResellerSubscriptionComparison(t *testing.T) {
|
||||
t.Fatalf("html missing %q\n%s", want, content)
|
||||
}
|
||||
}
|
||||
if !strings.Contains(content, "🏷 最低价") {
|
||||
t.Fatalf("expected lowest plan marker in subscription table\n%s", content)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateMarkdownV3IncludesSignatureStabilitySection(t *testing.T) {
|
||||
@@ -781,6 +968,168 @@ func TestGenerateMarkdownV3IncludesSignatureStabilitySection(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateMarkdownV3IncludesThemedPriceNewsSections(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "daily_report_price_news.md")
|
||||
report := sampleReportForV1()
|
||||
report.ModelEvents = []ModelEvent{
|
||||
{
|
||||
EventType: "price_cut",
|
||||
ModelName: "qwen-vl-max",
|
||||
ProviderName: "Alibaba",
|
||||
OperatorName: "DashScope",
|
||||
Summary: "视觉模型价格下降已足以影响默认选型。",
|
||||
Audience: "适合需要当天重排价格带的团队",
|
||||
TrustLabel: "官方来源",
|
||||
SourceKindLabel: "价格快照",
|
||||
PrimarySource: "pricing_history",
|
||||
UpdatedAt: "2026-05-13 10:00",
|
||||
EvidenceDetail: "pricing_history 记录到输入价格较昨日下降 18%",
|
||||
Baseline: "较昨日 -18%",
|
||||
PriceChangePct: -18,
|
||||
Priority: 100,
|
||||
},
|
||||
{
|
||||
EventType: "price_increase",
|
||||
ModelName: "claude-3.7-sonnet",
|
||||
ProviderName: "Anthropic",
|
||||
OperatorName: "Anthropic",
|
||||
Summary: "核心写作模型价格上调,需要准备预算回退。",
|
||||
Audience: "适合需要稳定预算的商用团队",
|
||||
TrustLabel: "官方来源",
|
||||
SourceKindLabel: "价格快照",
|
||||
PrimarySource: "pricing_history",
|
||||
UpdatedAt: "2026-05-13 10:10",
|
||||
EvidenceDetail: "pricing_history 记录到输入价格较昨日上涨 12%",
|
||||
Baseline: "较昨日 +12%",
|
||||
PriceChangePct: 12,
|
||||
Priority: 90,
|
||||
},
|
||||
{
|
||||
EventType: "promo_campaign",
|
||||
ModelName: "DeepSeek-V4-Flash",
|
||||
ProviderName: "DeepSeek",
|
||||
OperatorName: "DeepSeek",
|
||||
Summary: "平台活动窗口出现后,值得重新评估低成本推理方案。",
|
||||
Audience: "适合计划趁活动窗口压低推理成本的团队",
|
||||
TrustLabel: "官方来源 / 一级证据",
|
||||
SourceKindLabel: "官方活动页",
|
||||
PrimarySource: "https://api-docs.deepseek.com/news/news250929",
|
||||
UpdatedAt: "2026-05-13 09:00",
|
||||
EvidenceDetail: "官方活动页记录活动窗口价格下调",
|
||||
Baseline: "活动窗口开启",
|
||||
Priority: 80,
|
||||
},
|
||||
}
|
||||
decorateReportV1(report)
|
||||
|
||||
if err := generateMarkdownV3(report, path); err != nil {
|
||||
t.Fatalf("generateMarkdownV3 returned error: %v", err)
|
||||
}
|
||||
|
||||
body, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatalf("read markdown output: %v", err)
|
||||
}
|
||||
content := string(body)
|
||||
for _, want := range []string{
|
||||
"## 今日价格新闻",
|
||||
"### ↓ Opportunity · 降价机会",
|
||||
"### ↑ Warning · 涨价预警",
|
||||
"### ✦ Campaign · 平台活动",
|
||||
"qwen-vl-max",
|
||||
"claude-3.7-sonnet",
|
||||
"DeepSeek-V4-Flash",
|
||||
} {
|
||||
if !strings.Contains(content, want) {
|
||||
t.Fatalf("markdown missing %q\n%s", want, content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateHTMLV3IncludesThemedPriceNewsSections(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "daily_report_price_news.html")
|
||||
report := sampleReportForV1()
|
||||
report.ModelEvents = []ModelEvent{
|
||||
{
|
||||
EventType: "price_cut",
|
||||
ModelName: "qwen-vl-max",
|
||||
ProviderName: "Alibaba",
|
||||
OperatorName: "DashScope",
|
||||
Summary: "视觉模型价格下降已足以影响默认选型。",
|
||||
Audience: "适合需要当天重排价格带的团队",
|
||||
TrustLabel: "官方来源",
|
||||
SourceKindLabel: "价格快照",
|
||||
PrimarySource: "pricing_history",
|
||||
UpdatedAt: "2026-05-13 10:00",
|
||||
EvidenceDetail: "pricing_history 记录到输入价格较昨日下降 18%",
|
||||
Baseline: "较昨日 -18%",
|
||||
PriceChangePct: -18,
|
||||
Priority: 100,
|
||||
},
|
||||
{
|
||||
EventType: "price_increase",
|
||||
ModelName: "claude-3.7-sonnet",
|
||||
ProviderName: "Anthropic",
|
||||
OperatorName: "Anthropic",
|
||||
Summary: "核心写作模型价格上调,需要准备预算回退。",
|
||||
Audience: "适合需要稳定预算的商用团队",
|
||||
TrustLabel: "官方来源",
|
||||
SourceKindLabel: "价格快照",
|
||||
PrimarySource: "pricing_history",
|
||||
UpdatedAt: "2026-05-13 10:10",
|
||||
EvidenceDetail: "pricing_history 记录到输入价格较昨日上涨 12%",
|
||||
Baseline: "较昨日 +12%",
|
||||
PriceChangePct: 12,
|
||||
Priority: 90,
|
||||
},
|
||||
{
|
||||
EventType: "promo_campaign",
|
||||
ModelName: "DeepSeek-V4-Flash",
|
||||
ProviderName: "DeepSeek",
|
||||
OperatorName: "DeepSeek",
|
||||
Summary: "平台活动窗口出现后,值得重新评估低成本推理方案。",
|
||||
Audience: "适合计划趁活动窗口压低推理成本的团队",
|
||||
TrustLabel: "官方来源 / 一级证据",
|
||||
SourceKindLabel: "官方活动页",
|
||||
PrimarySource: "https://api-docs.deepseek.com/news/news250929",
|
||||
UpdatedAt: "2026-05-13 09:00",
|
||||
EvidenceDetail: "官方活动页记录活动窗口价格下调",
|
||||
Baseline: "活动窗口开启",
|
||||
Priority: 80,
|
||||
},
|
||||
}
|
||||
decorateReportV1(report)
|
||||
|
||||
if err := generateHTMLV3(report, path); err != nil {
|
||||
t.Fatalf("generateHTMLV3 returned error: %v", err)
|
||||
}
|
||||
|
||||
body, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatalf("read html output: %v", err)
|
||||
}
|
||||
content := string(body)
|
||||
for _, want := range []string{
|
||||
"今日价格新闻",
|
||||
"降价机会",
|
||||
"涨价预警",
|
||||
"平台活动",
|
||||
"Opportunity",
|
||||
"Warning",
|
||||
"Campaign",
|
||||
">↓<",
|
||||
">↑<",
|
||||
">✦<",
|
||||
"qwen-vl-max",
|
||||
"claude-3.7-sonnet",
|
||||
"DeepSeek-V4-Flash",
|
||||
} {
|
||||
if !strings.Contains(content, want) {
|
||||
t.Fatalf("html missing %q\n%s", want, content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateHTMLV3IncludesSignatureStabilitySection(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "daily_report.html")
|
||||
report := sampleReportForV1()
|
||||
@@ -830,6 +1179,163 @@ func TestGenerateHTMLV3IncludesSignatureStabilitySection(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateHTMLV3IncludesPriceNewsBadgeIcons(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "daily_report_price_news_badges.html")
|
||||
report := sampleReportForV1()
|
||||
report.ModelEvents = []ModelEvent{
|
||||
{
|
||||
EventType: "price_cut",
|
||||
ModelName: "qwen-vl-max",
|
||||
ProviderName: "Alibaba",
|
||||
OperatorName: "DashScope",
|
||||
Summary: "视觉模型价格下降已足以影响默认选型。",
|
||||
Audience: "适合需要当天重排价格带的团队",
|
||||
TrustLabel: "官方来源",
|
||||
SourceKindLabel: "价格快照",
|
||||
PrimarySource: "pricing_history",
|
||||
UpdatedAt: "2026-05-13 10:00",
|
||||
EvidenceDetail: "pricing_history 记录到输入价格较昨日下降 18%",
|
||||
Baseline: "较昨日 -18%",
|
||||
PriceChangePct: -18,
|
||||
Priority: 100,
|
||||
},
|
||||
{
|
||||
EventType: "price_increase",
|
||||
ModelName: "claude-3.7-sonnet",
|
||||
ProviderName: "Anthropic",
|
||||
OperatorName: "Anthropic",
|
||||
Summary: "核心写作模型价格上调,需要准备预算回退。",
|
||||
Audience: "适合需要稳定预算的商用团队",
|
||||
TrustLabel: "官方来源",
|
||||
SourceKindLabel: "价格快照",
|
||||
PrimarySource: "pricing_history",
|
||||
UpdatedAt: "2026-05-13 10:10",
|
||||
EvidenceDetail: "pricing_history 记录到输入价格较昨日上涨 12%",
|
||||
Baseline: "较昨日 +12%",
|
||||
PriceChangePct: 12,
|
||||
Priority: 90,
|
||||
},
|
||||
{
|
||||
EventType: "promo_campaign",
|
||||
ModelName: "DeepSeek-V4-Flash",
|
||||
ProviderName: "DeepSeek",
|
||||
OperatorName: "DeepSeek",
|
||||
Summary: "平台活动窗口出现后,值得重新评估低成本推理方案。",
|
||||
Audience: "适合计划趁活动窗口压低推理成本的团队",
|
||||
TrustLabel: "官方来源 / 一级证据",
|
||||
SourceKindLabel: "官方活动页",
|
||||
PrimarySource: "https://api-docs.deepseek.com/news/news250929",
|
||||
UpdatedAt: "2026-05-13 09:00",
|
||||
EvidenceDetail: "官方活动页记录活动窗口价格下调",
|
||||
Baseline: "活动窗口开启",
|
||||
Priority: 80,
|
||||
},
|
||||
}
|
||||
decorateReportV1(report)
|
||||
|
||||
if err := generateHTMLV3(report, path); err != nil {
|
||||
t.Fatalf("generateHTMLV3 returned error: %v", err)
|
||||
}
|
||||
|
||||
body, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatalf("read html output: %v", err)
|
||||
}
|
||||
content := string(body)
|
||||
for _, want := range []string{
|
||||
"Opportunity",
|
||||
"Warning",
|
||||
"Campaign",
|
||||
">↓<",
|
||||
">↑<",
|
||||
">✦<",
|
||||
} {
|
||||
if !strings.Contains(content, want) {
|
||||
t.Fatalf("html missing %q\n%s", want, content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGenerateHTMLV3PaginatesAppendices(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "daily_report_appendix_pagination.html")
|
||||
report := sampleReportForV1()
|
||||
report.IntlTop5 = nil
|
||||
report.IntlAppendixList = nil
|
||||
report.DomesticTop10 = nil
|
||||
report.DomesticAppendixList = nil
|
||||
report.FreeTop20 = nil
|
||||
report.Operators = nil
|
||||
report.Resellers = nil
|
||||
|
||||
for i := 0; i < 65; i++ {
|
||||
report.DomesticAppendixList = append(report.DomesticAppendixList, ModelInfo{
|
||||
Name: fmt.Sprintf("domestic-model-%02d", i+1),
|
||||
ProviderName: "ProviderCN",
|
||||
InputPrice: 1,
|
||||
OutputPrice: 2,
|
||||
Currency: "CNY",
|
||||
ContextLength: 131072,
|
||||
})
|
||||
}
|
||||
|
||||
for i := 0; i < 22; i++ {
|
||||
report.FreeTop20 = append(report.FreeTop20, ModelInfo{
|
||||
Name: fmt.Sprintf("free-model-%02d", i+1),
|
||||
ProviderName: "ProviderFree",
|
||||
OperatorType: "official",
|
||||
ContextLength: 65536,
|
||||
})
|
||||
}
|
||||
for i := 0; i < 23; i++ {
|
||||
report.Operators = append(report.Operators, OperatorInfo{Name: fmt.Sprintf("Operator-%02d", i+1), ModelCount: i + 1, MinInputPrice: 0.1, AvgInputPrice: 0.2})
|
||||
}
|
||||
for i := 0; i < 22; i++ {
|
||||
report.Resellers = append(report.Resellers, OperatorInfo{Name: fmt.Sprintf("Reseller-%02d", i+1), ModelCount: i + 1, MinInputPrice: 0.3, AvgInputPrice: 0.4})
|
||||
}
|
||||
decorateReportV1(report)
|
||||
report.AppendixLinks = []AppendixLink{
|
||||
{Title: "国际低价", Description: "查看国际低价模型附录(日报仅保留前几页)", Anchor: "#appendix-pricing-intl"},
|
||||
{Title: "国内低价", Description: "查看国内低价模型附录(日报仅保留前几页)", Anchor: "#appendix-pricing-domestic"},
|
||||
{Title: "免费样本", Description: "查看免费模型代表样本附录", Anchor: "#appendix-free"},
|
||||
{Title: "平台覆盖", Description: "查看官方平台与聚合平台覆盖", Anchor: "#appendix-platforms"},
|
||||
{Title: "全量导出 JSON", Description: "其余完整数据请下载独立导出文件或转到查询页查看", Anchor: "/reports/daily/appendix/2026-05-13/full_appendix.json"},
|
||||
}
|
||||
|
||||
if err := generateHTMLV3(report, path); err != nil {
|
||||
t.Fatalf("generateHTMLV3 returned error: %v", err)
|
||||
}
|
||||
|
||||
body, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatalf("read html output: %v", err)
|
||||
}
|
||||
content := string(body)
|
||||
for _, want := range []string{
|
||||
"完整价格附录(国际低价)",
|
||||
"完整价格附录(国内低价)",
|
||||
"完整免费附录",
|
||||
"平台覆盖附录",
|
||||
"国际低价",
|
||||
"国内低价",
|
||||
"全量导出 JSON",
|
||||
"/reports/daily/appendix/2026-05-13/full_appendix.json",
|
||||
"data-appendix-page=\"1\"",
|
||||
"data-appendix-total-pages=\"1\"",
|
||||
"data-appendix-total-pages=\"2\"",
|
||||
"data-appendix-total-pages=\"3\"",
|
||||
"#appendix-pricing-intl",
|
||||
"#appendix-pricing-domestic",
|
||||
"#appendix-free",
|
||||
"#appendix-platforms",
|
||||
"上一页",
|
||||
"下一页",
|
||||
} {
|
||||
if !strings.Contains(content, want) {
|
||||
t.Fatalf("html missing %q\n%s", want, content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildHeadlineItemsUsesModelEvents(t *testing.T) {
|
||||
report := sampleReportForV1()
|
||||
report.ModelEvents = []ModelEvent{
|
||||
@@ -883,14 +1389,17 @@ func TestBuildHeadlineItemsUsesModelEvents(t *testing.T) {
|
||||
if len(items) < 2 {
|
||||
t.Fatalf("expected at least 2 headline items, got %d", len(items))
|
||||
}
|
||||
if !strings.Contains(items[0].Title, "GLM-5") || items[0].Label != "一级官方发布" {
|
||||
t.Fatalf("expected official release event to rank first, got %+v", items[0])
|
||||
if items[0].Label != "价格下调" || !strings.Contains(items[0].Title, "glm-5") {
|
||||
t.Fatalf("expected price change event to rank first, got %+v", items[0])
|
||||
}
|
||||
if items[1].Baseline != "较昨日 -25%" {
|
||||
t.Fatalf("expected price_cut baseline to be preserved, got %+v", items[1])
|
||||
if items[1].Label != "一级官方发布" {
|
||||
t.Fatalf("expected official release to stay immediately after price change, got %+v", items[1])
|
||||
}
|
||||
if items[0].SourceKindLabel != "一级官方发布" || items[0].PrimarySource != "https://open.bigmodel.cn/dev/howuse/model" {
|
||||
t.Fatalf("expected official release evidence fields to be preserved, got %+v", items[0])
|
||||
if items[0].Baseline != "较昨日 -25%" {
|
||||
t.Fatalf("expected price_cut baseline to be preserved, got %+v", items[0])
|
||||
}
|
||||
if items[1].SourceKindLabel != "一级官方发布" || items[1].PrimarySource != "https://open.bigmodel.cn/dev/howuse/model" {
|
||||
t.Fatalf("expected official release evidence fields to be preserved, got %+v", items[1])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1082,6 +1591,89 @@ func TestDecorateReportV1ElevatesSignatureDriftIntoHeroSummary(t *testing.T) {
|
||||
if !strings.Contains(report.HeroEvidence, "最近 5 次中出现 3 次结构变化") {
|
||||
t.Fatalf("expected hero evidence to mention drift count, got %q", report.HeroEvidence)
|
||||
}
|
||||
|
||||
}
|
||||
func TestDecorateReportV1PrefersPriceChangeInHeroSummary(t *testing.T) {
|
||||
report := sampleReportForV1()
|
||||
report.ModelEvents = []ModelEvent{
|
||||
{
|
||||
EventType: "official_release",
|
||||
ModelName: "GLM-5",
|
||||
Summary: "官方发布新模型。",
|
||||
PrimarySource: "official release",
|
||||
EvidenceDetail: "models.release_date = 今日",
|
||||
Priority: 120,
|
||||
},
|
||||
{
|
||||
EventType: "price_cut",
|
||||
ModelName: "DeepSeek-V4-Flash",
|
||||
ProviderName: "DeepSeek",
|
||||
OperatorName: "OpenRouter",
|
||||
Summary: "价格下降已足以影响默认选型,值得重新评估同类模型。",
|
||||
PrimarySource: "pricing_history",
|
||||
EvidenceDetail: "pricing_history 记录到输入价格由 $0.60 调整为 $0.30,较昨日下降 50%",
|
||||
PriceChangePct: -50,
|
||||
OldInputPrice: 0.60,
|
||||
NewInputPrice: 0.30,
|
||||
OldOutputPrice: 2.40,
|
||||
NewOutputPrice: 1.20,
|
||||
Currency: "USD",
|
||||
Priority: 95,
|
||||
},
|
||||
}
|
||||
|
||||
decorateReportV1(report)
|
||||
|
||||
if !strings.Contains(report.HeroSummary, "DeepSeek-V4-Flash") || !strings.Contains(report.HeroSummary, "价格") {
|
||||
t.Fatalf("expected hero summary to prioritize price change, got %q", report.HeroSummary)
|
||||
}
|
||||
if !strings.Contains(report.HeroEvidence, "pricing_history") {
|
||||
t.Fatalf("expected hero evidence to mention pricing history, got %q", report.HeroEvidence)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildHeadlineItemsPlacesPriceChangeBeforeOfficialRelease(t *testing.T) {
|
||||
report := sampleReportForV1()
|
||||
report.ModelEvents = []ModelEvent{
|
||||
{
|
||||
EventType: "official_release",
|
||||
ModelName: "GLM-5",
|
||||
Summary: "官方发布新模型。",
|
||||
TrustLabel: "官方来源 / 一级证据",
|
||||
SourceKindLabel: "一级官方发布",
|
||||
PrimarySource: "official release",
|
||||
UpdatedAt: "2026-05-13 08:30",
|
||||
EvidenceDetail: "models.release_date = 今日",
|
||||
Priority: 120,
|
||||
},
|
||||
{
|
||||
EventType: "price_cut",
|
||||
ModelName: "DeepSeek-V4-Flash",
|
||||
ProviderName: "DeepSeek",
|
||||
OperatorName: "OpenRouter",
|
||||
Summary: "价格下降已足以影响默认选型,值得重新评估同类模型。",
|
||||
TrustLabel: "聚合来源",
|
||||
SourceKindLabel: "价格快照",
|
||||
PrimarySource: "pricing_history",
|
||||
UpdatedAt: "2026-05-13 09:30",
|
||||
EvidenceDetail: "pricing_history 记录到输入价格由 $0.60 调整为 $0.30,较昨日下降 50%",
|
||||
PriceChangePct: -50,
|
||||
OldInputPrice: 0.60,
|
||||
NewInputPrice: 0.30,
|
||||
OldOutputPrice: 2.40,
|
||||
NewOutputPrice: 1.20,
|
||||
Currency: "USD",
|
||||
Priority: 95,
|
||||
},
|
||||
}
|
||||
|
||||
items := buildHeadlineItems(report)
|
||||
if len(items) == 0 {
|
||||
t.Fatalf("expected headline items")
|
||||
}
|
||||
if items[0].Label != "价格下调" {
|
||||
t.Fatalf("expected price change headline first, got %+v", items[0])
|
||||
}
|
||||
}
|
||||
|
||||
func TestSignatureAuditSummaryToneRespectsConfiguredThreshold(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user