Files
llm-intelligence/scripts/perplexity_pricing_signature_guard.go

52 lines
1.5 KiB
Go
Raw Normal View History

//go:build llm_script
package main
import (
"flag"
"fmt"
"os"
"time"
)
func main() {
loadSubscriptionImportEnv()
var url string
var fixture string
var snapshotDir string
var baselinePath string
var timeoutSeconds int
var allowBootstrap bool
flag.StringVar(&url, "url", defaultPerplexityPricingFetchURL, "Perplexity Agent API 官方模型价格 markdown")
flag.StringVar(&fixture, "fixture", "", "Perplexity 价格样例文件")
flag.StringVar(&snapshotDir, "snapshot-dir", "", "Perplexity snapshot 输出目录")
flag.StringVar(&baselinePath, "baseline-path", "", "Perplexity 结构基线签名路径")
flag.IntVar(&timeoutSeconds, "timeout", 20, "请求超时(秒)")
flag.BoolVar(&allowBootstrap, "allow-bootstrap", true, "当 baseline 缺失时自动初始化")
flag.Parse()
now := time.Now()
cfg := perplexityPricingSignatureGuardConfig{
URL: url,
Fixture: fixture,
SnapshotDir: snapshotDir,
BaselinePath: baselinePath,
Timeout: time.Duration(timeoutSeconds) * time.Second,
AllowBootstrap: allowBootstrap,
}
result, err := runPerplexityPricingSignatureGuard(cfg, now)
if auditErr := persistPerplexityPricingSignatureAuditIfConfigured(cfg, result, now, err); auditErr != nil {
fmt.Fprintf(os.Stderr, "perplexity_pricing_signature_guard audit: %v\n", auditErr)
if err == nil {
err = auditErr
}
}
fmt.Println(formatPerplexityPricingSignatureGuardSummary(result))
if err != nil {
fmt.Fprintf(os.Stderr, "perplexity_pricing_signature_guard: %v\n", err)
os.Exit(1)
}
}