@@ -194,15 +194,11 @@ class PromptMemoryEntry(Base):
194194 attack_identifier : Mapped [dict [str , str ]] = mapped_column (JSON )
195195 response_error : Mapped [Literal ["blocked" , "none" , "processing" , "unknown" ]] = mapped_column (String , nullable = True )
196196
197- original_value_data_type : Mapped [Literal ["text" , "image_path" , "audio_path" , "url" , "error" ]] = mapped_column (
198- String , nullable = False
199- )
197+ original_value_data_type : Mapped [PromptDataType ] = mapped_column (String , nullable = False )
200198 original_value = mapped_column (Unicode , nullable = False )
201199 original_value_sha256 = mapped_column (String )
202200
203- converted_value_data_type : Mapped [Literal ["text" , "image_path" , "audio_path" , "url" , "error" ]] = mapped_column (
204- String , nullable = False
205- )
201+ converted_value_data_type : Mapped [PromptDataType ] = mapped_column (String , nullable = False )
206202 converted_value = mapped_column (Unicode )
207203 converted_value_sha256 = mapped_column (String )
208204
@@ -376,7 +372,7 @@ class ScoreEntry(Base):
376372 score_type : Mapped [Literal ["true_false" , "float_scale" , "unknown" ]] = mapped_column (String , nullable = False )
377373 score_category : Mapped [Optional [list [str ]]] = mapped_column (JSON , nullable = True )
378374 score_rationale = mapped_column (String , nullable = True )
379- score_metadata : Mapped [dict [str , Union [str , int , float ]]] = mapped_column (JSON )
375+ score_metadata : Mapped [Optional [ dict [str , Union [str , int , float ]]]] = mapped_column (JSON , nullable = True )
380376 scorer_class_identifier : Mapped [dict [str , Any ]] = mapped_column (JSON )
381377 prompt_request_response_id = mapped_column (CustomUUID , ForeignKey (f"{ PromptMemoryEntry .__tablename__ } .id" ))
382378 timestamp = mapped_column (DateTime , nullable = False )
@@ -557,11 +553,11 @@ class SeedEntry(Base):
557553 source = mapped_column (String , nullable = True )
558554 date_added = mapped_column (DateTime , nullable = False )
559555 added_by = mapped_column (String , nullable = False )
560- prompt_metadata : Mapped [dict [str , Union [str , int ]]] = mapped_column (JSON , nullable = True )
556+ prompt_metadata : Mapped [Optional [ dict [str , Union [str , int ] ]]] = mapped_column (JSON , nullable = True )
561557 parameters : Mapped [Optional [list [str ]]] = mapped_column (JSON , nullable = True )
562558 prompt_group_id : Mapped [Optional [uuid .UUID ]] = mapped_column (CustomUUID , nullable = True )
563559 sequence : Mapped [Optional [int ]] = mapped_column (INTEGER , nullable = True )
564- role : Mapped [ChatMessageRole ] = mapped_column (String , nullable = True )
560+ role : Mapped [Optional [ ChatMessageRole ] ] = mapped_column (String , nullable = True )
565561 seed_type : Mapped [SeedType ] = mapped_column (String , nullable = False , default = "prompt" )
566562
567563 def __init__ (self , * , entry : Seed ) -> None :
@@ -585,7 +581,7 @@ def __init__(self, *, entry: Seed) -> None:
585581 self .data_type = entry .data_type
586582 self .name = entry .name
587583 self .dataset_name = entry .dataset_name
588- self .harm_categories = entry .harm_categories
584+ self .harm_categories = list ( entry .harm_categories ) if entry . harm_categories else None
589585 self .description = entry .description
590586 self .authors = list (entry .authors ) if entry .authors else None
591587 self .groups = list (entry .groups ) if entry .groups else None
@@ -1013,6 +1009,8 @@ def __init__(self, *, entry: ScenarioResult) -> None:
10131009 self .pyrit_version = entry .scenario_identifier .pyrit_version
10141010 self .scenario_init_data = entry .scenario_identifier .init_data
10151011 # Convert ComponentIdentifier to dict for JSON storage
1012+ if entry .objective_target_identifier is None :
1013+ raise ValueError ("ScenarioResult.objective_target_identifier is required for database storage" )
10161014 self .objective_target_identifier = entry .objective_target_identifier .to_dict (
10171015 max_value_length = MAX_IDENTIFIER_VALUE_LENGTH
10181016 )
@@ -1103,7 +1101,7 @@ def get_scenario_result(self) -> ScenarioResult:
11031101 scenario_identifier = scenario_identifier ,
11041102 objective_target_identifier = target_identifier ,
11051103 attack_results = attack_results ,
1106- objective_scorer_identifier = scorer_identifier , # type: ignore[ty:invalid-argument-type]
1104+ objective_scorer_identifier = scorer_identifier ,
11071105 scenario_run_state = self .scenario_run_state ,
11081106 labels = self .labels ,
11091107 creation_time = self .timestamp ,
0 commit comments