Files
llm-intelligence/scripts/zhipu_coding_plan_lib.go

82 lines
2.9 KiB
Go
Raw Normal View History

//go:build llm_script
package main
import (
"fmt"
"regexp"
"strings"
)
const (
defaultZhipuCodingPlanOverviewURL = "https://docs.bigmodel.cn/cn/coding-plan/overview"
defaultZhipuCodingPlanPromotionURL = "https://docs.bigmodel.cn/cn/update/promotion"
)
func parseZhipuCodingPlanCatalog(overviewRaw string, promotionRaw string) ([]subscriptionImportRecord, error) {
publishedAt, known := publishedAtFromText(firstNonEmptyText(overviewRaw, promotionRaw))
pricePattern := regexp.MustCompile(`低至\s*([\d.]+)\s*元/月`)
priceMatch := pricePattern.FindStringSubmatch(promotionRaw)
if len(priceMatch) != 2 {
return nil, fmt.Errorf("zhipu promo floor price not found")
}
modelScope := []string{}
modelPattern := regexp.MustCompile(`包含\s+([^\n]+)`)
modelMatch := modelPattern.FindStringSubmatch(overviewRaw)
if len(modelMatch) == 2 {
for _, item := range strings.Split(modelMatch[1], "、") {
item = strings.TrimSpace(strings.TrimSuffix(item, "。"))
if item != "" {
modelScope = append(modelScope, item)
}
}
}
notes := []string{
"GLM Coding Plan 提供 Lite/Pro/Max 三档能力。",
}
if strings.Contains(overviewRaw, "每 5 小时最多约 80 / 400 / 1,600 次 prompts") {
notes = append(notes, "5 小时额度Lite 80 / Pro 400 / Max 1600 prompts。")
}
if strings.Contains(overviewRaw, "每周最多约 400 / 2,000 / 8,000 次 prompts") {
notes = append(notes, "每周额度Lite 400 / Pro 2000 / Max 8000 prompts。")
}
if strings.Contains(overviewRaw, "Lite 套餐每月包含 100 次 MCP 调用") {
notes = append(notes, "MCP 月额度Lite 100 / Pro 1000 / Max 4000。")
}
if strings.Contains(promotionRaw, "首单 9 折") {
notes = append(notes, "首单 9 折优惠,新老用户均可参与。")
}
notes = append(notes, "公开文档仅披露活动底价,分档定价仍需控制台核验。")
return []subscriptionImportRecord{{
ProviderName: "Zhipu AI",
ProviderNameCn: "智谱 AI",
ProviderCountry: "CN",
ProviderWebsite: "https://open.bigmodel.cn",
OperatorName: "Zhipu",
OperatorNameCn: "智谱开放平台",
OperatorCountry: "CN",
OperatorWebsite: "https://docs.bigmodel.cn/",
OperatorType: "official",
PlanFamily: "coding_plan",
PlanCode: "zhipu-coding-plan-promo-floor",
PlanName: "GLM Coding Plan 限时活动价(低至)",
Tier: "PromoFloor",
BillingCycle: "monthly",
Currency: "CNY",
ListPrice: mustParseSubscriptionPrice(priceMatch[1]),
PriceUnit: "CNY/month",
QuotaValue: 0,
QuotaUnit: "",
PlanScope: "GLM Coding Plan",
ModelScope: modelScope,
SourceURL: defaultZhipuCodingPlanPromotionURL,
PublishedAt: publishedAt,
EffectiveDate: effectiveDateFromPublishedAt(publishedAt),
Notes: strings.Join(notes, ""),
PublishedAtKnown: known,
}}, nil
}