@@ -40,7 +40,7 @@ def generate_summary(t):
4040
4141 assert isinstance (result , dict )
4242 assert result ["_debug" ]["prompt" ] == "Generate a summary of the following text: Hello, world!"
43- assert result ["_debug" ]["kwargs " ] == {"t" : "Hello, world!" }
43+ assert result ["_debug" ]["template_inputs " ] == {"t" : "Hello, world!" }
4444 assert result ["_debug" ]["system" ] == "You are a helpful assistant."
4545 assert result ["result" ]
4646
@@ -56,7 +56,41 @@ def generate_summary(a, b, c):
5656
5757 assert isinstance (result , dict )
5858 assert result ["_debug" ]["prompt" ] == "Generate a summary of the following text: Hello world !"
59- assert result ["_debug" ]["kwargs " ] == {"a" : "Hello" , "b" : "world" , "c" : "!" }
59+ assert result ["_debug" ]["template_inputs " ] == {"a" : "Hello" , "b" : "world" , "c" : "!" }
6060 assert result ["_debug" ]["system" ] == "You are a helpful assistant."
6161 assert result ["result" ]
62-
62+
63+
64+ def test_debug_info_keys ():
65+ """Test that all expected debug info keys are present with correct types"""
66+ @backend ("markov" , debug = True , system = "You are a helpful assistant." )
67+ def generate_summary (text ):
68+ """Generate a summary of the following text: {{ text }}"""
69+ pass
70+
71+ result = generate_summary ("Hello, world!" )
72+ debug_info = result ["_debug" ]
73+
74+ # Check all expected keys are present
75+ expected_keys = {
76+ "template" : str , # Original docstring template
77+ "func_name" : str , # Name of the function
78+ "prompt" : str , # Rendered prompt
79+ "system" : str , # System prompt
80+ "template_inputs" : dict , # Arguments used in template
81+ "backend_kwargs" : dict , # Backend configuration
82+ "datetime" : str , # ISO format datetime
83+ "return_type" : type (None ) # None since no return type specified
84+ }
85+
86+ for key , expected_type in expected_keys .items ():
87+ assert key in debug_info , f"Missing debug key: { key } "
88+ assert isinstance (debug_info [key ], expected_type ), f"Incorrect type for { key } : expected { expected_type } , got { type (debug_info [key ])} "
89+
90+ # Check specific values
91+ assert debug_info ["template" ] == "Generate a summary of the following text: {{ text }}"
92+ assert debug_info ["func_name" ] == "generate_summary"
93+ assert debug_info ["prompt" ] == "Generate a summary of the following text: Hello, world!"
94+ assert debug_info ["system" ] == "You are a helpful assistant."
95+ assert debug_info ["template_inputs" ] == {"text" : "Hello, world!" }
96+ assert debug_info ["return_type" ] is None
0 commit comments