Skip to main content

rag

函数名函数描述/介绍
rag.AddDocument_addDocument 向指定集合添加文档
rag.BuildCollectionFromFile
rag.BuildCollectionFromRaw
rag.BuildCollectionFromReader
rag.BuildIndexKnowledgeFromFile
rag.BuildKnowledgeFromEntityRepos
rag.DeleteCollection_deleteCollection 删除指定的 RAG 集合
rag.DeleteDocument_deleteDocument 从指定集合删除文档
rag.DeleteRAG_deleteRAG 删除指定的 RAG 系统
rag.EnableMockMode
rag.Export
rag.Get
rag.GetCollection
rag.GetCollectionInfo_getCollectionInfo 获取指定集合的详细信息
rag.HasCollection_hasCollection 检查指定集合是否存在
rag.Import
rag.ListCollection_listCollection 获取所有 RAG 集合列表
rag.ListRAG_listRAG 列出所有 RAG 系统列表
rag.NewRagDatabase
rag.NewTempRagDatabase_newTempRagDatabase 创建临时 RAG 数据库
rag.Query
rag.QueryDocuments_queryDocuments 在指定集合中查询文档
rag.aiService
rag.aiServiceType
rag.buildFilter
rag.buildQuery
rag.chunkSize
rag.ctx
rag.db
rag.docMetadataWithDocumentMetadataKeyValue sets document metadata key-value pairs
rag.docRawMetadataWithDocumentRawMetadata sets raw document metadata
rag.documentHandler
rag.embeddingHandle_embeddingHandle 创建自定义嵌入处理器
rag.entryLength
rag.extraPrompt
rag.getEntityFilter
rag.importNameWithRAGCollectionName sets the specific collection name to query
rag.importOverwrite
rag.importRebuildGraph
rag.khopLimit
rag.khopkWithKHopK 设置k-hop的跳数,k>=2时返回k-hop路径,k=0返回所有路径
rag.khopkMaxWithKHopKMax 设置最大路径长度,最小值为2
rag.khopkMinWithKHopKMin 设置最小路径长度,最小值为2
rag.log
rag.noEntityRepository_noEntityRepository 禁用实体仓库
rag.noHNSWGraph
rag.noKnowledgeBase_noKnowledgeBase 禁用知识库
rag.noMetadata
rag.noOriginInput
rag.onlyPQCode
rag.pathDepth
rag.progressHandler
rag.queryCollectionWithRAGCollectionName sets the specific collection name to query
rag.queryConcurrentWithRAGConcurrent sets the concurrency level for query operations
rag.queryCtxWithRAGCtx sets the context for RAG query operations
rag.queryEnhanceWithRAGEnhance sets the enhancement strategies to apply
rag.queryLimitWithRAGLimit sets the maximum number of results to return
rag.queryScoreLimitWithRAGCollectionScoreLimit sets the score limit for collection filtering
rag.queryStatusWithRAGQueryStatus sets the query status callback function
rag.queryTypeWithRAGDocumentType sets the document type filter
rag.ragCosineDistance
rag.ragDescription
rag.ragEmbeddingModel
rag.ragForceNewWithForceNew sets whether to force creation of new collection
rag.ragHNSWParametersWithHNSWParameters sets HNSW parameters
rag.ragImportFile
rag.ragModelDimensionWithModelDimension sets the model dimension
rag.statusCard

函数定义#

AddDocument#

详细描述#

_addDocument 向指定集合添加文档

Example:


    err = rag.AddDocument("my_collection", "doc1", "content", {"key": "value"})

定义#

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

参数#

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

返回值#

返回值(顺序)返回值类型返回值解释
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

BuildIndexKnowledgeFromFile#

详细描述#

定义#

BuildIndexKnowledgeFromFile(kbName string, path string, option ...any) error

参数#

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

返回值#

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

BuildKnowledgeFromEntityRepos#

详细描述#

