embedding

package
v0.10.3-0...-96d0e78 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2025 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClusterIDKey string = "cluster_id"
)
View Source
const (
	Provider string = "provider"
)

Variables

This section is empty.

Functions

func HasNonBM25Functions

func HasNonBM25Functions(functions []*schemapb.FunctionSchema, outputIDs []int64) bool

Determine whether the column corresponding to outputIDs contains functions, except bm25 function, if outputIDs is empty, check all cols

func TextEmbeddingInputsCheck

func TextEmbeddingInputsCheck(name string, fields []*schemapb.FieldSchema) error

func TextEmbeddingOutputsCheck

func TextEmbeddingOutputsCheck(fields []*schemapb.FieldSchema) error

func ValidateFunctions

func ValidateFunctions(schema *schemapb.CollectionSchema, extraInfo *models.ModelExtraInfo) error

Since bm25 and embedding are implemented in different ways, the bm25 function is not verified here.

Types

type AliEmbeddingProvider

type AliEmbeddingProvider struct {
	// contains filtered or unexported fields
}

func NewAliDashScopeEmbeddingProvider

func NewAliDashScopeEmbeddingProvider(fieldSchema *schemapb.FieldSchema, functionSchema *schemapb.FunctionSchema, params map[string]string, credentials *credentials.Credentials, extraInfo *models.ModelExtraInfo) (*AliEmbeddingProvider, error)

func (*AliEmbeddingProvider) CallEmbedding

func (provider *AliEmbeddingProvider) CallEmbedding(ctx context.Context, texts []string, mode models.TextEmbeddingMode) (any, error)

func (*AliEmbeddingProvider) FieldDim

func (provider *AliEmbeddingProvider) FieldDim() int64

func (*AliEmbeddingProvider) MaxBatch

func (provider *AliEmbeddingProvider) MaxBatch() int

type BedRockRequest

type BedRockRequest struct {
	InputText  string `json:"inputText"`
	Dimensions int64  `json:"dimensions,omitempty"`
	Normalize  bool   `json:"normalize,omitempty"`
}

type BedRockResponse

type BedRockResponse struct {
	Embedding           []float32 `json:"embedding"`
	InputTextTokenCount int       `json:"inputTextTokenCount"`
}

type BedrockClient

type BedrockClient interface {
	InvokeModel(ctx context.Context, params *bedrockruntime.InvokeModelInput, optFns ...func(*bedrockruntime.Options)) (*bedrockruntime.InvokeModelOutput, error)
}

type BedrockEmbeddingProvider

type BedrockEmbeddingProvider struct {
	// contains filtered or unexported fields
}

func NewBedrockEmbeddingProvider

func NewBedrockEmbeddingProvider(fieldSchema *schemapb.FieldSchema, functionSchema *schemapb.FunctionSchema, c BedrockClient, params map[string]string, credentials *milvusCredentials.Credentials, extraInfo *models.ModelExtraInfo) (*BedrockEmbeddingProvider, error)

func (*BedrockEmbeddingProvider) CallEmbedding

func (provider *BedrockEmbeddingProvider) CallEmbedding(ctx context.Context, texts []string, _ models.TextEmbeddingMode) (any, error)

func (*BedrockEmbeddingProvider) FieldDim

func (provider *BedrockEmbeddingProvider) FieldDim() int64

func (*BedrockEmbeddingProvider) MaxBatch

func (provider *BedrockEmbeddingProvider) MaxBatch() int

type CohereEmbeddingProvider

type CohereEmbeddingProvider struct {
	// contains filtered or unexported fields
}

func NewCohereEmbeddingProvider

func NewCohereEmbeddingProvider(fieldSchema *schemapb.FieldSchema, functionSchema *schemapb.FunctionSchema, params map[string]string, credentials *credentials.Credentials, extraInfo *models.ModelExtraInfo) (*CohereEmbeddingProvider, error)

func (*CohereEmbeddingProvider) CallEmbedding

func (provider *CohereEmbeddingProvider) CallEmbedding(ctx context.Context, texts []string, mode models.TextEmbeddingMode) (any, error)

func (*CohereEmbeddingProvider) FieldDim

func (provider *CohereEmbeddingProvider) FieldDim() int64

func (*CohereEmbeddingProvider) MaxBatch

func (provider *CohereEmbeddingProvider) MaxBatch() int

type FunctionBase

type FunctionBase struct {
	// contains filtered or unexported fields
}

func NewFunctionBase

func NewFunctionBase(coll *schemapb.CollectionSchema, fSchema *schemapb.FunctionSchema) (*FunctionBase, error)

func (*FunctionBase) GetOutputFields

func (base *FunctionBase) GetOutputFields() []*schemapb.FieldSchema

func (*FunctionBase) GetSchema

