Skip to content

Commit

Permalink
log, won't return on failure to write db (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielchalef authored Aug 15, 2023
1 parent 4a5df34 commit 0ea0427
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/store/postgres/documentstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func (ds *DocumentStore) documentEmbeddingUpdater(
docs := documentsFromEmbeddingUpdates(updates)
err := dbCollection.UpdateDocuments(ctx, docs)
if err != nil {
return fmt.Errorf("failed to update document embedding: %w", err)
log.Errorf("failed to update document embedding: %s", err)
}

log.Debugf("Document embedding updater updated %d documents", len(updates))
Expand Down
47 changes: 47 additions & 0 deletions pkg/store/postgres/documentstore_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package postgres

import (
"testing"

"github.com/google/uuid"

"github.com/getzep/zep/pkg/models"
"github.com/stretchr/testify/assert"
)

func TestDocumentsFromEmbeddingUpdates(t *testing.T) {
uuid1 := uuid.New()
uuid2 := uuid.New()

updates := []models.DocEmbeddingUpdate{
{
UUID: uuid1,
Embedding: []float32{0.1, 0.2, 0.3},
},
{
UUID: uuid2,
Embedding: []float32{0.4, 0.5, 0.6},
},
}

expectedDocs := []models.Document{
{
DocumentBase: models.DocumentBase{
UUID: uuid1,
IsEmbedded: true,
},
Embedding: []float32{0.1, 0.2, 0.3},
},
{
DocumentBase: models.DocumentBase{
UUID: uuid2,
IsEmbedded: true,
},
Embedding: []float32{0.4, 0.5, 0.6},
},
}

docs := documentsFromEmbeddingUpdates(updates)

assert.Equal(t, expectedDocs, docs)
}

0 comments on commit 0ea0427

Please sign in to comment.