定义#

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

参数#

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

返回值#

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

DeleteCollection#

详细描述#

_deleteCollection 删除指定的 RAG 集合

Example:


    err = rag.DeleteCollection("my_collection")

定义#

DeleteCollection(name string) error

参数#

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

返回值#

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

DeleteDocument#

详细描述#

_deleteDocument 从指定集合删除文档

Example:


    err = rag.DeleteDocument("my_collection", "doc1")

定义#

DeleteDocument(knowledgeBaseName string, documentName string, opts ...rag.RAGSystemConfigOption) error

参数#

参数名参数类型参数解释
knowledgeBaseNamestring
documentNamestring
opts...rag.RAGSystemConfigOption

返回值#

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

DeleteRAG#

详细描述#

_deleteRAG 删除指定的 RAG 系统

Example:


    err = rag.DeleteRAG("my_rag")

定义#

DeleteRAG(name string) error

参数#

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

返回值#

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

EnableMockMode#

详细描述#

定义#

EnableMockMode()

Export#

详细描述#

定义#

Export(collectionName string, fileName string, opts ...RAGSystemConfigOption) error

参数#

参数名参数类型参数解释
collectionNamestring
fileNamestring
opts...RAGSystemConfigOption

返回值#

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

Get#

详细描述#

定义#

Get(name string, opts ...RAGSystemConfigOption) (*RAGSystem, error)

参数#

参数名参数类型参数解释
namestring
opts...RAGSystemConfigOption

返回值#

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

GetCollection#

详细描述#

定义#

GetCollection(name string, opts ...RAGSystemConfigOption) (*RAGSystem, error)

参数#

参数名参数类型参数解释
namestring
opts...RAGSystemConfigOption

返回值#

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

GetCollectionInfo#

详细描述#

_getCollectionInfo 获取指定集合的详细信息

Example:


    info, err = rag.GetCollectionInfo("my_collection")

定义#

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

参数#

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

返回值#

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

HasCollection#

详细描述#

_hasCollection 检查指定集合是否存在

Example:


    exists = rag.HasCollection("my_collection")

定义#

HasCollection(name string) bool

参数#

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

返回值#

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

Import#

详细描述#

定义#

Import(inputPath string, optFuncs ...RAGSystemConfigOption) error

参数#

参数名参数类型参数解释
inputPathstring
optFuncs...RAGSystemConfigOption

返回值#

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

ListCollection#

详细描述#

_listCollection 获取所有 RAG 集合列表

Example:


    collections = rag.ListCollection()

定义#

ListCollection() []string

返回值#

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

ListRAG#

详细描述#

_listRAG 列出所有 RAG 系统列表

Example:


    ragSystems = rag.ListRAG()

定义#

ListRAG() []string

返回值#

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

NewRagDatabase#

详细描述#

定义#

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

参数#

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

返回值#

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

NewTempRagDatabase#

详细描述#

_newTempRagDatabase 创建临时 RAG 数据库

Example:


    db, err = rag.NewTempRagDatabase()

定义#

NewTempRagDatabase() (*gorm.DB, error)

返回值#

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

Query#

详细描述#

定义#

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

参数#

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

返回值#

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

QueryDocuments#

详细描述#

_queryDocuments 在指定集合中查询文档

Example:


    results, err = rag.QueryDocuments("my_collection", "query", 10)

定义#

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

参数#

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

返回值#

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

aiService#

详细描述#

定义#

aiService(aiService aicommon.AICallbackType) RAGSystemConfigOption

参数#

参数名参数类型参数解释
aiServiceaicommon.AICallbackType

返回值#

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

aiServiceType#

详细描述#

定义#

aiServiceType(aiServiceName string, aiServiceConfig ...aispec.AIConfigOption) RAGSystemConfigOption

参数#

参数名参数类型参数解释
aiServiceNamestring
aiServiceConfig...aispec.AIConfigOption

