core

package
v0.0.0-...-e986fc6 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

README

go-rag 核心逻辑

此目录本应放在internal目录下,但为了便于被其他项目直接引用,将其放在core目录下

详情可以参照 test文件

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IndexAsyncByDocsIDReq

type IndexAsyncByDocsIDReq struct {
	DocsIDs       []string
	KnowledgeName string // 知识库名称
	DocumentsId   int64  // 文档ID
	// contains filtered or unexported fields
}

type IndexAsyncReq

type IndexAsyncReq struct {
	Docs          []*schema.Document
	KnowledgeName string // 知识库名称
	DocumentsId   int64  // 文档ID
}

type IndexReq

type IndexReq struct {
	URI           string // 文档地址,可以是文件路径(pdf,html,md等),也可以是网址
	KnowledgeName string // 知识库名称
	DocumentsId   int64  // 文档ID
}

type Rag

type Rag struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, conf *config.Config) (*Rag, error)

func (*Rag) DeleteDocument

func (x *Rag) DeleteDocument(ctx context.Context, documentID string) error

func (*Rag) GetKnowledgeBaseList

func (x *Rag) GetKnowledgeBaseList(ctx context.Context) (list []string, err error)

GetKnowledgeBaseList 获取知识库列表

func (*Rag) Index

func (x *Rag) Index(ctx context.Context, req *IndexReq) (ids []string, err error)

Index 这里处理文档的读取、分割、合并和存储 真正的embedding 和 QA 异步执行

func (*Rag) IndexAsync

func (x *Rag) IndexAsync(ctx context.Context, req *IndexAsyncReq) (ids []string, err error)

IndexAsync 通过 schema.Document 异步 生成QA&embedding

func (*Rag) Retrieve

func (x *Rag) Retrieve(ctx context.Context, req *RetrieveReq) (msg []*schema.Document, err error)

Retrieve 检索

type RetrieveReq

type RetrieveReq struct {
	Query         string  // 检索关键词
	TopK          int     // 检索结果数量
	Score         float64 //  分数阀值(0-2, 0 完全相反,1 毫不相干,2 完全相同,一般需要传入一个大于1的数字,如1.5)
	KnowledgeName string  // 知识库名字
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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