Skip to content

Commit

Permalink
feat: add check on text prompt (#115)
Browse files Browse the repository at this point in the history
Because

the embedding pipleine can not allow empty text.

This commit

check the text prompt and throw the better understanding error message
  • Loading branch information
Yougigun authored Oct 14, 2024
1 parent 983374f commit b612e82
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/service/retrieval.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit b612e82

Please sign in to comment.