From b612e8246e869e511ded8315b77ca695a189db69 Mon Sep 17 00:00:00 2001 From: Gary Date: Mon, 14 Oct 2024 07:21:21 -0400 Subject: [PATCH] feat: add check on text prompt (#115) Because the embedding pipleine can not allow empty text. This commit check the text prompt and throw the better understanding error message --- pkg/service/retrieval.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/service/retrieval.go b/pkg/service/retrieval.go index 6913f22..0186665 100644 --- a/pkg/service/retrieval.go +++ b/pkg/service/retrieval.go @@ -19,6 +19,10 @@ type SimChunk struct { func (s *Service) SimilarityChunksSearch(ctx context.Context, caller uuid.UUID, requester uuid.UUID, ownerUID uuid.UUID, req *artifactPb.SimilarityChunksSearchRequest) ([]SimChunk, error) { log, _ := logger.GetZapLogger(ctx) t := time.Now() + // check if text prompt is empty + if req.TextPrompt == "" { + return nil, fmt.Errorf("text prompt is empty in SimilarityChunksSearch") + } textVector, err := s.EmbeddingTextPipe(ctx, caller, requester, []string{req.TextPrompt}) if err != nil { log.Error("failed to vectorize text", zap.Error(err))