Skip to content

Commit c4bbb98

Browse files
committed
fix remaining convertors
1 parent 0d27e9b commit c4bbb98

File tree

4 files changed

+31
-18
lines changed

4 files changed

+31
-18
lines changed

internal/adapter/converter/openai_converter.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ type OpenAIModelData struct {
2222
}
2323

2424
// OpenAIConverter converts models to OpenAI-compatible format
25-
type OpenAIConverter struct{}
25+
type OpenAIConverter struct {
26+
*BaseConverter
27+
}
2628

2729
// NewOpenAIConverter creates a new OpenAI format converter
2830
func NewOpenAIConverter() ports.ModelResponseConverter {
29-
return &OpenAIConverter{}
31+
return &OpenAIConverter{
32+
BaseConverter: NewBaseConverter("openai"),
33+
}
3034
}
3135

3236
func (c *OpenAIConverter) GetFormatName() string {

internal/adapter/converter/unified_converter.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,15 @@ type EndpointStatus struct {
4242
}
4343

4444
// UnifiedConverter converts models to the default Olla unified format
45-
type UnifiedConverter struct{}
45+
type UnifiedConverter struct {
46+
*BaseConverter
47+
}
4648

4749
// NewUnifiedConverter creates a new unified format converter
4850
func NewUnifiedConverter() ports.ModelResponseConverter {
49-
return &UnifiedConverter{}
51+
return &UnifiedConverter{
52+
BaseConverter: NewBaseConverter("unified"),
53+
}
5054
}
5155

5256
func (c *UnifiedConverter) GetFormatName() string {
@@ -176,12 +180,16 @@ func matchesTypeFilter(model *domain.UnifiedModel, filterType string) bool {
176180
return true
177181
}
178182

179-
// Check metadata first
180-
if modelType, ok := model.Metadata["type"].(string); ok && modelType == filterType {
183+
// Use base converter to determine model type
184+
base := NewBaseConverter("")
185+
modelType := base.DetermineModelType(model, "")
186+
187+
// If model type matches directly, return true
188+
if modelType == filterType {
181189
return true
182190
}
183191

184-
// Check capabilities as fallback
192+
// Also check capabilities for backward compatibility
185193
return matchesTypeByCapabilities(model.Capabilities, filterType)
186194
}
187195

internal/adapter/converter/vllm_converter.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ type VLLMModelData = profile.VLLMModel
1616
type VLLMModelPermission = profile.VLLMModelPermission
1717

1818
// VLLMConverter converts models to vLLM-compatible format with extended metadata
19-
type VLLMConverter struct{}
19+
type VLLMConverter struct {
20+
*BaseConverter
21+
}
2022

2123
// NewVLLMConverter creates a new vLLM format converter
2224
func NewVLLMConverter() ports.ModelResponseConverter {
23-
return &VLLMConverter{}
25+
return &VLLMConverter{
26+
BaseConverter: NewBaseConverter(constants.ProviderTypeVLLM),
27+
}
2428
}
2529

2630
func (c *VLLMConverter) GetFormatName() string {
@@ -91,14 +95,11 @@ func (c *VLLMConverter) convertModel(model *domain.UnifiedModel) *profile.VLLMMo
9195

9296
// findVLLMNativeName looks for the native vLLM name from aliases
9397
func (c *VLLMConverter) findVLLMNativeName(model *domain.UnifiedModel) string {
94-
// Check aliases for vLLM source - this reliably identifies vLLM models
95-
// We don't check NativeName for slashes as other providers (Ollama, etc.) also use them
96-
for _, alias := range model.Aliases {
97-
if alias.Source == constants.ProviderTypeVLLM {
98-
return alias.Name
99-
}
98+
// Use base converter to find vLLM-specific alias
99+
alias, found := c.BaseConverter.FindProviderAlias(model)
100+
if found {
101+
return alias
100102
}
101-
102103
return ""
103104
}
104105

internal/adapter/converter/vllm_converter_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func TestVLLMConverter_GetFormatName(t *testing.T) {
207207
}
208208

209209
func TestVLLMConverter_determineOwner(t *testing.T) {
210-
converter := &VLLMConverter{}
210+
converter := NewVLLMConverter().(*VLLMConverter)
211211

212212
tests := []struct {
213213
name string
@@ -245,7 +245,7 @@ func TestVLLMConverter_determineOwner(t *testing.T) {
245245
}
246246

247247
func TestVLLMConverter_findVLLMNativeName(t *testing.T) {
248-
converter := &VLLMConverter{}
248+
converter := NewVLLMConverter().(*VLLMConverter)
249249

250250
t.Run("only finds vLLM name from aliases with vllm source", func(t *testing.T) {
251251
// Test that slash-based names from non-vLLM sources are ignored

0 commit comments

Comments
 (0)