From 937eb32e939347c6ac152094985b7a5fa92e4bc7 Mon Sep 17 00:00:00 2001 From: Erik Winter Date: Thu, 6 Jul 2023 13:58:12 +0200 Subject: [PATCH] vec model and fix log --- model/video.go | 5 +++++ service.go | 2 +- storage/weaviate.go | 10 +++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/model/video.go b/model/video.go index e70273c..afeac58 100644 --- a/model/video.go +++ b/model/video.go @@ -26,3 +26,8 @@ type Video struct { Summary string } + +type VideoVec struct { + ID uuid.UUID + Summary string +} diff --git a/service.go b/service.go index 63be285..e7d1477 100644 --- a/service.go +++ b/service.go @@ -22,7 +22,7 @@ import ( func main() { ctx := context.Background() - logger := slog.New(slog.NewTextHandler(os.Stderr)) + logger := slog.New(slog.NewTextHandler(os.Stdout)) postgres, err := storage.NewPostgres(storage.PostgresInfo{ Host: getParam("POSTGRES_HOST", "localhost"), diff --git a/storage/weaviate.go b/storage/weaviate.go index 0fd96ef..aa7b907 100644 --- a/storage/weaviate.go +++ b/storage/weaviate.go @@ -64,7 +64,11 @@ func (w *Weaviate) ResetSchema() error { } func (w *Weaviate) Save(ctx context.Context, video *model.Video) error { - vID := video.ID.String() + vec := model.VideoVec{ + ID: video.ID, + Summary: video.Summary, + } + vID := vec.ID.String() // check it already exists exists, err := w.client.Data(). Checker(). @@ -80,7 +84,7 @@ func (w *Weaviate) Save(ctx context.Context, video *model.Video) error { Updater(). WithID(vID). WithClassName(className). - WithProperties(video). + WithProperties(vec). Do(ctx) } @@ -88,7 +92,7 @@ func (w *Weaviate) Save(ctx context.Context, video *model.Video) error { Creator(). WithClassName(className). WithID(vID). - WithProperties(video). + WithProperties(vec). Do(ctx) return err