mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-24 16:41:30 +02:00
shared/llm normalizes Bedrock and Vertex model ids so both sides of the routing and pricing contract compare equal, but nothing did the same for a first-party Anthropic id. A client pinning "claude-sonnet-4-5-20250929" against a record registered as "claude-sonnet-4-5" denied as not-routable, and where a catch-all route carried it through, the price lookup missed and the request recorded no cost. Add NormalizeAnthropicModel beside the existing two and consult it after an exact match fails in the router's claim check, the pricing table, and the per-record price map. Exact matches still win, so an operator who registers two dated releases of the same family keeps them distinct.
30 lines
1.2 KiB
Go
30 lines
1.2 KiB
Go
package llm
|
|
|
|
import (
|
|
sharedllm "github.com/netbirdio/netbird/shared/llm"
|
|
)
|
|
|
|
// NormalizeBedrockModel strips an ARN wrapper, a cross-region inference-profile
|
|
// prefix, and the version/throughput suffix from a Bedrock model id so it
|
|
// matches the catalog/pricing key. Thin delegate to the shared implementation
|
|
// (shared/llm), which management also uses at synthesis time so both sides of
|
|
// the pricing / routing contract normalize identically.
|
|
func NormalizeBedrockModel(modelID string) string {
|
|
return sharedllm.NormalizeBedrockModel(modelID)
|
|
}
|
|
|
|
// NormalizeAnthropicModel strips the trailing "-YYYYMMDD" release-date suffix
|
|
// from an Anthropic model id so a dated id a client pins matches the undated
|
|
// one the operator registered. Thin delegate to shared/llm for the same
|
|
// contract reason as the two below.
|
|
func NormalizeAnthropicModel(modelID string) string {
|
|
return sharedllm.NormalizeAnthropicModel(modelID)
|
|
}
|
|
|
|
// NormalizeVertexModel strips the "@version" suffix from a Vertex AI model id
|
|
// so it matches the catalog/pricing key. Thin delegate to shared/llm, kept
|
|
// beside NormalizeBedrockModel for the same contract reason.
|
|
func NormalizeVertexModel(modelID string) string {
|
|
return sharedllm.NormalizeVertexModel(modelID)
|
|
}
|