Documentation
¶
Index ¶
Constants ¶
View Source
const ( BaseLLMURL = "https://basellm.github.io/llm-metadata/api/newapi/ratio_config-v1-base.json" ModelsDevURL = "https://models.dev/api.json" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ModelPricing ¶
type PriceCandidate ¶ added in v0.0.6
type PriceCandidate struct {
Source string // "basellm" | "models.dev"
Provider string // models.dev 的 provider id;basellm 为 ""
MatchType string // "exact" | "fuzzy"
MatchedName string
Pricing ModelPricing
}
type Recommendation ¶ added in v0.0.6
type Recommendation struct {
Price ResolvedPrice
Provenance string // "models.dev (anthropic)" / "basellm"
Confidence string // "high" | "needs_review"
ReviewReasons []string
}
func ResolvePrice ¶ added in v0.0.6
func ResolvePrice(candidates []PriceCandidate, cfg ResolveConfig) Recommendation
ResolvePrice 把某模型的全部源×provider 候选收敛成唯一推荐价。
type ResolveConfig ¶ added in v0.0.6
type ResolvedPrice ¶ added in v0.0.6
type ResolvedPrice struct {
InputPrice, OutputPrice, CacheReadPrice, CacheWritePrice float64
}
ResolvedPrice 用裸 float64(cache 缺失记 0),与 DB/apply 语义一致。
type SourceData ¶ added in v0.0.6
type SourceData map[string][]SourceModelPrice
SourceData: modelID -> 该 modelID 在各 provider 下的全部候选。 basellm 每个 modelID 一条;models.dev 每个 modelID 可能多条(多 provider 托管)。
func ConvertBaseLLM ¶
func ConvertBaseLLM(data []byte) (SourceData, error)
func ConvertModelsDev ¶
func ConvertModelsDev(data []byte) (SourceData, error)
type SourceModelPrice ¶ added in v0.0.6
type SourceModelPrice struct {
Provider string
Pricing ModelPricing
}
SourceModelPrice 是某个 modelID 在某个 provider 下的一条候选价。 basellm 没有 provider 概念,Provider 留空。
func MatchAll ¶ added in v0.0.6
func MatchAll(modelName string, source SourceData) (matchType, matchedName string, prices []SourceModelPrice, ok bool)
MatchAll 在 source 中匹配 modelName,返回命中名下的全部 provider 候选。 先精确、再模糊(normalize 后取最短、字母序最早的源端名)。
Click to show internal directories.
Click to hide internal directories.