ragstore

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2025 License: AGPL-3.0 Imports: 20 Imported by: 0

README

RAG Store

License

This project is dual-licensed under the following terms:

  • For non-commercial use, you may choose either the GNU Affero General Public License v3.0 (AGPLv3) or a separate commercial license (see below). You can find a copy of the AGPLv3 at: https://www.gnu.org/licenses/agpl-3.0.txt

  • For commercial use, a separate commercial license is required. Commercial licenses are available for various use cases. Please contact me via my contact page to obtain a commercial license.

Installation

go get github.com/dracory/ragstore

Documentation

Index

Constants

View Source
const CHAT_MESSAGE_STATUS_ACTIVE = "active"
View Source
const CHAT_MESSAGE_STATUS_DELETED = "deleted"
View Source
const CHAT_MESSAGE_STATUS_INACTIVE = "inactive"
View Source
const COLUMN_CHUNK_INDEX = "chunk_index"
View Source
const COLUMN_CONTENT = "content"
View Source
const COLUMN_CREATED_AT = "created_at"
View Source
const COLUMN_DOCUMENT_ID = "document_id"
View Source
const COLUMN_EMBEDDING = "embedding"
View Source
const COLUMN_FILE_NAME = "file_name"
View Source
const COLUMN_ID = "id"
View Source
const COLUMN_MEMO = "memo"
View Source
const COLUMN_METAS = "metas"
View Source
const COLUMN_SOFT_DELETED_AT = "soft_deleted_at"
View Source
const COLUMN_STATUS = "status"
View Source
const COLUMN_TEXT = "text"
View Source
const COLUMN_UPDATED_AT = "updated_at"
View Source
const DOCUMENT_STATUS_ACTIVE = "active"
View Source
const DOCUMENT_STATUS_DELETED = "deleted"
View Source
const DOCUMENT_STATUS_INACTIVE = "inactive"

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunk

type Chunk struct {
	dataobject.DataObject
}

func (*Chunk) ChunkIndex

func (o *Chunk) ChunkIndex() int

func (*Chunk) Content

func (o *Chunk) Content() string

func (*Chunk) CreatedAt

func (o *Chunk) CreatedAt() string

func (*Chunk) CreatedAtCarbon

func (o *Chunk) CreatedAtCarbon() *carbon.Carbon

func (*Chunk) DocumentID

func (o *Chunk) DocumentID() string

func (*Chunk) Embedding

func (o *Chunk) Embedding() []float32

func (*Chunk) IsSoftDeleted

func (o *Chunk) IsSoftDeleted() bool

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) SetSoftDeletedAt

func (o *Chunk) SetSoftDeletedAt(softDeletedAt string) ChunkInterface

func (*Chunk) SetText

func (o *Chunk) SetText(text string) ChunkInterface

func (*Chunk) SetUpdatedAt

func (o *Chunk) SetUpdatedAt(updatedAt string) ChunkInterface

func (*Chunk) SoftDeletedAt

func (o *Chunk) SoftDeletedAt() string

func (*Chunk) SoftDeletedAtCarbon

func (o *Chunk) SoftDeletedAtCarbon() *carbon.Carbon

func (*Chunk) Text

func (o *Chunk) Text() string

func (*Chunk) UpdatedAt

func (o *Chunk) UpdatedAt() string

func (*Chunk) UpdatedAtCarbon

func (o *Chunk) UpdatedAtCarbon() *carbon.Carbon

type ChunkInterface

type ChunkInterface interface {
	dataobject.DataObjectInterface

	IsSoftDeleted() bool

	DocumentID() string
	SetDocumentID(chatID string) ChunkInterface

	ChunkIndex() int
	SetChunkIndex(chunkIndex int) ChunkInterface

	Content() string
	SetContent(content string) ChunkInterface

	Embedding() []float32
	SetEmbedding(embedding []float32) ChunkInterface

	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(chatIDs []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

	ToSelectDataset(store *store) (selectDataset *goqu.SelectDataset, columns []any, err error)
}

ChunkQueryInterface defines the interface for querying chunks

func ChunkQuery

func ChunkQuery() ChunkQueryInterface

ChunkQuery creates a new chunk query

type DocumentInterface

type DocumentInterface interface {
	Data() map[string]string
	DataChanged() map[string]string
	MarkAsNotDirty()

	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

	// Dataset conversion methods
	ToSelectDataset(store *store) (selectDataset *goqu.SelectDataset, columns []any, err error)

	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

	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
	DbDriverName           string
	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)

	DocumentCount(options DocumentQueryInterface) (int64, error)
	DocumentCreate(chat DocumentInterface) error
	DocumentDelete(chat DocumentInterface) error
	DocumentDeleteByID(id string) error
	DocumentFindByID(id string) (DocumentInterface, error)
	DocumentList(options DocumentQueryInterface) ([]DocumentInterface, error)
	DocumentSoftDelete(chat DocumentInterface) error
	DocumentSoftDeleteByID(id string) error
	DocumentUpdate(chat DocumentInterface) error

	ChunkCount(options ChunkQueryInterface) (int64, error)
	ChunkCreate(message ChunkInterface) error
	ChunkDelete(message ChunkInterface) error
	ChunkDeleteByID(id string) error
	ChunkFindByID(id string) (ChunkInterface, error)
	ChunkList(options ChunkQueryInterface) ([]ChunkInterface, error)
	ChunkSoftDelete(message ChunkInterface) error
	ChunkSoftDeleteByID(id string) error
	ChunkUpdate(message ChunkInterface) error
}

func NewStore

func NewStore(opts NewStoreOptions) (StoreInterface, error)

NewStore creates a new block store

Jump to

Keyboard shortcuts

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