Documentation
¶
Index ¶
- Constants
- Variables
- func CreateCollectionInTransaction(tx *gorm.DB, c *Collection) error
- func CreateCollectionMetadataInTransaction(tx *gorm.DB, cm *CollectionMetadata) error
- func DeleteAllCollectionMetadatasByVectorStoreIDInTransaction(tx *gorm.DB, vectorStoreID string) error
- func DeleteAllFilesByVectorStoreIDInTransaction(tx *gorm.DB, vectorStoreID string) error
- func DeleteCollectionInTransaction(tx *gorm.DB, projectID string, vectorStoreID string) error
- func DeleteCollectionMetadataInTransaction(tx *gorm.DB, id uint) error
- func UpdateCollectionInTransaction(tx *gorm.DB, nc *Collection) error
- func UpdateCollectionMetadataInTransaction(tx *gorm.DB, cm *CollectionMetadata) error
- type ChunkingStrategyType
- type Collection
- type CollectionMetadata
- type CollectionStatus
- type ExpiresAfterAnchor
- type File
- type FileStatus
- type LastErrorCode
- type S
- func (s *S) AutoMigrate() error
- func (s *S) CreateCollection(c *Collection) error
- func (s *S) CreateCollectionMetadata(cm *CollectionMetadata) error
- func (s *S) CreateFile(f *File) error
- func (s *S) DeleteAllCollectionMetadatasByVectorStoreID(vectorStoreID string) error
- func (s *S) DeleteAllFilesByVectorStoreID(vectorStoreID string) error
- func (s *S) DeleteCollection(projectID string, vectorStoreID string) error
- func (s *S) DeleteCollectionMetadata(id uint) error
- func (s *S) DeleteFile(vectorStoreID, fileID string) error
- func (s *S) GetCollectionByName(projectID, name string) (*Collection, error)
- func (s *S) GetCollectionByVectorStoreID(projectID string, vectorStoreID string) (*Collection, error)
- func (s *S) GetFileByFileID(vectorStoreID, fileID string) (*File, error)
- func (s *S) ListCollectionMetadataByVectorStoreID(vectorStoreID string) ([]*CollectionMetadata, error)
- func (s *S) ListCollections(projectID string) ([]*Collection, error)
- func (s *S) ListCollectionsWithPagination(projectID string, afterCreatedAt time.Time, afterID uint, order string, ...) ([]*Collection, bool, error)
- func (s *S) ListFiles(vectorStoreID string) ([]*File, error)
- func (s *S) ListFilesWithPagination(vectorStoreID string, afterCreatedAt time.Time, afterID uint, order string, ...) ([]*File, bool, error)
- func (s *S) Transaction(f func(*gorm.DB) error) error
- func (s *S) UpdateCollection(nc *Collection) error
- func (s *S) UpdateCollectionMetadata(cm *CollectionMetadata) error
Constants ¶
const ( // CollectionStatusExpired represents the expired status. CollectionStatusExpired CollectionStatus = "expired" // CollectionStatusInProgress represents the in_progress status. CollectionStatusInProgress CollectionStatus = "in_progress" // CollectionStatusCompleted represents the completed status. CollectionStatusCompleted CollectionStatus = "completed" // ExpiresAfterAnchorLastActiveAt represents the anchor for the expiration time based on the last_active_at time. ExpiresAfterAnchorLastActiveAt ExpiresAfterAnchor = "last_active_at" )
const ( // FileStatusInProgress represents the in_progress status. FileStatusInProgress FileStatus = "in_progress" // FileStatusCompleted represents the completed status. FileStatusCompleted FileStatus = "completed" // FileStatusFailed represents the failed status. FileStatusFailed FileStatus = "failed" // FileStatusCancelled represents the cancelled status. FileStatusCancelled FileStatus = "cancelled" // LastErrorCodeNone represents no error. LastErrorCodeNone LastErrorCode = "" // LastErrorCodeServerError represents a server error. LastErrorCodeServerError LastErrorCode = "server_error" // LastErrorCodeRateLimitExceeded represents a rate limit exceeded error. LastErrorCodeRateLimitExceeded LastErrorCode = "rate_limit_exceeded" // ChunkingStrategyTypeAuto represents the auto chunking strategy. ChunkingStrategyTypeAuto ChunkingStrategyType = "auto" // ChunkingStrategyTypeStatic represents the static chunking strategy. ChunkingStrategyTypeStatic ChunkingStrategyType = "static" )
Variables ¶
var ( // ErrConcurrentUpdate is returned when there is a concurrent update. ErrConcurrentUpdate = fmt.Errorf("store: concurrent update") )
Functions ¶
func CreateCollectionInTransaction ¶
func CreateCollectionInTransaction(tx *gorm.DB, c *Collection) error
CreateCollectionInTransaction creates a new collection.
func CreateCollectionMetadataInTransaction ¶
func CreateCollectionMetadataInTransaction(tx *gorm.DB, cm *CollectionMetadata) error
CreateCollectionMetadataInTransaction creates a new collection metadata.
func DeleteAllCollectionMetadatasByVectorStoreIDInTransaction ¶
func DeleteAllCollectionMetadatasByVectorStoreIDInTransaction(tx *gorm.DB, vectorStoreID string) error
DeleteAllCollectionMetadatasByVectorStoreIDInTransaction deletes all metadata of the collection.
func DeleteAllFilesByVectorStoreIDInTransaction ¶
DeleteAllFilesByVectorStoreIDInTransaction deletes all files of the collection.
func DeleteCollectionInTransaction ¶
DeleteCollectionInTransaction deletes the collection.
func DeleteCollectionMetadataInTransaction ¶
DeleteCollectionMetadataInTransaction deletes the metadata for the collection.
func UpdateCollectionInTransaction ¶
func UpdateCollectionInTransaction(tx *gorm.DB, nc *Collection) error
UpdateCollectionInTransaction updates the collection.
func UpdateCollectionMetadataInTransaction ¶
func UpdateCollectionMetadataInTransaction(tx *gorm.DB, cm *CollectionMetadata) error
UpdateCollectionMetadataInTransaction updates the metadata of a collection.
Types ¶
type ChunkingStrategyType ¶
type ChunkingStrategyType string
ChunkingStrategyType represents the type of chunking strategy.
type Collection ¶
type Collection struct {
gorm.Model
TenantID string
OrganizationID string
ProjectID string `gorm:"uniqueIndex:idx_collection_project_id_name"`
// VectorStoreID is the ID of the vector store that is externally visible in the API.
// This is also used as the name of the Milvus collection.
VectorStoreID string `gorm:"uniqueIndex"`
// CollectionID is the ID of the Milvus collection.
CollectionID int64 `gorm:"uniqueIndex"`
Name string `gorm:"uniqueIndex:idx_collection_project_id_name"`
// UsageBytes is the total number of bytes used by the files in the vector store.
UsageBytes int64
FileCountsInProgress int64
FileCountsCompleted int64
FileCountsFailed int64
FileCountsCancelled int64
FileCountsTotal int64
// TODO(guangrui): Update status.
Status CollectionStatus
Anchor ExpiresAfterAnchor
// ExpiresAfterDays is the number of days the anchor time for when the vector store will expire.
ExpiresAfterDays int64
// ExpiresAt is the Unix timestamp (in seconds) for when the vector store will expire.
ExpiresAt int64
// LastActiveAt is the Unix timestamp (in seconds) for when the vector store was last active.
LastActiveAt int64
EmbeddingModel string
EmbeddingDimensions int
Version int
}
Collection represents a collection.
type CollectionMetadata ¶
type CollectionMetadata struct {
gorm.Model
// VectorStoreID is the ID of the vector store.
VectorStoreID string `gorm:"uniqueIndex:idx_collectionmeta_vsid_key"`
Key string `gorm:"uniqueIndex:idx_collectionmeta_vsid_key"`
Value string
Version int
}
CollectionMetadata represents the metadata of a collection.
type CollectionStatus ¶
type CollectionStatus string
CollectionStatus represents the status of a collection.
type ExpiresAfterAnchor ¶
type ExpiresAfterAnchor string
ExpiresAfterAnchor represents the anchor for the expiration time.
type File ¶
type File struct {
gorm.Model
VectorStoreID string `gorm:"uniqueIndex:idx_file_vector_store_id_file_id"`
// FileID is the file ID.
FileID string `gorm:"uniqueIndex:idx_file_vector_store_id_file_id"`
// UsageBytes is the total vector store usage in bytes. Note that this may be different from the original file size.
UsageBytes int64
// TODO(guangrui): handle status update.
Status FileStatus
LastErrorCode LastErrorCode
LastErrorMessage string
ChunkingStrategyType ChunkingStrategyType
MaxChunkSizeTokens int64
ChunkOverlapTokens int64
Version int
}
File represents a file.
type LastErrorCode ¶
type LastErrorCode string
LastErrorCode represents the error code of the last error.
type S ¶
type S struct {
// contains filtered or unexported fields
}
S represents the data store.
func (*S) AutoMigrate ¶
AutoMigrate sets up the auto-migration task of the database.
func (*S) CreateCollection ¶
func (s *S) CreateCollection(c *Collection) error
CreateCollection creates a new collection.
func (*S) CreateCollectionMetadata ¶
func (s *S) CreateCollectionMetadata(cm *CollectionMetadata) error
CreateCollectionMetadata creates a new collection metadata.
func (*S) DeleteAllCollectionMetadatasByVectorStoreID ¶
DeleteAllCollectionMetadatasByVectorStoreID deletes all metadata of the collection.
func (*S) DeleteAllFilesByVectorStoreID ¶
DeleteAllFilesByVectorStoreID deletes all files of the collection.
func (*S) DeleteCollection ¶
DeleteCollection deletes the collection.
func (*S) DeleteCollectionMetadata ¶
DeleteCollectionMetadata deletes the metadata for the collection.
func (*S) DeleteFile ¶
DeleteFile deletes the file.
func (*S) GetCollectionByName ¶
func (s *S) GetCollectionByName(projectID, name string) (*Collection, error)
GetCollectionByName gets a collection.
func (*S) GetCollectionByVectorStoreID ¶
func (s *S) GetCollectionByVectorStoreID(projectID string, vectorStoreID string) (*Collection, error)
GetCollectionByVectorStoreID gets a collection.
func (*S) GetFileByFileID ¶
GetFileByFileID gets a file.
func (*S) ListCollectionMetadataByVectorStoreID ¶
func (s *S) ListCollectionMetadataByVectorStoreID(vectorStoreID string) ([]*CollectionMetadata, error)
ListCollectionMetadataByVectorStoreID lists metadata of a collections.
func (*S) ListCollections ¶
func (s *S) ListCollections(projectID string) ([]*Collection, error)
ListCollections lists collections.
func (*S) ListCollectionsWithPagination ¶
func (s *S) ListCollectionsWithPagination( projectID string, afterCreatedAt time.Time, afterID uint, order string, limit int, ) ([]*Collection, bool, error)
ListCollectionsWithPagination finds collections with pagination. Collections are returned in the order of VectorStoreID.
func (*S) ListFilesWithPagination ¶
func (s *S) ListFilesWithPagination( vectorStoreID string, afterCreatedAt time.Time, afterID uint, order string, limit int, ) ([]*File, bool, error)
ListFilesWithPagination finds files with pagination. Files are returned in the order of created_at.
func (*S) Transaction ¶
Transaction runs a given function in a transaction.
func (*S) UpdateCollection ¶
func (s *S) UpdateCollection(nc *Collection) error
UpdateCollection updates the collection.
func (*S) UpdateCollectionMetadata ¶
func (s *S) UpdateCollectionMetadata(cm *CollectionMetadata) error
UpdateCollectionMetadata updates the metadata of a collection.