Repository: ollama/ollama
File: fs/ggml/ggml.go (Go)

Code before:
func (kv KV) ContextLength() uint64 {
	return uint64(kv.Uint("context_length"))
}

func (kv KV) ChatTemplate() string {
	return kv.String("tokenizer.chat_template")
}

func (kv KV) String(key string, defaultValue ...string) string {
	return keyValue(kv, key, append(defaultValue, "")...)
}

func (kv KV) Uint(key string, defaultValue ...uint32) uint32 {
	return keyValue(kv, key, append(defaultValue, 0)...)
}

func (kv KV) Float(key string, defaultValue ...float32) float32 {
	return keyValue(kv, key, append(defaultValue, 0)...)
}

func (kv KV) Bool(key string, defaultValue ...bool) bool {
	return keyValue(kv, key, append(defaultValue, false)...)
}

func (kv KV) Strings(key string, defaultValue ...[]string) []string {
	return keyValue(kv, key, &array[string]{}).values
}

func (kv KV) Ints(key string, defaultValue ...[]int32) []int32 {
	return keyValue(kv, key, &array[int32]{}).values
}

func (kv KV) Uints(key string, defaultValue ...[]uint32) []uint32 {
	return keyValue(kv, key, &array[uint32]{}).values
}

func (kv KV) Floats(key string, defaultValue ...[]float32) []float32 {
	return keyValue(kv, key, &array[float32]{}).values
}

func (kv KV) OllamaEngineRequired() bool {
	return slices.Contains([]string{
		"gemma3",
		"mistral3",
	}, kv.Architecture())
}

type valueTypes interface {
	uint8 | int8 | uint16 | int16 |
		uint32 | int32 | uint64 | int64 |
		string | float32 | float64 | bool

Review comment (suggestion):
is it intentional that `defaultValue` isn't used in any of these array functions? I see it wasn't previously either. I noticed this while rebasing #10238 on top of this

Code after:
func (kv KV) ContextLength() uint64 {
	return uint64(kv.Uint("context_length"))
}

func (kv KV) ChatTemplate() string {
	return kv.String("tokenizer.chat_template")
}

func (kv KV) String(key string, defaultValue ...string) string {
	return keyValue(kv, key, append(defaultValue, "")...)
}

func (kv KV) Uint(key string, defaultValue ...uint32) uint32 {
	return keyValue(kv, key, append(defaultValue, 0)...)
}

func (kv KV) Float(key string, defaultValue ...float32) float32 {
	return keyValue(kv, key, append(defaultValue, 0)...)
}

func (kv KV) Bool(key string, defaultValue ...bool) bool {
	return keyValue(kv, key, append(defaultValue, false)...)
}

func (kv KV) Strings(key string, defaultValue ...[]string) []string {
	return keyValue(kv, key, &array[string]{values: append(defaultValue, []string(nil))[0]}).values
}

func (kv KV) Ints(key string, defaultValue ...[]int32) []int32 {
	return keyValue(kv, key, &array[int32]{values: append(defaultValue, []int32(nil))[0]}).values
}

func (kv KV) Uints(key string, defaultValue ...[]uint32) []uint32 {
	return keyValue(kv, key, &array[uint32]{values: append(defaultValue, []uint32(nil))[0]}).values
}

func (kv KV) Floats(key string, defaultValue ...[]float32) []float32 {
	return keyValue(kv, key, &array[float32]{values: append(defaultValue, []float32(nil))[0]}).values
}

func (kv KV) OllamaEngineRequired() bool {
	return slices.Contains([]string{
		"gemma3",
		"mistral3",
	}, kv.Architecture())
}

type valueTypes interface {
	uint8 | int8 | uint16 | int16 |
		uint32 | int32 | uint64 | int64 |
		string | float32 | float64 | bool