Versions in this module Expand all Collapse all v1 v1.2.0 Jun 6, 2026 v1.1.0 Jun 3, 2026 Changes in this version + const ProviderAliyun + const ProviderMilvus + const ProviderQdrant + const ProviderRAGFlow + var ErrBaseURL = errors.New("BaseURL is required") + var ErrChunkerNotFound = errors.New("no suitable chunker for document type") + var ErrCollectionNotFound = errors.New("Collection is required") + var ErrEmptyQuery = errors.New("empty query text") + var ErrEmptyText = errors.New("empty text") + var ErrHandlerNotFound = errors.New("handler not be null") + var ErrInvalidChunkOpt = errors.New("invalid chunk options") + var ErrInvalidVectorDimension = errors.New("invalid vector dimension") + var ErrNamespaceNotFound = errors.New("namespace not found") + var ErrNoChunks = errors.New("no chunks generated") + var ErrRecordNotFound = errors.New("record not found") + func ComputeHash(record *Record) string + type AliyunConfig struct + AccessKeyID string + AccessKeySecret string + CategoryID string + Endpoint string + Timeout time.Duration + WorkspaceID string + type AliyunHandler struct + CategoryID string + Embedder embedder.Embedder + WorkspaceID string + func (ah *AliyunHandler) CreateNamespace(ctx context.Context, name string) error + func (ah *AliyunHandler) Delete(ctx context.Context, ids []string, opts *DeleteOptions) error + func (ah *AliyunHandler) DeleteNamespace(ctx context.Context, name string) error + func (ah *AliyunHandler) Get(ctx context.Context, ids []string, opts *GetOptions) ([]Record, error) + func (ah *AliyunHandler) List(ctx context.Context, opts *ListOptions) (*ListResult, error) + func (ah *AliyunHandler) ListNamespaces(ctx context.Context) ([]string, error) + func (ah *AliyunHandler) Ping(ctx context.Context) error + func (ah *AliyunHandler) Provider() string + func (ah *AliyunHandler) Query(ctx context.Context, text string, opts *QueryOptions) ([]QueryResult, error) + func (ah *AliyunHandler) Upsert(ctx context.Context, records []Record, opts *UpsertOptions) error + type BackupConfig struct + FilePath string + Format ExportFormat + Timestamp bool + type CacheEntry struct + Results []QueryResult + Timestamp time.Time + type Chunk struct + Index int + Metadata map[string]any + Text string + Title string + type ChunkOptions struct + DocumentTitle string + MaxChars int + MinChars int + OverlapChars int + PreChunkClean *utils.Options + type Chunker interface + Chunk func(ctx context.Context, text string, opts *ChunkOptions) ([]Chunk, error) + Provider func() string + type DeleteOptions struct + Namespace string + type DocumentHash struct + Hash string + ID string + UpdatedAt time.Time + type DocumentType int + const DocumentTypeStructured + const DocumentTypeTableKV + const DocumentTypeUnknown + const DocumentTypeUnstructured + type DocumentTypeDetector interface + DetectDocumentType func(ctx context.Context, text string) (DocumentType, error) + type ExportData struct + Metadata ExportMetadata + Records []Record + type ExportFormat string + const ExportFormatJSON + const ExportFormatJSONL + type ExportMetadata struct + ExportedAt time.Time + Handler string + Namespace string + TotalRecords int + Version string + type Filter struct + Field string + Operator FilterOp + Value []any + type FilterOp string + const FilterOpContainsAll + const FilterOpContainsAny + const FilterOpEqual + const FilterOpGt + const FilterOpGte + const FilterOpIn + const FilterOpLt + const FilterOpLte + const FilterOpNotEqual + const FilterOpNotIn + type GetOptions struct + Namespace string + type HandlerFactoryParams struct + AliyunConfig *AliyunConfig + MilvusConfig *MilvusConfig + Namespace string + Provider string + QdrantConfig *QdrantConfig + RAGFlowConfig *RAGFlowConfig + type IncrementalUpdater struct + func NewIncrementalUpdater() *IncrementalUpdater + func (iu *IncrementalUpdater) Clear() + func (iu *IncrementalUpdater) GetChanges(records []Record) ([]Record, []string) + func (iu *IncrementalUpdater) GetHashes() map[string]string + func (iu *IncrementalUpdater) GetSyncStats(records []Record) SyncStats + func (iu *IncrementalUpdater) LastSyncTime() time.Time + func (iu *IncrementalUpdater) UpdateHashes(records []Record) + type KnowledgeBase struct + func NewKnowledgeBase(cfg KnowledgeBaseConfig) (*KnowledgeBase, error) + func (kb *KnowledgeBase) AddDocument(ctx context.Context, docID, title, content string, metadata map[string]any) error + func (kb *KnowledgeBase) Backup(ctx context.Context, cfg BackupConfig) (string, error) + func (kb *KnowledgeBase) CacheStats() map[string]any + func (kb *KnowledgeBase) ClearCache() + func (kb *KnowledgeBase) Close() error + func (kb *KnowledgeBase) DeleteDocument(ctx context.Context, docID string) error + func (kb *KnowledgeBase) ExportToFile(ctx context.Context, filepath string, format ExportFormat) error + func (kb *KnowledgeBase) ExportToWriter(ctx context.Context, w io.Writer, format ExportFormat) error + func (kb *KnowledgeBase) Health(ctx context.Context) error + func (kb *KnowledgeBase) ImportFromFile(ctx context.Context, filepath string, format ExportFormat) error + func (kb *KnowledgeBase) ImportFromReader(ctx context.Context, r io.Reader, format ExportFormat) error + func (kb *KnowledgeBase) IncrementalAddDocuments(ctx context.Context, updater *IncrementalUpdater, records []Record) error + func (kb *KnowledgeBase) Query(ctx context.Context, query string, topK int) ([]QueryResult, error) + func (kb *KnowledgeBase) Restore(ctx context.Context, filepath string, format ExportFormat) error + type KnowledgeBaseConfig struct + Chunkers map[DocumentType]Chunker + Detector DocumentTypeDetector + Embedder embedder.Embedder + EnableCache bool + Handler KnowledgeHandler + Namespace string + QueryCacheSize int + Retriever retrieve.StrategyRetriever + Searcher search.Engine + VectorCacheSize int + type KnowledgeHandler interface + CreateNamespace func(ctx context.Context, name string) error + Delete func(ctx context.Context, ids []string, opts *DeleteOptions) error + DeleteNamespace func(ctx context.Context, name string) error + Get func(ctx context.Context, ids []string, opts *GetOptions) ([]Record, error) + List func(ctx context.Context, opts *ListOptions) (*ListResult, error) + ListNamespaces func(ctx context.Context) ([]string, error) + Ping func(ctx context.Context) error + Provider func() string + Query func(ctx context.Context, text string, opts *QueryOptions) ([]QueryResult, error) + Upsert func(ctx context.Context, records []Record, opts *UpsertOptions) error + func NewKnowledgeHandler(p HandlerFactoryParams) (KnowledgeHandler, error) + type ListOptions struct + Filters []Filter + Limit int + Namespace string + Offset string + OrderBy string + OrderDir string + type ListResult struct + NextOffset string + Records []Record + type MilvusConfig struct + Address string + DBName string + Password string + Token string + Username string + type MilvusHandler struct + Address string + DBName string + Embedder embedder.Embedder + Password string + Token string + Username string + func (h *MilvusHandler) CreateNamespace(ctx context.Context, name string) error + func (h *MilvusHandler) Delete(ctx context.Context, ids []string, opts *DeleteOptions) error + func (h *MilvusHandler) DeleteNamespace(ctx context.Context, name string) error + func (h *MilvusHandler) Get(ctx context.Context, ids []string, opts *GetOptions) ([]Record, error) + func (h *MilvusHandler) List(ctx context.Context, opts *ListOptions) (*ListResult, error) + func (h *MilvusHandler) ListNamespaces(ctx context.Context) ([]string, error) + func (h *MilvusHandler) Ping(ctx context.Context) error + func (h *MilvusHandler) Provider() string + func (h *MilvusHandler) Query(ctx context.Context, text string, opts *QueryOptions) ([]QueryResult, error) + func (h *MilvusHandler) Upsert(ctx context.Context, records []Record, opts *UpsertOptions) error + type QdrantConfig struct + APIKey string + BaseURL string + Timeout time.Duration + type QdrantHandler struct + APIKey string + BaseURL string + Embedder embedder.Embedder + HTTPClient *http.Client + func (qh *QdrantHandler) CreateNamespace(ctx context.Context, name string) error + func (qh *QdrantHandler) Delete(ctx context.Context, ids []string, opts *DeleteOptions) error + func (qh *QdrantHandler) DeleteNamespace(ctx context.Context, name string) error + func (qh *QdrantHandler) Get(ctx context.Context, ids []string, opts *GetOptions) ([]Record, error) + func (qh *QdrantHandler) List(ctx context.Context, opts *ListOptions) (*ListResult, error) + func (qh *QdrantHandler) ListNamespaces(ctx context.Context) ([]string, error) + func (qh *QdrantHandler) Ping(ctx context.Context) error + func (qh *QdrantHandler) Provider() string + func (qh *QdrantHandler) Query(ctx context.Context, text string, opts *QueryOptions) ([]QueryResult, error) + func (qh *QdrantHandler) Upsert(ctx context.Context, records []Record, opts *UpsertOptions) error + type QueryCache struct + func NewQueryCache(maxSize int, ttl time.Duration) *QueryCache + func (qc *QueryCache) Clear() + func (qc *QueryCache) Get(ctx context.Context, query string) ([]QueryResult, bool) + func (qc *QueryCache) Set(ctx context.Context, query string, results []QueryResult) + func (qc *QueryCache) Stats() map[string]any + type QueryOptions struct + EnableReranking bool + Filters []Filter + MinScore float64 + Model string + Namespace string + ReturnMetadata bool + TopK int + type QueryResult struct + Record Record + Score float64 + type RAGFlowConfig struct + APIKey string + BaseURL string + Timeout time.Duration + type RAGFlowHandler struct + APIKey string + BaseURL string + Embedder embedder.Embedder + HTTPClient *http.Client + func (rh *RAGFlowHandler) CreateNamespace(ctx context.Context, name string) error + func (rh *RAGFlowHandler) Delete(ctx context.Context, ids []string, opts *DeleteOptions) error + func (rh *RAGFlowHandler) DeleteNamespace(ctx context.Context, name string) error + func (rh *RAGFlowHandler) Get(ctx context.Context, ids []string, opts *GetOptions) ([]Record, error) + func (rh *RAGFlowHandler) List(ctx context.Context, opts *ListOptions) (*ListResult, error) + func (rh *RAGFlowHandler) ListNamespaces(ctx context.Context) ([]string, error) + func (rh *RAGFlowHandler) Ping(ctx context.Context) error + func (rh *RAGFlowHandler) Provider() string + func (rh *RAGFlowHandler) Query(ctx context.Context, text string, opts *QueryOptions) ([]QueryResult, error) + func (rh *RAGFlowHandler) Upsert(ctx context.Context, records []Record, opts *UpsertOptions) error + type Record struct + Content string + CreatedAt time.Time + ID string + Metadata map[string]any + Source string + Tags []string + Title string + UpdatedAt time.Time + Vector []float32 + type RuleBasedDocumentTypeDetector struct + func (d *RuleBasedDocumentTypeDetector) DetectDocumentType(ctx context.Context, text string) (DocumentType, error) + type SyncStats struct + Added int + Deleted int + LastSyncAt time.Time + TotalTime time.Duration + Unchanged int + Updated int + type UpsertOptions struct + BatchSize int + Namespace string + Overwrite bool + type VectorCache struct + func NewVectorCache(maxSize int) *VectorCache + func (vc *VectorCache) Clear() + func (vc *VectorCache) Get(text string) ([]float32, bool) + func (vc *VectorCache) Set(text string, vector []float32) + func (vc *VectorCache) Size() int