func (base *FunctionBase) GetSchema() *schemapb.FunctionSchema

type FunctionExecutor

type FunctionExecutor struct {
	// contains filtered or unexported fields
}

func NewFunctionExecutor

func NewFunctionExecutor(schema *schemapb.CollectionSchema, functions []*schemapb.FunctionSchema, extraInfo *models.ModelExtraInfo) (*FunctionExecutor, error)

func (*FunctionExecutor) ProcessBulkInsert

func (executor *FunctionExecutor) ProcessBulkInsert(ctx context.Context, data *storage.InsertData) error

func (*FunctionExecutor) ProcessInsert

func (executor *FunctionExecutor) ProcessInsert(ctx context.Context, msg *msgstream.InsertMsg) error

func (*FunctionExecutor) ProcessSearch

func (executor *FunctionExecutor) ProcessSearch(ctx context.Context, req *internalpb.SearchRequest) error

type OpenAIEmbeddingProvider

type OpenAIEmbeddingProvider struct {
	// contains filtered or unexported fields
}

func NewAzureOpenAIEmbeddingProvider

func NewAzureOpenAIEmbeddingProvider(fieldSchema *schemapb.FieldSchema, functionSchema *schemapb.FunctionSchema, params map[string]string, credentials *credentials.Credentials, extraInfo *models.ModelExtraInfo) (*OpenAIEmbeddingProvider, error)

func NewOpenAIEmbeddingProvider

func NewOpenAIEmbeddingProvider(fieldSchema *schemapb.FieldSchema, functionSchema *schemapb.FunctionSchema, params map[string]string, credentials *credentials.Credentials, extraInfo *models.ModelExtraInfo) (*OpenAIEmbeddingProvider, error)

func (*OpenAIEmbeddingProvider) CallEmbedding

func (provider *OpenAIEmbeddingProvider) CallEmbedding(ctx context.Context, texts []string, _ models.TextEmbeddingMode) (any, error)

func (*OpenAIEmbeddingProvider) FieldDim

func (provider *OpenAIEmbeddingProvider) FieldDim() int64

func (*OpenAIEmbeddingProvider) MaxBatch

func (provider *OpenAIEmbeddingProvider) MaxBatch() int

type Runner

type Runner interface {
	GetSchema() *schemapb.FunctionSchema
	GetOutputFields() []*schemapb.FieldSchema
	GetCollectionName() string
	GetFunctionTypeName() string
	GetFunctionName() string
	GetFunctionProvider() string
	Check(ctx context.Context) error

	MaxBatch() int
	ProcessInsert(ctx context.Context, inputs []*schemapb.FieldData) ([]*schemapb.FieldData, error)
	ProcessSearch(ctx context.Context, placeholderGroup *commonpb.PlaceholderGroup) (*commonpb.PlaceholderGroup, error)
	ProcessBulkInsert(ctx context.Context, inputs []storage.FieldData) (map[storage.FieldID]storage.FieldData, error)
}

type SiliconflowEmbeddingProvider

type SiliconflowEmbeddingProvider struct {
	// contains filtered or unexported fields
}

func NewSiliconflowEmbeddingProvider

func NewSiliconflowEmbeddingProvider(fieldSchema *schemapb.FieldSchema, functionSchema *schemapb.FunctionSchema, params map[string]string, credentials *credentials.Credentials, extraInfo *models.ModelExtraInfo) (*SiliconflowEmbeddingProvider, error)

func (*SiliconflowEmbeddingProvider) CallEmbedding

func (provider *SiliconflowEmbeddingProvider) CallEmbedding(ctx context.Context, texts []string, _ models.TextEmbeddingMode) (any, error)

func (*SiliconflowEmbeddingProvider) FieldDim

func (provider *SiliconflowEmbeddingProvider) FieldDim() int64

func (*SiliconflowEmbeddingProvider) MaxBatch

func (provider *SiliconflowEmbeddingProvider) MaxBatch() int

type TeiEmbeddingProvider

type TeiEmbeddingProvider struct {
	// contains filtered or unexported fields
}

func NewTEIEmbeddingProvider

func NewTEIEmbeddingProvider(fieldSchema *schemapb.FieldSchema, functionSchema *schemapb.FunctionSchema, params map[string]string, credentials *credentials.Credentials, extraInfo *models.ModelExtraInfo) (*TeiEmbeddingProvider, error)

func (*TeiEmbeddingProvider) CallEmbedding

func (provider *TeiEmbeddingProvider) CallEmbedding(ctx context.Context, texts []string, mode models.TextEmbeddingMode) (any, error)

func (*TeiEmbeddingProvider) FieldDim

func (provider *TeiEmbeddingProvider) FieldDim() int64

func (*TeiEmbeddingProvider) MaxBatch

