github.com/weaviate/weaviate@v1.24.6/modules/multi2vec-bind/vectorizer/texts.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/pkg/errors"
    18  	"github.com/weaviate/weaviate/entities/moduletools"
    19  	libvectorizer "github.com/weaviate/weaviate/usecases/vectorizer"
    20  )
    21  
    22  func (v *Vectorizer) Texts(ctx context.Context, inputs []string,
    23  	cfg moduletools.ClassConfig,
    24  ) ([]float32, error) {
    25  	res, err := v.client.Vectorize(ctx, inputs, []string{}, []string{}, []string{}, []string{}, []string{}, []string{})
    26  	if err != nil {
    27  		return nil, errors.Wrap(err, "remote client vectorize")
    28  	}
    29  	if len(inputs) != len(res.TextVectors) {
    30  		return nil, errors.New("inputs are not equal to vectors returned")
    31  	}
    32  	return libvectorizer.CombineVectors(res.TextVectors), nil
    33  }