Skip to content

Commit

Permalink
fix: add unique id to different documents
Browse files Browse the repository at this point in the history
Signed-off-by: bjwswang <[email protected]>
  • Loading branch information
bjwswang committed Sep 12, 2023
1 parent 96b9dbd commit 1746655
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/vectorstores/chromadb/chroma.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

chroma "github.com/amikos-tech/chroma-go"
chromaopenapi "github.com/amikos-tech/chroma-go/swagger"
"github.com/google/uuid"
"github.com/tmc/langchaingo/schema"
"github.com/tmc/langchaingo/vectorstores"
)
Expand Down Expand Up @@ -87,8 +88,9 @@ func (s Store) AddDocuments(ctx context.Context, docs []schema.Document, options
nameSpace := s.getNameSpace(opts)

texts := make([]string, 0, len(docs))
ids := make([]string, len(docs))
ids := make([]string, 0, len(docs))
for _, doc := range docs {
ids = append(ids, uuid.New().String())
texts = append(texts, doc.PageContent)
}

Expand All @@ -111,7 +113,6 @@ func (s Store) AddDocuments(ctx context.Context, docs []schema.Document, options
for k, v := range docs[i].Metadata {
metadata[k] = v
}
metadata[s.textKey] = texts[i]
metadata[s.nameSpaceKey] = nameSpace

metadatas = append(metadatas, metadata)
Expand Down

0 comments on commit 1746655

Please sign in to comment.