Fix/filter empty segment (#1004)

Co-authored-by: jyong <jyong@dify.ai>
This commit is contained in:
Jyong 2023-08-25 15:50:29 +08:00 committed by GitHub
commit 2d604d9330
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View file

@ -891,6 +891,10 @@ class SegmentService:
if document.doc_form == 'qa_model':
if 'answer' not in args or not args['answer']:
raise ValueError("Answer is required")
if not args['answer'].strip():
raise ValueError("Answer is empty")
if 'content' not in args or not args['content'] or not args['content'].strip():
raise ValueError("Content is empty")
@classmethod
def create_segment(cls, args: dict, document: Document, dataset: Dataset):