index

package
v0.6.9 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

func New

func New(ctx context.Context, dsn string, autoMigrate bool) (*DB, error)

func (*DB) AutoMigrate

func (db *DB) AutoMigrate() error

func (*DB) Check

func (db *DB) Check(w http.ResponseWriter, _ *http.Request)

func (*DB) Close

func (db *DB) Close() error

func (*DB) ExportDatasetsToFile added in v0.1.7

func (db *DB) ExportDatasetsToFile(ctx context.Context, path string, ids ...string) error

func (*DB) ImportDatasetsFromFile added in v0.1.7

func (db *DB) ImportDatasetsFromFile(ctx context.Context, path string) error

func (*DB) UpdateDataset added in v0.1.8

func (db *DB) UpdateDataset(ctx context.Context, dataset Dataset) error

func (*DB) WithContext

func (db *DB) WithContext(ctx context.Context) *gorm.DB

type Dataset

type Dataset struct {
	ID                       string                      `gorm:"primaryKey" json:"id"`
	EmbeddingsProviderConfig *config.ModelProviderConfig `json:"embeddingsProviderConfig,omitempty" gorm:"serializer:json"`
	Files                    []File                      `gorm:"foreignKey:Dataset;references:ID;constraint:OnDelete:CASCADE;"`
	Metadata                 map[string]any              `json:"metadata,omitempty" gorm:"serializer:json"`
}

Dataset refers to a VectorDB data space. @Description Dataset refers to a VectorDB data space.

func GetDataset

func GetDataset(db *gorm.DB, id string) (*Dataset, error)

func (*Dataset) ReplaceMetadata added in v0.1.8

func (d *Dataset) ReplaceMetadata(metadata map[string]interface{})

ReplaceMetadata replaces the metadata of the dataset with the given metadata.

func (*Dataset) SetMetadataField added in v0.1.8

func (d *Dataset) SetMetadataField(key string, value interface{})

SetMetadataField sets a metadata field in the dataset. If the metadata does not exist, it will be created. If the metadata field already exists, it will be overwritten.

func (*Dataset) UpdateMetadata added in v0.1.8

func (d *Dataset) UpdateMetadata(metadata map[string]interface{})

UpdateMetadata updates the metadata of the dataset with the given metadata. If a metadata field already exists, it will be overwritten. If a metadata field does not exist, it will be created. Existing metadata fields that are not present in the given metadata will remain unchanged.

type Document

type Document struct {
	ID      string `gorm:"primaryKey" json:"id"`
	Dataset string `gorm:"primaryKey" json:"dataset"` // Foreign key to Dataset, part of composite primary key with FileID
	FileID  string `gorm:"primaryKey" json:"file_id"` // Foreign key to File, part of composite primary key with Dataset
}

type File

type File struct {
	ID        string     `gorm:"primaryKey" json:"id"`
	Dataset   string     `gorm:"primaryKey" json:"dataset"` // Foreign key to Dataset
	Documents []Document `gorm:"foreignKey:FileID,Dataset;references:ID,Dataset;constraint:OnDelete:CASCADE;"`
	// File metadata, commonly used for deduplication
	FileMetadata `json:",inline"`
}

type FileMetadata

type FileMetadata struct {
	Name         string    `json:"name"`
	AbsolutePath string    `json:"absolute_path"`
	Size         int64     `json:"size"`
	ModifiedAt   time.Time `json:"modified_at"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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