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