Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions schema/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,95 @@ func TestConfig(t *testing.T) {
`,
fail: true,
},
// valid: minimal config with required fields only
{
config: `
{
"descriptor": {
"name": "xyz-3-8B-Instruct"
},
"config": {
"paramSize": "8b"
},
"modelfs": {
"type": "layers",
"diffIds": [
"sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
]
}
}
`,
fail: false,
},
// valid: full config with all optional fields populated
{
config: `
{
"descriptor": {
"createdAt": "2025-01-01T00:00:00Z",
"authors": ["xyz@xyz.com"],
"vendor": "XYZ Corp.",
"family": "xyz3",
"name": "xyz-3-8B-Instruct",
"version": "3.1",
"title": "XYZ 3 8B Instruct",
"description": "xyz is a large language model.",
"docURL": "https://www.xyz.com/get-started/",
"sourceURL": "https://github.com/xyz/xyz3",
"datasetsURL": ["https://www.xyz.com/datasets/"],
"revision": "1234567890",
"licenses": ["Apache-2.0"]
},
"config": {
"architecture": "transformer",
"format": "safetensors",
"paramSize": "8b",
"precision": "float16",
"quantization": "gptq",
"capabilities": {
"inputTypes": ["text"],
"outputTypes": ["text"],
"knowledgeCutoff": "2024-05-21T00:00:00Z",
"reasoning": true,
"toolUsage": false
}
},
"modelfs": {
"type": "layers",
"diffIds": [
"sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"sha256:abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
]
}
}
`,
fail: false,
},
// valid: multimodal model with image input and output
{
config: `
{
"descriptor": {
"name": "xyz-vl-7B"
},
"config": {
"architecture": "transformer",
"paramSize": "7b",
"capabilities": {
"inputTypes": ["text", "image"],
"outputTypes": ["text", "image", "embedding"]
}
},
"modelfs": {
"type": "layers",
"diffIds": [
"sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
]
}
}
`,
fail: false,
},
} {
r := strings.NewReader(tt.config)
err := schema.ValidatorMediaTypeModelConfig.Validate(r)
Expand Down
4 changes: 2 additions & 2 deletions schema/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ var validateByMediaType = map[Validator]validateFunc{
}

func validateConfig(buf []byte) error {
mc := v1.ModelConfig{}
model := v1.Model{}

err := json.Unmarshal(buf, &mc)
err := json.Unmarshal(buf, &model)
if err != nil {
return fmt.Errorf("config format mismatch: %w", err)
}
Expand Down
Loading