import("log""trpc.group/trpc-go/trpc-agent-go/knowledge")kb:=knowledge.New(knowledge.WithEmbedder(embedder),knowledge.WithVectorStore(vectorStore),knowledge.WithSources(sources),knowledge.WithEnableSourceSync(true),// 启用同步模式)iferr:=kb.Load(ctx);err!=nil{log.Fatalf("Failed to load: %v",err)}
import("fmt""log""trpc.group/trpc-go/trpc-agent-go/knowledge")// 显示所有文档信息docInfos,err:=kb.ShowDocumentInfo(ctx)iferr!=nil{log.Printf("Failed to show document info: %v",err)return}// 按源名称过滤显示docInfos,err=kb.ShowDocumentInfo(ctx,knowledge.WithShowDocumentInfoSourceName("APIDocumentation"))iferr!=nil{log.Printf("Failed to show source documents: %v",err)return}// 按文档ID过滤显示docInfos,err=kb.ShowDocumentInfo(ctx,knowledge.WithShowDocumentInfoIDs([]string{"doc1","doc2"}))iferr!=nil{log.Printf("Failed to show specific documents: %v",err)return}// 遍历显示文档信息for_,docInfo:=rangedocInfos{fmt.Printf("Document ID: %s\n",docInfo.DocumentID)fmt.Printf("Source: %s\n",docInfo.SourceName)fmt.Printf("URI: %s\n",docInfo.URI)fmt.Printf("Chunk Index: %d\n",docInfo.ChunkIndex)}