File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -129,8 +129,14 @@ def create_prompt(
129129 """
130130 write_log (f"Creating prompt for { len (marker_genes )} clusters" )
131131
132+ # Validate custom template type and use default template when empty.
133+ if prompt_template is not None and not isinstance (prompt_template , str ):
134+ raise ValueError (
135+ f"prompt_template must be a string or None, got { type (prompt_template ).__name__ } "
136+ )
137+
132138 # Use default template if not provided
133- if not prompt_template :
139+ if not prompt_template or not prompt_template . strip () :
134140 prompt_template = DEFAULT_PROMPT_TEMPLATE
135141
136142 # Default tissue if none provided
Original file line number Diff line number Diff line change @@ -88,6 +88,16 @@ def test_create_prompt_with_malformed_template_raises_clear_error(self):
8888 prompt_template = bad_template ,
8989 )
9090
91+ def test_create_prompt_with_non_string_template_raises_clear_error (self ):
92+ """Test non-string custom templates fail with explicit type guidance."""
93+ with pytest .raises (ValueError , match = "prompt_template must be a string or None" ):
94+ create_prompt (
95+ marker_genes = self .marker_genes ,
96+ species = "human" ,
97+ tissue = "blood" ,
98+ prompt_template = 123 , # type: ignore[arg-type]
99+ )
100+
91101 def test_create_initial_discussion_prompt (self ):
92102 """Test initial discussion prompt creation."""
93103 cluster_id = "1"
You can’t perform that action at this time.
0 commit comments