github.com/weaviate/weaviate@v1.24.6/modules/multi2vec-bind/vectorizer/fakes_for_test.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 vectorizer 13 14 import ( 15 "context" 16 17 "github.com/weaviate/weaviate/modules/multi2vec-bind/ent" 18 ) 19 20 type builder struct { 21 fakeClassConfig *fakeClassConfig 22 } 23 24 func newConfigBuilder() *builder { 25 return &builder{ 26 fakeClassConfig: &fakeClassConfig{config: map[string]interface{}{}}, 27 } 28 } 29 30 func (b *builder) addSetting(name string, value interface{}) *builder { 31 b.fakeClassConfig.config[name] = value 32 return b 33 } 34 35 func (b *builder) addWeights(textWeights, imageWeights, audioWeights, 36 videoWeights, imuWeights, thermalWeights, depthWeights []interface{}, 37 ) *builder { 38 weightSettings := map[string]interface{}{} 39 if textWeights != nil { 40 weightSettings["textFields"] = textWeights 41 } 42 if imageWeights != nil { 43 weightSettings["imageFields"] = imageWeights 44 } 45 if audioWeights != nil { 46 weightSettings["audioFields"] = audioWeights 47 } 48 if videoWeights != nil { 49 weightSettings["videoFields"] = videoWeights 50 } 51 if imuWeights != nil { 52 weightSettings["imuFields"] = imuWeights 53 } 54 if thermalWeights != nil { 55 weightSettings["thermalFields"] = thermalWeights 56 } 57 if depthWeights != nil { 58 weightSettings["depthFields"] = depthWeights 59 } 60 if len(weightSettings) > 0 { 61 b.fakeClassConfig.config["weights"] = weightSettings 62 } 63 return b 64 } 65 66 func (b *builder) build() *fakeClassConfig { 67 return b.fakeClassConfig 68 } 69 70 type fakeClassConfig struct { 71 config map[string]interface{} 72 } 73 74 func (c fakeClassConfig) Class() map[string]interface{} { 75 return c.config 76 } 77 78 func (c fakeClassConfig) ClassByModuleName(moduleName string) map[string]interface{} { 79 return c.config 80 } 81 82 func (c fakeClassConfig) Property(propName string) map[string]interface{} { 83 return c.config 84 } 85 86 func (c fakeClassConfig) Tenant() string { 87 return "" 88 } 89 90 func (f fakeClassConfig) TargetVector() string { 91 return "" 92 } 93 94 type fakeClient struct{} 95 96 func (c *fakeClient) Vectorize(ctx context.Context, 97 texts, images, audio, video, imu, thermal, depth []string, 98 ) (*ent.VectorizationResult, error) { 99 result := &ent.VectorizationResult{ 100 TextVectors: [][]float32{{1.0, 2.0, 3.0, 4.0, 5.0}}, 101 ImageVectors: [][]float32{{10.0, 20.0, 30.0, 40.0, 50.0}}, 102 } 103 return result, nil 104 }