feat(import): refine official release metadata backfill
This commit is contained in:
@@ -73,6 +73,24 @@ type baiduModelMetadata struct {
|
||||
}
|
||||
|
||||
var baiduModelMetadataRules = []baiduModelMetadata{
|
||||
{
|
||||
Prefix: "baidu-ernie-5.0",
|
||||
ReleaseDate: "2026-01-22",
|
||||
ModelSourceURL: "https://cloud.baidu.com/news/news_eacd0f0b-0ca3-4963-aec8-5e6b9ebef9ba",
|
||||
},
|
||||
{
|
||||
Prefix: "baidu-ernie-x1.1",
|
||||
ReleaseDate: "2025-09-09",
|
||||
ModelSourceURL: "https://cloud.baidu.com/news/news_be713ff4-8477-4852-88f1-9cc56c406d6a",
|
||||
},
|
||||
{
|
||||
Prefix: "baidu-ernie-5.1",
|
||||
ModelSourceURL: "https://cloud.baidu.com/product/wenxinworkshop.html",
|
||||
},
|
||||
{
|
||||
Prefix: "baidu-ernie-4.5-turbo-vl",
|
||||
ModelSourceURL: "https://cloud.baidu.com/product/wenxinworkshop.html",
|
||||
},
|
||||
{
|
||||
Prefix: "baidu-ernie-4.5-turbo",
|
||||
ReleaseDate: "2025-04-25",
|
||||
@@ -93,6 +111,21 @@ var baiduModelMetadataRules = []baiduModelMetadata{
|
||||
ReleaseDate: "2025-03-16",
|
||||
ModelSourceURL: "https://cloud.baidu.com/article/3835921",
|
||||
},
|
||||
{
|
||||
Prefix: "baidu-ernie-character",
|
||||
ReleaseDate: "2024-03-22",
|
||||
ModelSourceURL: "https://cloud.baidu.com/news/news_667c065f-0bd7-475d-98c2-901763d0ee77",
|
||||
},
|
||||
{
|
||||
Prefix: "baidu-ernie-lite-pro",
|
||||
ReleaseDate: "2024-03-22",
|
||||
ModelSourceURL: "https://cloud.baidu.com/news/news_667c065f-0bd7-475d-98c2-901763d0ee77",
|
||||
},
|
||||
{
|
||||
Prefix: "baidu-ernie-speed-pro",
|
||||
ReleaseDate: "2024-03-22",
|
||||
ModelSourceURL: "https://cloud.baidu.com/news/news_667c065f-0bd7-475d-98c2-901763d0ee77",
|
||||
},
|
||||
}
|
||||
|
||||
func enrichBaiduModelMetadata(model ModelPricing) ModelPricing {
|
||||
@@ -114,6 +147,10 @@ func enrichBaiduModelMetadata(model ModelPricing) ModelPricing {
|
||||
return model
|
||||
}
|
||||
|
||||
func hasExplicitModelMetadata(model ModelPricing) bool {
|
||||
return strings.TrimSpace(model.ReleaseDate) != "" || firstNonEmpty(model.ModelSourceURL) != "" && model.ModelSourceURL != model.SourceURL
|
||||
}
|
||||
|
||||
func parseZhipuPrice(s string) float64 {
|
||||
// Extract price from strings like "6元", "免费", "限时免费"
|
||||
if strings.Contains(s, "免费") {
|
||||
@@ -260,14 +297,22 @@ func main() {
|
||||
log.Printf("Model error: %v", err)
|
||||
continue
|
||||
}
|
||||
_, _ = db.Exec(
|
||||
if _, err := db.Exec(
|
||||
`UPDATE models
|
||||
SET source_url = COALESCE(NULLIF(source_url, ''), $2),
|
||||
release_date = COALESCE(release_date, $3),
|
||||
SET source_url = CASE
|
||||
WHEN $4 THEN $2
|
||||
ELSE COALESCE(NULLIF(source_url, ''), $2)
|
||||
END,
|
||||
release_date = CASE
|
||||
WHEN $4 AND $3::date IS NOT NULL THEN $3::date
|
||||
ELSE COALESCE(release_date, $3::date)
|
||||
END,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = $1`,
|
||||
modelID, firstNonEmpty(p.ModelSourceURL, p.SourceURL), releaseDateValue(p.ReleaseDate),
|
||||
)
|
||||
modelID, firstNonEmpty(p.ModelSourceURL, p.SourceURL), releaseDateValue(p.ReleaseDate), hasExplicitModelMetadata(p),
|
||||
); err != nil {
|
||||
log.Printf("Model metadata update error for %s: %v", p.ModelID, err)
|
||||
}
|
||||
|
||||
// Insert pricing
|
||||
sourceType := p.OperatorType
|
||||
|
||||
Reference in New Issue
Block a user