Skip to content
Merged
40 changes: 0 additions & 40 deletions modules/aws/module.go

This file was deleted.

98 changes: 98 additions & 0 deletions modules/aws/modules.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package aws

import (
"github.com/weaviate/weaviate-go-client/v6/modules"
"github.com/weaviate/weaviate-go-client/v6/modules/internal"
)

func init() {
modules.Register(*new(Text2Vec))
modules.Register(*new(Multi2Vec))
}

// Text2Vec is a vectorizer for text properties based on the text2vec-aws module.
// Unset fields inherit the server defaults.
//
// See [Weaviate Docs - text2vec-aws].
//
// [Weaviate Docs - text2vec-aws]: https://docs.weaviate.io/weaviate/model-providers/aws/embeddings
type Text2Vec struct {
// BedrockModel is the Bedrock model ID.
BedrockModel string `json:"model,omitempty"`
// Dimensions is the size of the output vectors.
Dimensions int `json:"dimensions,omitzero"`
// Properties limits vectorization to these properties.
// By default, all text properties are vectorized.
Properties []string `json:"properties,omitempty"`
// Service selects the AWS service that hosts the model.
Service string `json:"service,omitempty"`
// Region is the AWS region to run the model in.
Region string `json:"region,omitempty"`
// SageMakerEndpoint is the endpoint name.
SageMakerEndpoint string `json:"endpoint,omitempty"`
// SageMakerModel for multi-model endpoints.
SageMakerModel string `json:"targetModel,omitempty"`
// SageMakerVariant is the production variant of the [SageMakerModel].
SageMakerVariant string `json:"targetVariant,omitempty"`
}

func (Text2Vec) Name() string { return "text2vec-aws" }

const (
Bedrock = "bedrock"
SageMaker = "sagemaker"
)

// Multi2Vec is a vectorizer for text and image properties based on the multi2vec-aws module.
// Unset fields inherit the server defaults.
//
// See [Weaviate Docs - AWS embeddings].
//
// [Weaviate Docs - AWS embeddings]: https://docs.weaviate.io/weaviate/model-providers/aws/embeddings
type Multi2Vec struct {
// Model is the Bedrock model ID.
Model string
// Dimensions is the size of the output vectors.
Dimensions int
// Region is the AWS region to run the model in.
Region string

TextFields []modules.WeightedField
ImageFields []modules.WeightedField
}

func (Multi2Vec) Name() string { return "multi2vec-aws" }

type multi2vecJSON struct {
Model string `json:"model,omitempty"`
Dimensions int `json:"dimensions,omitzero"`
Region string `json:"region,omitempty"`
}

func (m2v Multi2Vec) EncodeMap() (map[string]any, error) {
return internal.EncodeWithWeightedFields(multi2vecJSON{
Model: m2v.Model,
Dimensions: m2v.Dimensions,
Region: m2v.Region,
}, internal.WeightedFields{
TextFields: m2v.TextFields,
ImageFields: m2v.ImageFields,
})
}

func (m2v *Multi2Vec) DecodeMap(m map[string]any) error {
var dest multi2vecJSON
wfs, err := internal.DecodeWithWeightedFields(m, &dest)
if err != nil {
return err
}

*m2v = Multi2Vec{
Model: dest.Model,
Dimensions: dest.Dimensions,
Region: dest.Region,
TextFields: wfs.TextFields,
ImageFields: wfs.ImageFields,
}
return nil
}
61 changes: 61 additions & 0 deletions modules/bind/modules.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package bind

import (
"github.com/weaviate/weaviate-go-client/v6/modules"
"github.com/weaviate/weaviate-go-client/v6/modules/internal"
)

func init() {
modules.Register(*new(Multi2Vec))
}

// Multi2Vec is a vectorizer for text, image, audio, video, IMU, thermal and depth properties based on the multi2vec-bind module.
//
// See [Weaviate Docs - multi2vec-bind].
//
// [Weaviate Docs - multi2vec-bind]: https://docs.weaviate.io/weaviate/model-providers/imagebind/embeddings-multimodal
type Multi2Vec struct {
// Each *Fields list names the properties of one modality to vectorize.
TextFields []modules.WeightedField `json:"-"`
ImageFields []modules.WeightedField `json:"-"`
AudioFields []modules.WeightedField `json:"-"`
VideoFields []modules.WeightedField `json:"-"`
DepthFields []modules.WeightedField `json:"-"`
ThermalFields []modules.WeightedField `json:"-"`
IMUFields []modules.WeightedField `json:"-"`
}

func (Multi2Vec) Name() string { return "multi2vec-bind" }

func (m2v Multi2Vec) EncodeMap() (map[string]any, error) {
return internal.EncodeWithWeightedFields(nil, internal.WeightedFields{
ImageFields: m2v.ImageFields,
TextFields: m2v.TextFields,
AudioFields: m2v.AudioFields,
VideoFields: m2v.VideoFields,
DepthFields: m2v.DepthFields,
ThermalFields: m2v.ThermalFields,
IMUFields: m2v.IMUFields,
})
}

