Skip to content

Commit

Permalink
Merge pull request #86 from bjwswang/main
Browse files Browse the repository at this point in the history
fix: add unique id to different documents
  • Loading branch information
bjwswang authored Sep 12, 2023
2 parents 1fecdf6 + 1746655 commit 578b75a
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 578b75a

Please sign in to comment.