Documentation
¶
Index ¶
- Constants
- type Chunk
- func (o *Chunk) ChunkIndex() int
- func (o *Chunk) Content() string
- func (o *Chunk) CreatedAt() string
- func (o *Chunk) CreatedAtCarbon() *carbon.Carbon
- func (o *Chunk) CreatedAtStdTime() time.Time
- func (o *Chunk) DocumentID() string
- func (o *Chunk) Embedding() []float32
- func (o *Chunk) EmbeddingFieldString() string
- func (o *Chunk) EmbeddingFromString(jsonStr string) []float32
- func (o *Chunk) ID() string
- func (o *Chunk) IsSoftDeleted() bool
- func (o *Chunk) SetChunkIndex(chunkIndex int) ChunkInterface
- func (o *Chunk) SetContent(content string) ChunkInterface
- func (o *Chunk) SetCreatedAt(createdAt string) ChunkInterface
- func (o *Chunk) SetDocumentID(id string) ChunkInterface
- func (o *Chunk) SetEmbedding(embedding []float32) ChunkInterface
- func (o *Chunk) SetEmbeddingFieldString(s string)
- func (o *Chunk) SetID(id string) ChunkInterface
- func (o *Chunk) SetSoftDeletedAt(softDeletedAt string) ChunkInterface
- func (o *Chunk) SetUpdatedAt(updatedAt string) ChunkInterface
- func (o *Chunk) SoftDeletedAt() string
- func (o *Chunk) SoftDeletedAtCarbon() *carbon.Carbon
- func (o *Chunk) UpdatedAt() string
- func (o *Chunk) UpdatedAtCarbon() *carbon.Carbon
- func (o *Chunk) UpdatedAtStdTime() time.Time
- type ChunkInterface
- type ChunkQueryInterface
- type DocumentInterface
- type DocumentQueryInterface
- type NewStoreOptions
- type StoreInterface
Constants ¶
const COLUMN_CHUNK_INDEX = "chunk_index"
const COLUMN_CONTENT = "content"
const COLUMN_CREATED_AT = "created_at"
const COLUMN_DOCUMENT_ID = "document_id"
const COLUMN_EMBEDDING = "embedding"
const COLUMN_FILE_NAME = "file_name"
const COLUMN_ID = "id"
const COLUMN_MEMO = "memo"
const COLUMN_METAS = "metas"
const COLUMN_SOFT_DELETED_AT = "soft_deleted_at"
const COLUMN_STATUS = "status"
const COLUMN_TEXT = "text"
const COLUMN_UPDATED_AT = "updated_at"
const DOCUMENT_STATUS_ACTIVE = "active"
const DOCUMENT_STATUS_DELETED = "deleted"
const DOCUMENT_STATUS_INACTIVE = "inactive"
const MAX_DATETIME = "9999-12-31 23:59:59"
MAX_DATETIME is a far-future datetime used as the default soft-delete sentinel. Records with soft_deleted_at equal to this value are considered active.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chunk ¶
type Chunk struct {
orm.ShortID
DocumentIDField string `json:"document_id" db:"document_id"`
ChunkIndexField int `json:"chunk_index" db:"chunk_index"`
ContentField string `json:"content" db:"content"`
EmbeddingField string `json:"embedding" db:"embedding"`
CreatedAtTime time.Time `json:"created_at" db:"created_at"`
UpdatedAtTime time.Time `json:"updated_at" db:"updated_at"`
soft_delete.SoftDeletesMaxDate
}
func (*Chunk) ChunkIndex ¶
func (*Chunk) CreatedAtCarbon ¶
func (*Chunk) CreatedAtStdTime ¶ added in v0.4.0
CreatedAtStdTime returns the created_at as time.Time (for internal use)
func (*Chunk) DocumentID ¶
func (*Chunk) EmbeddingFieldString ¶ added in v0.4.0
EmbeddingFieldString returns the embedding as a JSON string
func (*Chunk) EmbeddingFromString ¶ added in v0.4.0
func (*Chunk) IsSoftDeleted ¶
IsSoftDeleted checks if the chunk is soft deleted
func (*Chunk) SetChunkIndex ¶
func (o *Chunk) SetChunkIndex(chunkIndex int) ChunkInterface
func (*Chunk) SetContent ¶
func (o *Chunk) SetContent(content string) ChunkInterface
func (*Chunk) SetCreatedAt ¶
func (o *Chunk) SetCreatedAt(createdAt string) ChunkInterface
func (*Chunk) SetDocumentID ¶
func (o *Chunk) SetDocumentID(id string) ChunkInterface
func (*Chunk) SetEmbedding ¶
func (o *Chunk) SetEmbedding(embedding []float32) ChunkInterface
func (*Chunk) SetEmbeddingFieldString ¶ added in v0.4.0
SetEmbeddingFieldString sets the embedding from a JSON string
func (*Chunk) SetID ¶ added in v0.4.0
func (o *Chunk) SetID(id string) ChunkInterface
func (*Chunk) SetSoftDeletedAt ¶
func (o *Chunk) SetSoftDeletedAt(softDeletedAt string) ChunkInterface
func (*Chunk) SetUpdatedAt ¶
func (o *Chunk) SetUpdatedAt(updatedAt string) ChunkInterface
func (*Chunk) SoftDeletedAt ¶
func (*Chunk) SoftDeletedAtCarbon ¶
func (*Chunk) UpdatedAtCarbon ¶
func (*Chunk) UpdatedAtStdTime ¶ added in v0.4.0
UpdatedAtStdTime returns the updated_at as time.Time (for internal use)
type ChunkInterface ¶
type ChunkInterface interface {
IsSoftDeleted() bool
ID() string
SetID(id string) ChunkInterface
DocumentID() string
SetDocumentID(documentID string) ChunkInterface
ChunkIndex() int
SetChunkIndex(chunkIndex int) ChunkInterface
Content() string
SetContent(content string) ChunkInterface
Embedding() []float32
SetEmbedding(embedding []float32) ChunkInterface
EmbeddingFieldString() string
SetEmbeddingFieldString(s string)
CreatedAt() string
CreatedAtCarbon() *carbon.Carbon
SetCreatedAt(createdAt string) ChunkInterface
SoftDeletedAt() string
SoftDeletedAtCarbon() *carbon.Carbon
SetSoftDeletedAt(softDeletedAt string) ChunkInterface
UpdatedAt() string
UpdatedAtCarbon() *carbon.Carbon
SetUpdatedAt(updatedAt string) ChunkInterface
}
func NewChunk ¶
func NewChunk() ChunkInterface
func NewChunkFromExistingData ¶
func NewChunkFromExistingData(data map[string]string) ChunkInterface
type ChunkQueryInterface ¶
type ChunkQueryInterface interface {
// Validation method
Validate() error
// Basic query methods
IsCreatedAtGteSet() bool
GetCreatedAtGte() string
SetCreatedAtGte(createdAt string) ChunkQueryInterface
IsCreatedAtLteSet() bool
GetCreatedAtLte() string
SetCreatedAtLte(createdAt string) ChunkQueryInterface
IsIDSet() bool
GetID() string
SetID(id string) ChunkQueryInterface
IsIDInSet() bool
GetIDIn() []string
SetIDIn(ids []string) ChunkQueryInterface
IsIDNotInSet() bool
GetIDNotIn() []string
SetIDNotIn(ids []string) ChunkQueryInterface
IsLimitSet() bool
GetLimit() int
SetLimit(limit int) ChunkQueryInterface
IsDocumentIDSet() bool
GetDocumentID() string
SetDocumentID(documentID string) ChunkQueryInterface
IsDocumentIDInSet() bool
GetDocumentIDIn() []string
SetDocumentIDIn(documentIDs []string) ChunkQueryInterface
IsOffsetSet() bool
GetOffset() int
SetOffset(offset int) ChunkQueryInterface
IsOrderBySet() bool
GetOrderBy() string
SetOrderBy(orderBy string) ChunkQueryInterface
IsOrderDirectionSet() bool
GetOrderDirection() string
SetOrderDirection(orderDirection string) ChunkQueryInterface
// Count related methods
IsCountOnlySet() bool
GetCountOnly() bool
SetCountOnly(countOnly bool) ChunkQueryInterface
// Soft delete related query methods
IsWithSoftDeletedSet() bool
GetWithSoftDeleted() bool
SetWithSoftDeleted(withSoftDeleted bool) ChunkQueryInterface
IsOnlySoftDeletedSet() bool
GetOnlySoftDeleted() bool
SetOnlySoftDeleted(onlySoftDeleted bool) ChunkQueryInterface
IsUpdatedAtGteSet() bool
GetUpdatedAtGte() string
SetUpdatedAtGte(updatedAt string) ChunkQueryInterface
IsUpdatedAtLteSet() bool
GetUpdatedAtLte() string
SetUpdatedAtLte(updatedAt string) ChunkQueryInterface
}
ChunkQueryInterface defines the interface for querying chunks
type DocumentInterface ¶
type DocumentInterface interface {
IsActive() bool
IsInactive() bool
IsSoftDeleted() bool
ID() string
SetID(id string) DocumentInterface
Status() string
SetStatus(status string) DocumentInterface
FileName() string
SetFileName(fileName string) DocumentInterface
Text() string
SetText(text string) DocumentInterface
Memo() string
SetMemo(memo string) DocumentInterface
Meta(key string) (string, error)
SetMeta(key string, value string) error
Metas() (map[string]string, error)
SetMetas(metas map[string]string) error
UpsertMetas(metas map[string]string) error
CreatedAt() string
CreatedAtCarbon() *carbon.Carbon
SetCreatedAt(createdAt string) DocumentInterface
SoftDeletedAt() string
SoftDeletedAtCarbon() *carbon.Carbon
SetSoftDeletedAt(softDeletedAt string) DocumentInterface
UpdatedAt() string
UpdatedAtCarbon() *carbon.Carbon
SetUpdatedAt(updatedAt string) DocumentInterface
}
func NewDocument ¶
func NewDocument() DocumentInterface
func NewDocumentFromExistingData ¶
func NewDocumentFromExistingData(data map[string]string) DocumentInterface
type DocumentQueryInterface ¶
type DocumentQueryInterface interface {
// Validation method
Validate() error
// Count related methods
IsCountOnlySet() bool
GetCountOnly() bool
SetCountOnly(countOnly bool) DocumentQueryInterface
// Soft delete related query methods
IsWithSoftDeletedSet() bool
GetWithSoftDeleted() bool
SetWithSoftDeleted(withSoftDeleted bool) DocumentQueryInterface
IsOnlySoftDeletedSet() bool
GetOnlySoftDeleted() bool
SetOnlySoftDeleted(onlySoftDeleted bool) DocumentQueryInterface
IsCreatedAtGteSet() bool
GetCreatedAtGte() string
SetCreatedAtGte(createdAt string) DocumentQueryInterface
IsCreatedAtLteSet() bool
GetCreatedAtLte() string
SetCreatedAtLte(createdAt string) DocumentQueryInterface
IsIDSet() bool
GetID() string
SetID(id string) DocumentQueryInterface
IsIDInSet() bool
GetIDIn() []string
SetIDIn(ids []string) DocumentQueryInterface
IsLimitSet() bool
GetLimit() int
SetLimit(limit int) DocumentQueryInterface
IsOffsetSet() bool
GetOffset() int
SetOffset(offset int) DocumentQueryInterface
IsOrderBySet() bool
GetOrderBy() string
SetOrderBy(orderBy string) DocumentQueryInterface
IsOrderDirectionSet() bool
GetOrderDirection() string
SetOrderDirection(orderDirection string) DocumentQueryInterface
IsStatusSet() bool
GetStatus() string
SetStatus(status string) DocumentQueryInterface
SetStatusIn(statuses []string) DocumentQueryInterface
IsStatusInSet() bool
GetStatusIn() []string
IsUpdatedAtGteSet() bool
GetUpdatedAtGte() string
SetUpdatedAtGte(updatedAt string) DocumentQueryInterface
IsUpdatedAtLteSet() bool
GetUpdatedAtLte() string
SetUpdatedAtLte(updatedAt string) DocumentQueryInterface
}
DocumentQueryInterface defines the interface for querying chats
func DocumentQuery ¶
func DocumentQuery() DocumentQueryInterface
DocumentQuery creates a new document query
type NewStoreOptions ¶
type NewStoreOptions struct {
TableDocumentName string
TableDocumentChunkName string
DB *sql.DB
AutomigrateEnabled bool
DebugEnabled bool
Logger *slog.Logger
}
NewStoreOptions define the options for creating a new block store
type StoreInterface ¶
type StoreInterface interface {
AutoMigrate() error
EnableDebug(enabled bool)
GetDB() *sql.DB
GetLogger() *slog.Logger
SetLogger(logger *slog.Logger)
DocumentCount(options DocumentQueryInterface) (int64, error)
DocumentCreate(document DocumentInterface) error
DocumentDelete(document DocumentInterface) error
DocumentDeleteByID(id string) error
DocumentExists(id string) (bool, error)
DocumentFindByID(id string) (DocumentInterface, error)
DocumentList(options DocumentQueryInterface) ([]DocumentInterface, error)
DocumentSoftDelete(document DocumentInterface) error
DocumentSoftDeleteByID(id string) error
DocumentUpdate(document DocumentInterface) error
ChunkCount(options ChunkQueryInterface) (int64, error)
ChunkCreate(chunk ChunkInterface) error
ChunkDelete(chunk ChunkInterface) error
ChunkDeleteByID(id string) error
ChunkExists(id string) (bool, error)
ChunkFindByID(id string) (ChunkInterface, error)
ChunkList(options ChunkQueryInterface) ([]ChunkInterface, error)
ChunkSoftDelete(chunk ChunkInterface) error
ChunkSoftDeleteByID(id string) error
ChunkUpdate(chunk ChunkInterface) error
}
func NewStore ¶
func NewStore(opts NewStoreOptions) (StoreInterface, error)
NewStore creates a new block store