fix(pricing): support Perplexity/Vertex price format without dollar sign
Some checks failed
CI / go-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / docker-build (push) Has been cancelled

- official_pricing_import_common.go: make dollar sign optional in firstDollarPrice regex
- perplexity_pricing_lib.go: fix column detection to match 'Input ($/1M)' format
- also updated vertex and perplexity baseline snapshots
This commit is contained in:
phamnazage-jpg
2026-05-22 09:18:14 +08:00
parent 68b1b2be41
commit 236dea8bf4
2 changed files with 4 additions and 4 deletions

View File

@@ -362,7 +362,7 @@ func cleanHTMLText(raw string) string {
}
func firstDollarPrice(raw string) (float64, bool) {
pattern := regexp.MustCompile(`\$ ?([0-9]+(?:\.[0-9]+)?)`)
pattern := regexp.MustCompile(`\$? ?([0-9]+(?:\.[0-9]+)?)`)
match := pattern.FindStringSubmatch(raw)
if len(match) != 2 {
return 0, false

View File

@@ -120,9 +120,9 @@ func detectPerplexityTableColumns(header []string) (int, int, int, int) {
switch {
case strings.Contains(lower, "model") && modelIndex == -1:
modelIndex = i
case strings.Contains(lower, "input") && strings.Contains(lower, "price") && inputIndex == -1:
inputIndex = i
case strings.Contains(lower, "output") && strings.Contains(lower, "price") && outputIndex == -1:
case strings.Contains(lower, "input") && (strings.Contains(lower, "price") || strings.Contains(lower, "$") || strings.Contains(lower, "/1m")) && inputIndex == -1:
inputIndex = i
case strings.Contains(lower, "output") && (strings.Contains(lower, "price") || strings.Contains(lower, "$") || strings.Contains(lower, "/1m")) && outputIndex == -1:
outputIndex = i
case (strings.Contains(lower, "documentation") || strings.Contains(lower, "docs")) && docIndex == -1:
docIndex = i