github.com/weaviate/weaviate@v1.24.6/modules/text2vec-transformers/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/text2vec-transformers/ent" 18 ) 19 20 type fakeClient struct { 21 lastInput string 22 lastConfig ent.VectorizationConfig 23 } 24 25 func (c *fakeClient) VectorizeObject(ctx context.Context, 26 text string, cfg ent.VectorizationConfig, 27 ) (*ent.VectorizationResult, error) { 28 c.lastInput = text 29 c.lastConfig = cfg 30 return &ent.VectorizationResult{ 31 Vector: []float32{0, 1, 2, 3}, 32 Dimensions: 4, 33 Text: text, 34 }, nil 35 } 36 37 func (c *fakeClient) VectorizeQuery(ctx context.Context, 38 text string, cfg ent.VectorizationConfig, 39 ) (*ent.VectorizationResult, error) { 40 return c.VectorizeObject(ctx, text, cfg) 41 } 42 43 type fakeClassConfig struct { 44 classConfig map[string]interface{} 45 vectorizeClassName bool 46 vectorizePropertyName bool 47 skippedProperty string 48 excludedProperty string 49 poolingStrategy string 50 } 51 52 func (f fakeClassConfig) Class() map[string]interface{} { 53 classSettings := map[string]interface{}{ 54 "vectorizeClassName": f.vectorizeClassName, 55 "poolingStrategy": f.poolingStrategy, 56 } 57 return classSettings 58 } 59 60 func (f fakeClassConfig) ClassByModuleName(moduleName string) map[string]interface{} { 61 return f.classConfig 62 } 63 64 func (f fakeClassConfig) Property(propName string) map[string]interface{} { 65 if propName == f.skippedProperty { 66 return map[string]interface{}{ 67 "skip": true, 68 } 69 } 70 if propName == f.excludedProperty { 71 return map[string]interface{}{ 72 "vectorizePropertyName": false, 73 } 74 } 75 if f.vectorizePropertyName { 76 return map[string]interface{}{ 77 "vectorizePropertyName": true, 78 } 79 } 80 return nil 81 } 82 83 func (f fakeClassConfig) Tenant() string { 84 return "" 85 } 86 87 func (f fakeClassConfig) TargetVector() string { 88 return "" 89 }