func (m2v *Multi2Vec) DecodeMap(m map[string]any) error {
type multi2vecJSON Multi2Vec // Avoid recursive calls to DecodeMap

var dest multi2vecJSON
wfs, err := internal.DecodeWithWeightedFields(m, &dest)
if err != nil {
return err
}

*m2v = Multi2Vec{
TextFields: wfs.TextFields,
ImageFields: wfs.ImageFields,
AudioFields: wfs.AudioFields,
VideoFields: wfs.VideoFields,
DepthFields: wfs.DepthFields,
ThermalFields: wfs.ThermalFields,
IMUFields: wfs.IMUFields,
}
return nil
}
54 changes: 54 additions & 0 deletions modules/clip/modules.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package clip

import (
"github.com/weaviate/weaviate-go-client/v6/modules"
"github.com/weaviate/weaviate-go-client/v6/modules/internal"
)

func init() {
modules.Register(*new(Multi2Vec))
}

// Multi2Vec is a vectorizer for text and image properties based on the multi2vec-clip module.
// Unset fields inherit the server defaults.
//
// See [Weaviate Docs - multi2vec-clip].
//
// [Weaviate Docs - multi2vec-clip]: https://docs.weaviate.io/weaviate/model-providers/transformers/embeddings-multimodal
type Multi2Vec struct {
// InferenceURL is the inference container URL.
InferenceURL string
// TextFields and ImageFields name the properties to vectorize.
TextFields []modules.WeightedField `json:"-"`
ImageFields []modules.WeightedField `json:"-"`
}

func (Multi2Vec) Name() string { return "multi2vec-clip" }

type multi2vecJSON struct {
InferenceURL string `json:"inferenceUrl,omitempty"`
}

func (m2v Multi2Vec) EncodeMap() (map[string]any, error) {
return internal.EncodeWithWeightedFields(multi2vecJSON{
InferenceURL: m2v.InferenceURL,
}, internal.WeightedFields{
TextFields: m2v.TextFields,
ImageFields: m2v.ImageFields,
})
}

func (m2v *Multi2Vec) DecodeMap(m map[string]any) error {
var dest multi2vecJSON
wfs, err := internal.DecodeWithWeightedFields(m, &dest)
if err != nil {
return err
}

*m2v = Multi2Vec{
InferenceURL: dest.InferenceURL,
TextFields: wfs.TextFields,
ImageFields: wfs.ImageFields,
}
return nil
}
65 changes: 64 additions & 1 deletion modules/cohere/module.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package cohere

import "github.com/weaviate/weaviate-go-client/v6/modules"
import (
"github.com/weaviate/weaviate-go-client/v6/modules"
"github.com/weaviate/weaviate-go-client/v6/modules/internal"
)

func init() {
modules.Register(*new(Text2Vec))
modules.Register(*new(Multi2Vec))
}

// Text2Vec is a vectorizer for text properties based on the text2vec-cohere module.
Expand Down Expand Up @@ -35,3 +39,62 @@ const (
TruncateLeft = "LEFT"
TruncateRight = "RIGHT"
)

// Multi2Vec is a vectorizer for text and image properties based on the multi2vec-cohere module.
// Unset fields inherit the server defaults.
//
// See [Weaviate Docs - multi2vec-cohere].
//
// [Weaviate Docs - multi2vec-cohere]: https://docs.weaviate.io/weaviate/model-providers/cohere/embeddings-multimodal
type Multi2Vec struct {
// BaseURL overrides the default request URL, e.g. a proxy.
BaseURL string
// Model is the embedding model name.
Model string
// Dimensions is the size of the output vectors.
Dimensions int
// Truncate sets how inputs longer than the model's context are cut.
Truncate string
// TextFields and ImageFields name the properties to vectorize.
TextFields []modules.WeightedField `json:"-"`
ImageFields []modules.WeightedField `json:"-"`
}

func (Multi2Vec) Name() string { return "multi2vec-cohere" }

type multi2vecJSON struct {
BaseURL string `json:"baseURL,omitempty"`
Model string `json:"model,omitempty"`
Dimensions int `json:"dimensions,omitzero"`
Truncate string `json:"truncate,omitempty"`
}

func (m2v Multi2Vec) EncodeMap() (map[string]any, error) {
return internal.EncodeWithWeightedFields(multi2vecJSON{
BaseURL: m2v.BaseURL,
Model: m2v.Model,
Dimensions: m2v.Dimensions,
Truncate: m2v.Truncate,
}, internal.WeightedFields{
TextFields: m2v.TextFields,
ImageFields: m2v.ImageFields,
})
}

func (m2v *Multi2Vec) DecodeMap(m map[string]any) error {
var dest multi2vecJSON
wfs, err := internal.DecodeWithWeightedFields(m, &dest)
if err != nil {
return err
}

*m2v = Multi2Vec{
BaseURL: dest.BaseURL,
Model: dest.Model,
Dimensions: dest.Dimensions,
Truncate: dest.Truncate,
TextFields: wfs.TextFields,
ImageFields: wfs.ImageFields,
}
return nil
}
45 changes: 0 additions & 45 deletions modules/google/module.go

This file was deleted.

Loading
Loading