File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,6 +82,10 @@ def match_instruments(
8282 clustering_algorithm : str = "affinity_propagation" ,
8383 num_clusters_for_kmeans : int = None
8484) -> MatchResult :
85+ for instrument in instruments :
86+ for question in instrument .questions :
87+ if question .question_text is None or question .question_text == "" :
88+ raise ValueError ("Invalid argument: you cannot send an empty question to Harmony. Please remove all null and empty questions." )
8589 return match_instruments_with_function (
8690 instruments = instruments ,
8791 query = query ,
Original file line number Diff line number Diff line change @@ -616,6 +616,10 @@ def match_instruments_with_function(
616616 for instrument in instruments :
617617 all_questions .extend (instrument .questions )
618618
619+ for question in all_questions :
620+ if question .question_text is None or question .question_text == "" :
621+ raise ValueError ("Invalid argument: you cannot send an empty question to Harmony. Please remove all null and empty questions." )
622+
619623 text_vectors , new_vectors_dict = create_full_text_vectors (
620624 all_questions = [q .question_text for q in all_questions ],
621625 query = query ,
Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ class RawFile(BaseModel):
6161class Question (BaseModel ):
6262 question_no : Optional [str ] = Field (None , description = "Number of the question" )
6363 question_intro : Optional [str ] = Field (None , description = "Introductory text applying to the question" )
64- question_text : str = Field (description = "Text of the question" )
64+ question_text : str = Field (description = "Text of the question" , min_length = 1 )
6565 options : List [str ] = Field ([], description = "The possible answer options" )
6666 source_page : int = Field (0 , description = "The page of the PDF on which the question was located, zero-indexed" )
6767 instrument_id : Optional [str ] = Field (None , description = "Unique identifier for the instrument (UUID-4)" )
You can’t perform that action at this time.
0 commit comments