返回值#

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

buildFilter#

详细描述#

定义#

buildFilter(filter *ypb.EntityFilter) RAGSystemConfigOption

参数#

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

返回值#

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

buildQuery#

详细描述#

定义#

buildQuery(query string) RAGSystemConfigOption

参数#

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

返回值#

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

chunkSize#

详细描述#

定义#

chunkSize(size int64) Option

参数#

参数名参数类型参数解释
sizeint64

返回值#

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

ctx#

详细描述#

定义#

ctx(ctx context.Context) AnalysisOption

参数#

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

返回值#

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

db#

详细描述#

定义#

db(db *gorm.DB) RAGSystemConfigOption

参数#

参数名参数类型参数解释
db*gorm.DB

返回值#

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

docMetadata#

详细描述#

WithDocumentMetadataKeyValue sets document metadata key-value pairs

定义#

docMetadata(key string, value any) RAGSystemConfigOption

参数#

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

返回值#

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

docRawMetadata#

详细描述#

WithDocumentRawMetadata sets raw document metadata

定义#

docRawMetadata(metadata map[string]any) RAGSystemConfigOption

参数#

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

返回值#

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

documentHandler#

详细描述#

定义#

documentHandler(documentHandler func(doc schema.VectorStoreDocument) (schema.VectorStoreDocument, error)) RAGSystemConfigOption

参数#

参数名参数类型参数解释
documentHandlerfunc(doc schema.VectorStoreDocument) (schema.VectorStoreDocument, error)

返回值#

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

embeddingHandle#

详细描述#

_embeddingHandle 创建自定义嵌入处理器

