Documentation
¶
Index ¶
- Constants
- func CheckModel(modelId, modelFile string) (string, error)
- func New(dataDir string, opts ...RAGOption) (core.Indexer, error)
- func Open(dataDir string) (core.Indexer, error)
- type Config
- type HybridIndexer
- func (h *HybridIndexer) Add(ctx context.Context, content string) ([]*core.Chunk, error)
- func (h *HybridIndexer) AddFile(ctx context.Context, filePath string) ([]*core.Chunk, error)
- func (h *HybridIndexer) AddIndexer(indexer core.Indexer, weight float32)
- func (h *HybridIndexer) Close(ctx context.Context) error
- func (h *HybridIndexer) GetIndexer(name string) (core.Indexer, bool)
- func (h *HybridIndexer) GetWeights() map[string]float32
- func (h *HybridIndexer) IndexChunk(ctx context.Context, chunk *core.Chunk) error
- func (h *HybridIndexer) IndexChunks(ctx context.Context, chunks []*core.Chunk) error
- func (h *HybridIndexer) ListIndexers() []string
- func (h *HybridIndexer) Name() string
- func (h *HybridIndexer) NewQuery(terms string) core.Query
- func (h *HybridIndexer) Remove(ctx context.Context, chunkID string) error
- func (h *HybridIndexer) RemoveIndexer(name string)
- func (h *HybridIndexer) Search(ctx context.Context, query core.Query) ([]core.Hit, error)
- func (h *HybridIndexer) Type() string
- type HybridOption
- type IndexingService
- type RAGOption
- type ServiceOption
Constants ¶
const ( GORAG_MODEL_PATH = "GORAG_MODEL_PATH" GORAG_BASE_URL = "GORAG_BASE_URL" GORAG_API_KEY = "GORAG_API_KEY" GORAG_AUTH_TOKEN = "GORAG_AUTH_TOKEN" GORAG_MODEL = "GORAG_MODEL" )
Variables ¶
This section is empty.
Functions ¶
func CheckModel ¶ added in v1.1.10
CheckModel 检查模型文件是否存在,如果不存在则从 HuggingFace 下载 modelId: HuggingFace 模型 ID,如 "Xenova/chinese-clip-vit-base-patch16" modelFile: 模型文件路径,如 "onnx/model.onnx" 返回模型文件的完整路径
Types ¶
type HybridIndexer ¶ added in v1.1.10
type HybridIndexer struct {
// contains filtered or unexported fields
}
HybridIndexer 混合索引器 将多个索引器(语义、BM25等)组合,实现查询结果融合与重排
func NewHybridIndexer ¶ added in v1.1.10
func NewHybridIndexer( logger logging.Logger, vectorStore core.VectorStore, graphStore core.GraphStore, docStore core.FullTextStore, client chat.Client, embedder core.Embedder, opts ...HybridOption) (*HybridIndexer, error)
NewHybridIndexer 创建混合索引器
func (*HybridIndexer) AddIndexer ¶ added in v1.1.10
func (h *HybridIndexer) AddIndexer(indexer core.Indexer, weight float32)
AddIndexer 向混合索引器添加索引器
func (*HybridIndexer) Close ¶ added in v1.1.10
func (h *HybridIndexer) Close(ctx context.Context) error
Close 关闭所有索引器持有的资源
func (*HybridIndexer) GetIndexer ¶ added in v1.1.10
func (h *HybridIndexer) GetIndexer(name string) (core.Indexer, bool)
GetIndexer 获取索引器
func (*HybridIndexer) GetWeights ¶ added in v1.1.10
func (h *HybridIndexer) GetWeights() map[string]float32
func (*HybridIndexer) IndexChunk ¶ added in v1.1.10
IndexChunk indexes a single pre-generated chunk across all indexers
func (*HybridIndexer) IndexChunks ¶ added in v1.1.10
IndexChunks indexes multiple pre-generated chunks across all indexers
func (*HybridIndexer) ListIndexers ¶ added in v1.1.10
func (h *HybridIndexer) ListIndexers() []string
ListIndexers 列出所有索引器名称(按字母排序,保证确定性输出)
func (*HybridIndexer) NewQuery ¶ added in v1.1.10
func (h *HybridIndexer) NewQuery(terms string) core.Query
func (*HybridIndexer) Remove ¶ added in v1.1.10
func (h *HybridIndexer) Remove(ctx context.Context, chunkID string) error
Remove 从所有索引器移除
func (*HybridIndexer) RemoveIndexer ¶ added in v1.1.10
func (h *HybridIndexer) RemoveIndexer(name string)
RemoveIndexer 移除索引器
type HybridOption ¶ added in v1.1.10
type HybridOption func(*HybridIndexer)
HybridOption HybridIndexer 的可选配置
func WithCacheStore ¶ added in v1.1.10
func WithCacheStore(cache core.CacheStore) HybridOption
WithCacheStore 设置图索引器的缓存(依赖注入 core.CacheStore 接口)
func WithCacheStoreOrNil ¶ added in v1.1.10
func WithCacheStoreOrNil(dataDir string) HybridOption
WithCacheStoreOrNil 创建缓存并返回 HybridOption; 缓存创建失败时返回 nil option,不阻断索引器创建
type IndexingService ¶ added in v1.1.10
type IndexingService struct {
// contains filtered or unexported fields
}
IndexingService RAG 索引服务 支持批量索引和文件监控两种模式
func NewRAGService ¶ added in v1.1.10
func NewRAGService(dataDir string, opts ...ServiceOption) (*IndexingService, error)
NewRAGService 创建 RAG 索引服务 dataDir: RAG 数据目录(必须) opts: 可选配置项
func (*IndexingService) Index ¶ added in v1.1.10
func (s *IndexingService) Index() error
Index 执行批量索引 对监控目录下的全部文件进行全量索引
func (*IndexingService) Reindex ¶ added in v1.1.10
func (s *IndexingService) Reindex(ctx context.Context, file string) error
Reindex 重新索引指定文件(公开 API) 删除旧索引数据后重新分块并索引,适用于文件内容变更后的更新场景
func (*IndexingService) Watch ¶ added in v1.1.10
func (s *IndexingService) Watch() error
Watch 启动文件监控服务 当文件发生变更时自动进行索引 首次启动时会执行全量索引
type RAGOption ¶
type RAGOption func(*Config)
func WithIndexType ¶ added in v1.1.10
func WithModelFile ¶ added in v1.1.10
type ServiceOption ¶ added in v1.1.10
type ServiceOption func(*IndexingService)
ServiceOption 服务配置选项
func WithLogger ¶ added in v1.1.10
func WithLogger(logger logging.Logger) ServiceOption
WithLogger 设置日志记录器
func WithWorkerCount ¶ added in v1.1.10
func WithWorkerCount(count int) ServiceOption
WithWorkerCount 设置 worker pool 大小
Directories
¶
| Path | Synopsis |
|---|---|
|
Package entity defines the core entities for the goRAG framework.
|
Package entity defines the core entities for the goRAG framework. |
|
Package logging provides structured logging capabilities for the goRAG framework.
|
Package logging provides structured logging capabilities for the goRAG framework. |
|
store
|
|