Changeset 0.9.0 (#50)
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package providers
|
||||
|
||||
import (
|
||||
"git.gobha.me/xcaliber/chat-switchboard/capabilities"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/models"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -65,12 +67,12 @@ func (p *OpenRouterProvider) ListModels(ctx context.Context, cfg ProviderConfig)
|
||||
return nil, fmt.Errorf("openrouter decode models: %w", err)
|
||||
}
|
||||
|
||||
models := make([]Model, 0, len(result.Data))
|
||||
out := make([]Model, 0, len(result.Data))
|
||||
for _, m := range result.Data {
|
||||
// Start with known table, fall back to heuristic
|
||||
caps, found := LookupKnownModel(m.ID)
|
||||
caps, found := capabilities.LookupKnownModel(m.ID)
|
||||
if !found {
|
||||
caps = InferCapabilities(m.ID)
|
||||
caps = capabilities.InferCapabilities(m.ID)
|
||||
}
|
||||
|
||||
// Overlay context length from OpenRouter metadata
|
||||
@@ -93,12 +95,12 @@ func (p *OpenRouterProvider) ListModels(ctx context.Context, cfg ProviderConfig)
|
||||
caps.Streaming = true
|
||||
|
||||
// Parse pricing (OpenRouter uses per-token strings, convert to per-1M)
|
||||
var pricing *ModelPricing
|
||||
var pricing *models.ModelPricing
|
||||
if m.Pricing.Prompt != "" {
|
||||
inputPerToken, _ := strconv.ParseFloat(m.Pricing.Prompt, 64)
|
||||
outputPerToken, _ := strconv.ParseFloat(m.Pricing.Completion, 64)
|
||||
if inputPerToken > 0 || outputPerToken > 0 {
|
||||
pricing = &ModelPricing{
|
||||
pricing = &models.ModelPricing{
|
||||
InputPerM: inputPerToken * 1_000_000,
|
||||
OutputPerM: outputPerToken * 1_000_000,
|
||||
}
|
||||
@@ -116,7 +118,7 @@ func (p *OpenRouterProvider) ListModels(ctx context.Context, cfg ProviderConfig)
|
||||
name = m.ID
|
||||
}
|
||||
|
||||
models = append(models, Model{
|
||||
out = append(out, Model{
|
||||
ID: m.ID,
|
||||
Name: name,
|
||||
OwnedBy: ownedBy,
|
||||
@@ -124,7 +126,7 @@ func (p *OpenRouterProvider) ListModels(ctx context.Context, cfg ProviderConfig)
|
||||
Pricing: pricing,
|
||||
})
|
||||
}
|
||||
return models, nil
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// ── OpenRouter Wire Types ───────────────────
|
||||
|
||||
Reference in New Issue
Block a user