func (provider *TeiEmbeddingProvider) MaxBatch() int

type TextEmbeddingFunction

type TextEmbeddingFunction struct {
	FunctionBase
	// contains filtered or unexported fields
}

func NewTextEmbeddingFunction

func NewTextEmbeddingFunction(coll *schemapb.CollectionSchema, functionSchema *schemapb.FunctionSchema, extraInfo *models.ModelExtraInfo) (*TextEmbeddingFunction, error)

func (*TextEmbeddingFunction) Check

func (runner *TextEmbeddingFunction) Check(ctx context.Context) error

func (*TextEmbeddingFunction) GetCollectionName

func (runner *TextEmbeddingFunction) GetCollectionName() string

func (*TextEmbeddingFunction) GetFunctionName

func (runner *TextEmbeddingFunction) GetFunctionName() string

func (*TextEmbeddingFunction) GetFunctionProvider

func (runner *TextEmbeddingFunction) GetFunctionProvider() string

func (*TextEmbeddingFunction) GetFunctionTypeName

func (runner *TextEmbeddingFunction) GetFunctionTypeName() string

func (*TextEmbeddingFunction) MaxBatch

func (runner *TextEmbeddingFunction) MaxBatch() int

func (*TextEmbeddingFunction) ProcessBulkInsert

func (runner *TextEmbeddingFunction) ProcessBulkInsert(ctx context.Context, inputs []storage.FieldData) (map[storage.FieldID]storage.FieldData, error)

func (*TextEmbeddingFunction) ProcessInsert

func (runner *TextEmbeddingFunction) ProcessInsert(ctx context.Context, inputs []*schemapb.FieldData) ([]*schemapb.FieldData, error)

func (*TextEmbeddingFunction) ProcessSearch

func (runner *TextEmbeddingFunction) ProcessSearch(ctx context.Context, placeholderGroup *commonpb.PlaceholderGroup) (*commonpb.PlaceholderGroup, error)

type VertexAIEmbeddingProvider

type VertexAIEmbeddingProvider struct {
	// contains filtered or unexported fields
}

func NewVertexAIEmbeddingProvider

func NewVertexAIEmbeddingProvider(fieldSchema *schemapb.FieldSchema, functionSchema *schemapb.FunctionSchema, c *vertexai.VertexAIEmbedding, params map[string]string, credentials *credentials.Credentials, extraInfo *models.ModelExtraInfo) (*VertexAIEmbeddingProvider, error)

func (*VertexAIEmbeddingProvider) CallEmbedding

func (provider *VertexAIEmbeddingProvider) CallEmbedding(ctx context.Context, texts []string, mode models.TextEmbeddingMode) (any, error)

func (*VertexAIEmbeddingProvider) FieldDim

func (provider *VertexAIEmbeddingProvider) FieldDim() int64

func (*VertexAIEmbeddingProvider) MaxBatch

func (provider *VertexAIEmbeddingProvider) MaxBatch() int

type VoyageAIEmbeddingProvider

type VoyageAIEmbeddingProvider struct {
	// contains filtered or unexported fields
}

func NewVoyageAIEmbeddingProvider

func NewVoyageAIEmbeddingProvider(fieldSchema *schemapb.FieldSchema, functionSchema *schemapb.FunctionSchema, params map[string]string, credentials *credentials.Credentials, extraInfo *models.ModelExtraInfo) (*VoyageAIEmbeddingProvider, error)

func (*VoyageAIEmbeddingProvider) CallEmbedding

func (provider *VoyageAIEmbeddingProvider) CallEmbedding(ctx context.Context, texts []string, mode models.TextEmbeddingMode) (any, error)

func (*VoyageAIEmbeddingProvider) FieldDim

func (provider *VoyageAIEmbeddingProvider) FieldDim() int64

func (*VoyageAIEmbeddingProvider) MaxBatch

func (provider *VoyageAIEmbeddingProvider) MaxBatch() int

type ZillizEmbeddingProvider

type ZillizEmbeddingProvider struct {
	// contains filtered or unexported fields
}

func NewZillizEmbeddingProvider

func NewZillizEmbeddingProvider(fieldSchema *schemapb.FieldSchema, functionSchema *schemapb.FunctionSchema, params map[string]string, extraInfo *models.ModelExtraInfo) (*ZillizEmbeddingProvider, error)

func (*ZillizEmbeddingProvider) CallEmbedding

func (provider *ZillizEmbeddingProvider) CallEmbedding(ctx context.Context, texts []string, mode models.TextEmbeddingMode) (any, error)

func (*ZillizEmbeddingProvider) FieldDim

func (provider *ZillizEmbeddingProvider) FieldDim() int64

func (*ZillizEmbeddingProvider) MaxBatch

func (provider *ZillizEmbeddingProvider) MaxBatch() int

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL