Skip to main content

rag

函数名函数描述/介绍
rag.AddDocument
rag.BuildCollectionFromFile
rag.BuildCollectionFromRaw
rag.BuildCollectionFromReader
rag.BuildKnowledgeFromEntityRepos
rag.DeleteCollection
rag.DeleteDocument
rag.EnableMockMode
rag.GetCollection
rag.GetCollectionInfo
rag.ListCollection
rag.NewRagDatabase
rag.NewTempRagDatabase
rag.Query
rag.QueryDocuments
rag.QueryDocumentsWithAISummary
rag.buildFilter
rag.buildQuery
rag.ctx
rag.docMetadata
rag.docRawMetadata
rag.entryLength
rag.extraPrompt
rag.getEntityFilter
rag.khopLimit
rag.khopkWithKHopK 设置k-hop的跳数,k>=2时返回k-hop路径,k=0返回所有路径
rag.khopkMaxWithKHopKMax 设置最大路径长度,最小值为2
rag.khopkMinWithKHopKMin 设置最小路径长度,最小值为2
rag.log
rag.pathDepth
rag.queryCollectionWithRAGCollectionName 指定搜索的集合名称
rag.queryConcurrentWithRAGConcurrent 设置并发数
rag.queryCtxWithRAGCtx 设置上下文
rag.queryEnhanceWithRAGEnhance 启用或禁用增强搜索
rag.queryLimitWithRAGLimit 设置查询结果限制
rag.queryScoreLimitWithRAGCollectionScoreLimit 设置集合搜索分数阈值
rag.queryStatus
rag.queryType
rag.ragCosineDistance
rag.ragDescription
rag.ragEmbeddingModelWithEmbeddingModel 设置embedding模型
rag.ragForceNew
rag.ragHNSWParametersWithHNSWParameters 批量设置HNSW参数
rag.ragModelDimensionWithModelDimension 设置模型维度
rag.statusCard

函数定义#

AddDocument#

详细描述#

定义#

AddDocument(knowledgeBaseName string, documentName string, document string, metadata map[string]any, opts ...any) error

参数#

参数名参数类型参数解释
knowledgeBaseNamestring
documentNamestring
documentstring
metadatamap[string]any
opts...any

返回值#

返回值(顺序)返回值类型返回值解释
r1error

BuildCollectionFromFile#

详细描述#

定义#

BuildCollectionFromFile(kbName string, path string, option ...any) (<-chan *schema.KnowledgeBaseEntry, error)

参数#

参数名参数类型参数解释
kbNamestring
pathstring
option...any

返回值#

返回值(顺序)返回值类型返回值解释
r1<-chan *schema.KnowledgeBaseEntry
r2error

BuildCollectionFromRaw#

详细描述#

定义#

BuildCollectionFromRaw(kbName string, content []byte, option ...any) (<-chan *schema.KnowledgeBaseEntry, error)

参数#

参数名参数类型参数解释
kbNamestring
content[]byte
option...any

返回值#

返回值(顺序)返回值类型返回值解释
r1<-chan *schema.KnowledgeBaseEntry
r2error

BuildCollectionFromReader#

详细描述#

定义#

BuildCollectionFromReader(kbName string, reader io.Reader, option ...any) (<-chan *schema.KnowledgeBaseEntry, error)

参数#

参数名参数类型参数解释
kbNamestring
readerio.Reader
option...any

返回值#

返回值(顺序)返回值类型返回值解释
r1<-chan *schema.KnowledgeBaseEntry
r2error

BuildKnowledgeFromEntityRepos#

详细描述#

定义#

BuildKnowledgeFromEntityRepos(name string, option ...any) (<-chan *schema.KnowledgeBaseEntry, error)

参数#

参数名参数类型参数解释
namestring
option...any

返回值#

返回值(顺序)返回值类型返回值解释
r1<-chan *schema.KnowledgeBaseEntry
r2error

DeleteCollection#

详细描述#

定义#

DeleteCollection(name string) error

参数#

参数名参数类型参数解释
namestring

返回值#

返回值(顺序)返回值类型返回值解释
r1error

DeleteDocument#

详细描述#

定义#

DeleteDocument(knowledgeBaseName string, documentName string, opts ...any) error

参数#

参数名参数类型参数解释
knowledgeBaseNamestring
documentNamestring
opts...any

返回值#

返回值(顺序)返回值类型返回值解释
r1error

EnableMockMode#

详细描述#

定义#

EnableMockMode()

GetCollection#

详细描述#

定义#

GetCollection(name string, i ...any) (*RAGSystem, error)

参数#

参数名参数类型参数解释
namestring
i...any

返回值#

返回值(顺序)返回值类型返回值解释
r1*RAGSystem
r2error

GetCollectionInfo#

详细描述#

定义#

GetCollectionInfo(name string) (*rag.CollectionInfo, error)

参数#

参数名参数类型参数解释
namestring

返回值#

返回值(顺序)返回值类型返回值解释
r1*rag.CollectionInfo
r2error

ListCollection#

详细描述#

定义#

ListCollection() []string

返回值#

返回值(顺序)返回值类型返回值解释
r1[]string

NewRagDatabase#

详细描述#

定义#

NewRagDatabase(path string) (*gorm.DB, error)

参数#

参数名参数类型参数解释
pathstring

返回值#

返回值(顺序)返回值类型返回值解释
r1*gorm.DB
r2error

NewTempRagDatabase#

详细描述#

定义#

NewTempRagDatabase() (*gorm.DB, error)

返回值#

返回值(顺序)返回值类型返回值解释
r1*gorm.DB
r2error

Query#

详细描述#

定义#

Query(query string, opts ...RAGQueryOption) (<-chan *RAGSearchResult, error)

参数#

参数名参数类型参数解释
querystring
opts...RAGQueryOption

返回值#

返回值(顺序)返回值类型返回值解释
r1<-chan *RAGSearchResult
r2error

QueryDocuments#

详细描述#

定义#

QueryDocuments(knowledgeBaseName string, query string, limit int, opts ...any) ([]rag.SearchResult, error)

参数#

参数名参数类型参数解释
knowledgeBaseNamestring
querystring
limitint
opts...any

返回值#

返回值(顺序)返回值类型返回值解释
r1[]rag.SearchResult
r2error

QueryDocumentsWithAISummary#

详细描述#

定义#

QueryDocumentsWithAISummary(knowledgeBaseName string, query string, limit int, opts ...any) (string, error)

参数#

参数名参数类型参数解释
knowledgeBaseNamestring
querystring
limitint
opts...any

返回值#

返回值(顺序)返回值类型返回值解释
r1string
r2error

buildFilter#

详细描述#

定义#

buildFilter(filter *ypb.EntityFilter) KHopQueryOption

参数#

参数名参数类型参数解释
filter*ypb.EntityFilter

返回值#

返回值(顺序)返回值类型返回值解释
r1KHopQueryOption

buildQuery#

详细描述#

定义#

buildQuery(query string) KHopQueryOption

参数#

参数名参数类型参数解释
querystring

返回值#

返回值(顺序)返回值类型返回值解释
r1KHopQueryOption

ctx#

详细描述#

定义#

ctx(ctx context.Context) AnalysisOption

参数#

参数名参数类型参数解释
ctxcontext.Context

返回值#

返回值(顺序)返回值类型返回值解释
r1AnalysisOption

docMetadata#

详细描述#

定义#

docMetadata(key string, value any) DocumentOption

参数#

参数名参数类型参数解释
keystring
valueany

返回值#

返回值(顺序)返回值类型返回值解释
r1DocumentOption

docRawMetadata#

详细描述#

定义#

docRawMetadata(i map[string]any) DocumentOption

参数#

参数名参数类型参数解释
imap[string]any

返回值#

返回值(顺序)返回值类型返回值解释
r1DocumentOption

entryLength#

详细描述#

定义#

entryLength(length int) RefineOption

参数#

参数名参数类型参数解释
lengthint

返回值#

返回值(顺序)返回值类型返回值解释
r1RefineOption

extraPrompt#

详细描述#

定义#

extraPrompt(prompt string) AnalysisOption

参数#

参数名参数类型参数解释
promptstring

返回值#

返回值(顺序)返回值类型返回值解释
r1AnalysisOption

getEntityFilter#

详细描述#

定义#

getEntityFilter(reposName string, entityTypes []string, names []string, HiddenIndex []string, keywords []string) *ypb.EntityFilter

参数#

参数名参数类型参数解释
reposNamestring
entityTypes[]string
names[]string
HiddenIndex[]string
keywords[]string

返回值#

返回值(顺序)返回值类型返回值解释
r1*ypb.EntityFilter

khopLimit#

详细描述#

定义#

khopLimit(k int) KHopQueryOption

参数#

参数名参数类型参数解释
kint

返回值#

返回值(顺序)返回值类型返回值解释
r1KHopQueryOption

khopk#

详细描述#

WithKHopK 设置k-hop的跳数,k>=2时返回k-hop路径,k=0返回所有路径

定义#

khopk(k int) KHopQueryOption

参数#

参数名参数类型参数解释
kint

返回值#

返回值(顺序)返回值类型返回值解释
r1KHopQueryOption

khopkMax#

详细描述#

WithKHopKMax 设置最大路径长度,最小值为2

定义#

khopkMax(kMax int) KHopQueryOption

参数#

参数名参数类型参数解释
kMaxint

返回值#

返回值(顺序)返回值类型返回值解释
r1KHopQueryOption

khopkMin#

详细描述#

