feat(imports): add real pricing and subscription collectors

Add plan catalog and subscription schema support, seed baselines, and real importers for core domestic subscriptions plus stable official pricing sources.

This commit also hardens the shared fetch layers so the importers can support live collection and database writes instead of relying on manual placeholders alone.
This commit is contained in:
phamnazage-jpg
2026-05-15 22:32:57 +08:00
parent dd58c18fe3
commit 958245537a
91 changed files with 10474 additions and 1 deletions

View File

@@ -0,0 +1,76 @@
//go:build llm_script
package main
import (
"fmt"
"regexp"
"strings"
)
const default360PricingURL = "https://ai.360.com/open/models"
var platform360CardPattern = regexp.MustCompile(`(?s)([A-Za-z0-9._/-]+)\n([^\n]+)\n.*?(?:输入价格|Input Price)\s*:\s*¥([\d.]+)\s*/\s*1M tokens.*?(?:输出价格|Output Price)\s*:\s*¥([\d.]+)\s*/\s*1M tokens.*?(?:上下文|Context)\s*:\s*([\d,]+)`)
func parse360PricingCatalog(raw string) ([]officialPricingRecord, error) {
matches := platform360CardPattern.FindAllStringSubmatch(raw, -1)
if len(matches) == 0 {
return nil, fmt.Errorf("unexpected 360 pricing content")
}
records := make([]officialPricingRecord, 0, len(matches))
for _, match := range matches {
modelName := strings.TrimSpace(match[1])
providerName := normalize360Provider(match[2], modelName)
providerNameCn, providerCountry, providerWebsite := providerMetadata(providerName)
record := officialPricingRecord{
ModelID: normalizeExternalID("360", modelName),
ModelName: modelName,
ProviderName: providerName,
ProviderNameCn: providerNameCn,
ProviderCountry: providerCountry,
ProviderWebsite: providerWebsite,
OperatorName: "360 Open Platform",
OperatorNameCn: "360 智脑开放平台",
OperatorCountry: "CN",
OperatorWebsite: "https://ai.360.com",
OperatorType: "relay",
Region: "CN",
Currency: "CNY",
InputPrice: mustParseSubscriptionPrice(match[3]),
OutputPrice: mustParseSubscriptionPrice(match[4]),
ContextLength: parseContextLengthCommon(match[5]),
SourceURL: default360PricingURL,
ModelSourceURL: default360PricingURL,
DateConfidence: "unknown",
DateSourceKind: "official_product_page",
Modality: detectModality(modelName),
}
record.IsFree = record.InputPrice == 0 && record.OutputPrice == 0
records = append(records, record)
}
return records, nil
}
func normalize360Provider(raw string, modelName string) string {
switch strings.ToLower(strings.TrimSpace(raw)) {
case "deepseek", "深度求索":
return "DeepSeek"
case "moonshot ai", "月之暗面":
return "Moonshot AI"
case "qwen", "阿里巴巴", "通义千问":
return "Qwen"
case "zhipu", "智谱":
return "Zhipu AI"
case "字节跳动":
return "ByteDance"
case "360智脑":
return "360"
default:
providerByPath := providerFromModelPath(modelName)
if providerByPath != "unknown" {
return providerByPath
}
return strings.TrimSpace(raw)
}
}