Add Temperature to Model struct
This commit is contained in:
@@ -9,9 +9,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Model struct {
|
type Model struct {
|
||||||
Name string
|
Name string
|
||||||
Reasoning bool
|
Reasoning bool
|
||||||
MaxTokens int
|
MaxTokens *int
|
||||||
|
Temperature *float32
|
||||||
}
|
}
|
||||||
|
|
||||||
type Provider struct {
|
type Provider struct {
|
||||||
@@ -89,11 +90,21 @@ func parseModels(rawModels []any) ([]Model, error) {
|
|||||||
if maxTokensVal, ok := rawModel["maxTokens"]; ok {
|
if maxTokensVal, ok := rawModel["maxTokens"]; ok {
|
||||||
// YAML numbers often unmarshal as int, sometimes float64. Handle int primarily.
|
// YAML numbers often unmarshal as int, sometimes float64. Handle int primarily.
|
||||||
if maxTokensInt, ok := maxTokensVal.(int); ok {
|
if maxTokensInt, ok := maxTokensVal.(int); ok {
|
||||||
parsedModel.MaxTokens = maxTokensInt
|
parsedModel.MaxTokens = &maxTokensInt
|
||||||
} else {
|
} else {
|
||||||
return nil, fmt.Errorf("Invalid 'maxTokens' type (%T) for model '%s'", maxTokensVal, parsedModel.Name)
|
return nil, fmt.Errorf("Invalid 'maxTokens' type (%T) for model '%s'", maxTokensVal, parsedModel.Name)
|
||||||
}
|
}
|
||||||
} // else: default is 0
|
} // else: default is nil
|
||||||
|
|
||||||
|
if temperatureVal, ok := rawModel["temperature"]; ok {
|
||||||
|
// YAML numbers often unmarshal as int, sometimes float64. Handle int primarily.
|
||||||
|
if temperatureFloat, ok := temperatureVal.(float64); ok {
|
||||||
|
asFloat32 := float32(temperatureFloat)
|
||||||
|
parsedModel.Temperature = &asFloat32
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("Invalid 'temperature' type (%T) for model '%s'", temperatureVal, parsedModel.Name)
|
||||||
|
}
|
||||||
|
} // else: default is nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("Invalid model definition type (%T) at index %d in provider '%s'", modelInterface, i)
|
return nil, fmt.Errorf("Invalid model definition type (%T) at index %d in provider '%s'", modelInterface, i)
|
||||||
|
|||||||
Reference in New Issue
Block a user