Example:


    embeddingOpt = rag.embeddingHandle((text) => {        return [0.1, 0.2, 0.3] // 返回嵌入向量    })

定义#

embeddingHandle(handle func(text string) any) rag.RAGSystemConfigOption

参数#

参数名参数类型参数解释
handlefunc(text string) any

返回值#

返回值(顺序)返回值类型返回值解释
r1rag.RAGSystemConfigOption

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

importName#

详细描述#

WithRAGCollectionName sets the specific collection name to query

定义#

importName(collectionName string) RAGSystemConfigOption

参数#

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

返回值#

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

importOverwrite#

详细描述#

定义#

importOverwrite(overwriteExisting bool) RAGSystemConfigOption

参数#

参数名参数类型参数解释
overwriteExistingbool

返回值#

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

importRebuildGraph#

详细描述#

定义#

importRebuildGraph(rebuildHNSWIndex bool) RAGSystemConfigOption

参数#

参数名参数类型参数解释
rebuildHNSWIndexbool

返回值#

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

khopLimit#

详细描述#

定义#

khopLimit(k int) RAGSystemConfigOption

参数#

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

返回值#

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

khopk#

详细描述#

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

定义#

khopk(k int) RAGSystemConfigOption

参数#

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

返回值#

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

khopkMax#

详细描述#

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

定义#

khopkMax(kMax int) RAGSystemConfigOption

参数#

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

返回值#

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

khopkMin#

详细描述#

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

定义#

khopkMin(kMin int) RAGSystemConfigOption

参数#

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

返回值#

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

log#

详细描述#

定义#

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

参数#

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

返回值#

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

noEntityRepository#

详细描述#

_noEntityRepository 禁用实体仓库

Example:


    rag.noEntityRepository()

定义#

noEntityRepository() rag.RAGSystemConfigOption

返回值#

返回值(顺序)返回值类型返回值解释
r1rag.RAGSystemConfigOption

noHNSWGraph#

详细描述#

定义#

noHNSWGraph(noHNSWGraph bool) RAGSystemConfigOption

参数#

参数名参数类型参数解释
noHNSWGraphbool

返回值#

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

noKnowledgeBase#

详细描述#

_noKnowledgeBase 禁用知识库

Example:


    rag.noKnowledgeBase()

定义#

noKnowledgeBase() rag.RAGSystemConfigOption

返回值#

返回值(顺序)返回值类型返回值解释
r1rag.RAGSystemConfigOption

noMetadata#

详细描述#

定义#

noMetadata(noMetadata bool) RAGSystemConfigOption

参数#

参数名参数类型参数解释
noMetadatabool

返回值#

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

noOriginInput#

详细描述#

定义#

noOriginInput(noOriginInput bool) RAGSystemConfigOption

参数#

参数名参数类型参数解释
noOriginInputbool

返回值#

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

onlyPQCode#

详细描述#

定义#

onlyPQCode(onlyPQCode bool) RAGSystemConfigOption

参数#

参数名参数类型参数解释
onlyPQCodebool

返回值#

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

pathDepth#

详细描述#

定义#

pathDepth(deep int) RAGSystemConfigOption

参数#

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

返回值#

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

progressHandler#

详细描述#

定义#

progressHandler(progressHandler func(percent float64, message string, messageType string)) RAGSystemConfigOption

参数#

参数名参数类型参数解释
progressHandlerfunc(percent float64, message string, messageType string)

返回值#

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

queryCollection#

详细描述#

WithRAGCollectionName sets the specific collection name to query

定义#

queryCollection(collectionName string) RAGSystemConfigOption

参数#

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

返回值#

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

queryConcurrent#

详细描述#

WithRAGConcurrent sets the concurrency level for query operations

定义#

queryConcurrent(concurrent int) RAGSystemConfigOption

参数#

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

返回值#

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

queryCtx#

详细描述#

WithRAGCtx sets the context for RAG query operations

定义#

queryCtx(ctx context.Context) RAGSystemConfigOption

参数#

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

返回值#

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

queryEnhance#

详细描述#

WithRAGEnhance sets the enhancement strategies to apply

定义#

queryEnhance(enhance ...string) RAGSystemConfigOption

参数#

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

返回值#

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

queryLimit#

详细描述#

WithRAGLimit sets the maximum number of results to return

定义#

queryLimit(limit int) RAGSystemConfigOption

参数#

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

返回值#

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

queryScoreLimit#

详细描述#

WithRAGCollectionScoreLimit sets the score limit for collection filtering

定义#

queryScoreLimit(scoreLimit float64) RAGSystemConfigOption

参数#

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

返回值#

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

queryStatus#

详细描述#

WithRAGQueryStatus sets the query status callback function

定义#

queryStatus(callback func(label string, i any, tags ...string)) RAGSystemConfigOption

参数#

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

返回值#

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

queryType#

详细描述#

WithRAGDocumentType sets the document type filter

定义#

queryType(documentType ...string) RAGSystemConfigOption

参数#

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

返回值#

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

ragCosineDistance#

详细描述#

定义#

ragCosineDistance()

ragDescription#

详细描述#

定义#

ragDescription(description string) RAGSystemConfigOption

参数#

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

返回值#

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

ragEmbeddingModel#

详细描述#

定义#

ragEmbeddingModel(model string) RAGSystemConfigOption

参数#

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

返回值#

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

ragForceNew#

详细描述#

WithForceNew sets whether to force creation of new collection

定义#

ragForceNew(force bool) RAGSystemConfigOption

参数#

参数名参数类型参数解释
forcebool

返回值#

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

ragHNSWParameters#

详细描述#

WithHNSWParameters sets HNSW parameters

定义#

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

参数#

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

返回值#

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

ragImportFile#

详细描述#

定义#

ragImportFile(importFile string) RAGSystemConfigOption

参数#

参数名参数类型参数解释
importFilestring

返回值#

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

ragModelDimension#

详细描述#

WithModelDimension sets the model dimension

定义#

ragModelDimension(dimension int) RAGSystemConfigOption

参数#

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

返回值#

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

statusCard#

详细描述#

定义#

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

参数#

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

返回值#

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