WithKHopKMin 设置最小路径长度,最小值为2

定义#

khopkMin(kMin int) KHopQueryOption

参数#

参数名参数类型参数解释
kMinint

返回值#

返回值(顺序)返回值类型返回值解释
r1KHopQueryOption

log#

详细描述#

定义#

log(handler func(format string, args ...any)) AnalysisOption

参数#

参数名参数类型参数解释
handlerfunc(format string, args ...any)

返回值#

返回值(顺序)返回值类型返回值解释
r1AnalysisOption

pathDepth#

详细描述#

定义#

pathDepth(deep int) KHopQueryOption

参数#

参数名参数类型参数解释
deepint

返回值#

返回值(顺序)返回值类型返回值解释
r1KHopQueryOption

queryCollection#

详细描述#

WithRAGCollectionName 指定搜索的集合名称

定义#

queryCollection(collectionName string) RAGQueryOption

参数#

参数名参数类型参数解释
collectionNamestring

返回值#

返回值(顺序)返回值类型返回值解释
r1RAGQueryOption

queryConcurrent#

详细描述#

WithRAGConcurrent 设置并发数

定义#

queryConcurrent(concurrent int) RAGQueryOption

参数#

参数名参数类型参数解释
concurrentint

返回值#

返回值(顺序)返回值类型返回值解释
r1RAGQueryOption

queryCtx#

详细描述#

WithRAGCtx 设置上下文

定义#

queryCtx(ctx context.Context) RAGQueryOption

参数#

参数名参数类型参数解释
ctxcontext.Context

返回值#

返回值(顺序)返回值类型返回值解释
r1RAGQueryOption

queryEnhance#

详细描述#

WithRAGEnhance 启用或禁用增强搜索

定义#

queryEnhance(enhancePlan ...string) RAGQueryOption

参数#

参数名参数类型参数解释
enhancePlan...string

返回值#

返回值(顺序)返回值类型返回值解释
r1RAGQueryOption

queryLimit#

详细描述#

WithRAGLimit 设置查询结果限制

定义#

queryLimit(limit int) RAGQueryOption

参数#

参数名参数类型参数解释
limitint

返回值#

返回值(顺序)返回值类型返回值解释
r1RAGQueryOption

queryScoreLimit#

详细描述#

WithRAGCollectionScoreLimit 设置集合搜索分数阈值

定义#

queryScoreLimit(scoreLimit float64) RAGQueryOption

参数#

参数名参数类型参数解释
scoreLimitfloat64

返回值#

返回值(顺序)返回值类型返回值解释
r1RAGQueryOption

queryStatus#

详细描述#

定义#

queryStatus(i func(label string, i any, tags ...string)) RAGQueryOption

参数#

参数名参数类型参数解释
ifunc(label string, i any, tags ...string)

返回值#

返回值(顺序)返回值类型返回值解释
r1RAGQueryOption

queryType#

详细描述#

定义#

queryType(documentType ...string) RAGQueryOption

参数#

参数名参数类型参数解释
documentType...string

返回值#

返回值(顺序)返回值类型返回值解释
r1RAGQueryOption

ragCosineDistance#

详细描述#

定义#

ragCosineDistance()

ragDescription#

详细描述#

定义#

ragDescription(description string) RAGOption

参数#

参数名参数类型参数解释
descriptionstring

返回值#

返回值(顺序)返回值类型返回值解释
r1RAGOption

ragEmbeddingModel#

详细描述#

WithEmbeddingModel 设置embedding模型

定义#

ragEmbeddingModel(model string) RAGOption

参数#

参数名参数类型参数解释
modelstring

返回值#

返回值(顺序)返回值类型返回值解释
r1RAGOption

ragForceNew#

详细描述#

定义#

ragForceNew(i ...bool) RAGOption

参数#

参数名参数类型参数解释
i...bool

返回值#

返回值(顺序)返回值类型返回值解释
r1RAGOption

ragHNSWParameters#

详细描述#

WithHNSWParameters 批量设置HNSW参数

定义#

ragHNSWParameters(m int, ml float64, efSearch int, efConstruct int) RAGOption

参数#

参数名参数类型参数解释
mint
mlfloat64
efSearchint
efConstructint

返回值#

返回值(顺序)返回值类型返回值解释
r1RAGOption

ragModelDimension#

详细描述#

WithModelDimension 设置模型维度

定义#

ragModelDimension(dimension int) RAGOption

参数#

参数名参数类型参数解释
dimensionint

返回值#

返回值(顺序)返回值类型返回值解释
r1RAGOption

statusCard#

详细描述#

定义#

statusCard(handler func(id string, data any, tags ...string)) AnalysisOption

参数#

参数名参数类型参数解释
handlerfunc(id string, data any, tags ...string)

返回值#

返回值(顺序)返回值类型返回值解释
r1AnalysisOption