Documentation
¶
Index ¶
- type AIContentProcessor
- type CacheManager
- type CommonIndexableItem
- type ContentProcessor
- type FailedItem
- type FileCacheManager
- func (f *FileCacheManager) Clear() error
- func (f *FileCacheManager) LoadProcessedCache() (map[string]string, error)
- func (f *FileCacheManager) LoadRawCache() (map[string]string, error)
- func (f *FileCacheManager) SaveProcessedCache(cache map[string]string) error
- func (f *FileCacheManager) SaveRawCache(cache map[string]string) error
- type IndexManager
- func CreateIndexManager(db *gorm.DB, collectionName, description string, optFuncs ...OptionFunc) (*IndexManager, error)
- func CreateIndexManagerWithAI(db *gorm.DB, collectionName, description string, ...) (*IndexManager, error)
- func NewIndexManager(db *gorm.DB, ragSystem *rag.RAGSystem, collectionName string, ...) *IndexManager
- type IndexOptions
- type IndexResult
- type IndexableItem
- type OptionFunc
- func WithAIProcessor(liteForge contracts.LiteForge, customPrompt ...string) OptionFunc
- func WithBatchSize(size int) OptionFunc
- func WithCacheDir(dir string) OptionFunc
- func WithCacheManager(manager CacheManager) OptionFunc
- func WithConcurrentWorkers(workers int) OptionFunc
- func WithContentProcessor(processor ContentProcessor) OptionFunc
- func WithForceBypassCache(bypass bool) OptionFunc
- func WithIncludeMetadata(include bool) OptionFunc
- func WithProgressCallback(callback ProgressCallback) OptionFunc
- func WithSimpleProcessor() OptionFunc
- func WithTempCacheDir() OptionFunc
- type ProgressCallback
- type ScriptIndexableItem
- type SimpleContentProcessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AIContentProcessor ¶
type AIContentProcessor struct {
// contains filtered or unexported fields
}
AIContentProcessor AI内容处理器
func NewAIContentProcessor ¶
func NewAIContentProcessor(liteForge contracts.LiteForge, customPrompt ...string) *AIContentProcessor
NewAIContentProcessor 创建AI内容处理器
func (*AIContentProcessor) ProcessContent ¶
ProcessContent 处理原始内容,返回清洗后的内容
type CacheManager ¶
type CacheManager interface {
// LoadRawCache 加载原始内容缓存
LoadRawCache() (map[string]string, error)
// SaveRawCache 保存原始内容缓存
SaveRawCache(cache map[string]string) error
// LoadProcessedCache 加载处理后内容缓存
LoadProcessedCache() (map[string]string, error)
// SaveProcessedCache 保存处理后内容缓存
SaveProcessedCache(cache map[string]string) error
// Clear 清空所有缓存
Clear() error
}
CacheManager 缓存管理器接口
type CommonIndexableItem ¶
type CommonIndexableItem struct {
Key string
Content string
Metadata map[string]interface{}
DisplayName string
}
func NewCommonIndexableItem ¶
func NewCommonIndexableItem(key, content string, metadata map[string]interface{}, displayName string) *CommonIndexableItem
func (*CommonIndexableItem) GetContent ¶
func (c *CommonIndexableItem) GetContent() (string, error)
func (*CommonIndexableItem) GetDisplayName ¶
func (c *CommonIndexableItem) GetDisplayName() string
func (*CommonIndexableItem) GetKey ¶
func (c *CommonIndexableItem) GetKey() string
func (*CommonIndexableItem) GetMetadata ¶
func (c *CommonIndexableItem) GetMetadata() map[string]interface{}
type ContentProcessor ¶
type ContentProcessor interface {
// ProcessContent 处理原始内容,返回清洗后的内容
ProcessContent(ctx context.Context, rawContent string) (string, error)
}
ContentProcessor 内容处理器接口
type FileCacheManager ¶
type FileCacheManager struct {
// contains filtered or unexported fields
}
FileCacheManager 基于文件的缓存管理器
func NewFileCacheManager ¶
func NewFileCacheManager(cacheDir string) *FileCacheManager
NewFileCacheManager 创建文件缓存管理器
func (*FileCacheManager) LoadProcessedCache ¶
func (f *FileCacheManager) LoadProcessedCache() (map[string]string, error)
LoadProcessedCache 加载处理后内容缓存
func (*FileCacheManager) LoadRawCache ¶
func (f *FileCacheManager) LoadRawCache() (map[string]string, error)
LoadRawCache 加载原始内容缓存
func (*FileCacheManager) SaveProcessedCache ¶
func (f *FileCacheManager) SaveProcessedCache(cache map[string]string) error
SaveProcessedCache 保存处理后内容缓存
func (*FileCacheManager) SaveRawCache ¶
func (f *FileCacheManager) SaveRawCache(cache map[string]string) error
SaveRawCache 保存原始内容缓存
type IndexManager ¶
type IndexManager struct {
// contains filtered or unexported fields
}
IndexManager 通用索引管理器
func CreateIndexManager ¶
func CreateIndexManager(db *gorm.DB, collectionName, description string, optFuncs ...OptionFunc) (*IndexManager, error)
CreateIndexManager 创建索引管理器的便捷函数
func CreateIndexManagerWithAI ¶
func CreateIndexManagerWithAI(db *gorm.DB, collectionName, description string, aiOpts []aispec.AIConfigOption, optFuncs ...OptionFunc) (*IndexManager, error)
CreateIndexManagerWithAI 创建带AI配置的索引管理器
func NewIndexManager ¶
func NewIndexManager(db *gorm.DB, ragSystem *rag.RAGSystem, collectionName string, options *IndexOptions) *IndexManager
NewIndexManager 创建索引管理器
func (*IndexManager) GetTotalCount ¶
func (m *IndexManager) GetTotalCount() (int, error)
GetTotalCount 获取总文档数量
func (*IndexManager) IndexItems ¶
func (m *IndexManager) IndexItems(ctx context.Context, items []IndexableItem) (*IndexResult, error)
IndexItems 索引数据项列表
func (*IndexManager) SearchItems ¶
func (m *IndexManager) SearchItems(query string, page, limit int) ([]*rag.SearchResult, error)
SearchItems 搜索项目
type IndexOptions ¶
type IndexOptions struct {
// 缓存目录
CacheDir string
// 是否强制绕过缓存
ForceBypassCache bool
// 是否包含元数据
IncludeMetadata bool
// 批处理大小
BatchSize int
// 进度回调
ProgressCallback ProgressCallback
// 内容处理器
ContentProcessor ContentProcessor
// 缓存管理器
CacheManager CacheManager
// 并发数
ConcurrentWorkers int
}
IndexOptions 索引选项
func ApplyOptions ¶
func ApplyOptions(base *IndexOptions, optFuncs ...OptionFunc) *IndexOptions
ApplyOptions 应用选项函数列表
type IndexResult ¶
type IndexResult struct {
// 成功索引的数量
SuccessCount int
// 失败的项目
FailedItems []FailedItem
// 跳过的项目(已存在且未强制更新)
SkippedCount int
// 总耗时
Duration string
}
IndexResult 索引结果
func QuickIndexScripts ¶
func QuickIndexScripts(db *gorm.DB, collectionName string, scripts []*schema.YakScript, optFuncs ...OptionFunc) (*IndexResult, error)
QuickIndexScripts 快速索引脚本的便捷函数
type IndexableItem ¶
type IndexableItem interface {
// GetKey 获取数据的唯一标识符
GetKey() string
// GetContent 获取用于生成向量的内容
GetContent() (string, error)
// GetMetadata 获取元数据信息
GetMetadata() map[string]interface{}
// GetDisplayName 获取显示名称(用于日志等)
GetDisplayName() string
}
IndexableItem 可索引的数据项接口
func ConvertScriptsToIndexableItems ¶
func ConvertScriptsToIndexableItems(scripts []*schema.YakScript) []IndexableItem
ConvertScriptsToIndexableItems 将脚本列表转换为可索引项列表
type OptionFunc ¶
type OptionFunc func(*IndexOptions)
OptionFunc 选项函数类型
func WithAIProcessor ¶
func WithAIProcessor(liteForge contracts.LiteForge, customPrompt ...string) OptionFunc
WithAIProcessor 使用AI处理器(需要提供 LiteForge 实现)
func WithCacheManager ¶
func WithCacheManager(manager CacheManager) OptionFunc
WithCacheManager 设置缓存管理器
func WithConcurrentWorkers ¶
func WithConcurrentWorkers(workers int) OptionFunc
WithConcurrentWorkers 设置并发工作协程数
func WithContentProcessor ¶
func WithContentProcessor(processor ContentProcessor) OptionFunc
WithContentProcessor 设置内容处理器
func WithForceBypassCache ¶
func WithForceBypassCache(bypass bool) OptionFunc
WithForceBypassCache 强制绕过缓存
func WithIncludeMetadata ¶
func WithIncludeMetadata(include bool) OptionFunc
WithIncludeMetadata 设置是否包含元数据
func WithProgressCallback ¶
func WithProgressCallback(callback ProgressCallback) OptionFunc
WithProgressCallback 设置进度回调
type ProgressCallback ¶
ProgressCallback 进度回调函数
type ScriptIndexableItem ¶
type ScriptIndexableItem struct {
// contains filtered or unexported fields
}
ScriptIndexableItem 将 YakScript 适配为 IndexableItem
func NewScriptIndexableItem ¶
func NewScriptIndexableItem(script *schema.YakScript) *ScriptIndexableItem
NewScriptIndexableItem 创建脚本索引项
func (*ScriptIndexableItem) GetContent ¶
func (s *ScriptIndexableItem) GetContent() (string, error)
GetContent 获取用于生成向量的内容
func (*ScriptIndexableItem) GetDisplayName ¶
func (s *ScriptIndexableItem) GetDisplayName() string
GetDisplayName 获取显示名称
func (*ScriptIndexableItem) GetKey ¶
func (s *ScriptIndexableItem) GetKey() string
GetKey 获取脚本的唯一标识符
func (*ScriptIndexableItem) GetMetadata ¶
func (s *ScriptIndexableItem) GetMetadata() map[string]interface{}
GetMetadata 获取元数据信息
type SimpleContentProcessor ¶
type SimpleContentProcessor struct{}
SimpleContentProcessor 简单内容处理器(不使用AI)
func NewSimpleContentProcessor ¶
func NewSimpleContentProcessor() *SimpleContentProcessor
NewSimpleContentProcessor 创建简单内容处理器
func (*SimpleContentProcessor) ProcessContent ¶
func (p *SimpleContentProcessor) ProcessContent(ctx context.Context, rawContent string) (string, error)
ProcessContent 简单处理内容(直接返回原内容)