github.com/weaviate/weaviate@v1.24.6/usecases/modulecomponents/arguments/nearThermal/param.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 package nearThermal 13 14 import ( 15 "errors" 16 ) 17 18 type NearThermalParams struct { 19 Thermal string 20 Certainty float64 21 Distance float64 22 WithDistance bool 23 TargetVectors []string 24 } 25 26 func (n NearThermalParams) GetCertainty() float64 { 27 return n.Certainty 28 } 29 30 func (n NearThermalParams) GetDistance() float64 { 31 return n.Distance 32 } 33 34 func (n NearThermalParams) SimilarityMetricProvided() bool { 35 return n.Certainty != 0 || n.WithDistance 36 } 37 38 func (n NearThermalParams) GetTargetVectors() []string { 39 return n.TargetVectors 40 } 41 42 func validateNearThermalFn(param interface{}) error { 43 nearThermal, ok := param.(*NearThermalParams) 44 if !ok { 45 return errors.New("'nearThermal' invalid parameter") 46 } 47 48 if len(nearThermal.Thermal) == 0 { 49 return errors.New("'nearThermal.thermal' needs to be defined") 50 } 51 52 if nearThermal.Certainty != 0 && nearThermal.WithDistance { 53 return errors.New( 54 "nearThermal cannot provide both distance and certainty") 55 } 56 57 if len(nearThermal.TargetVectors) > 1 { 58 return errors.New( 59 "nearThermal.targetVectors cannot provide more than 1 target vector value") 60 } 61 62 return nil 63 }