@@ -110,13 +110,13 @@ def test_create_chat_prompt_with_placeholders():
110110 second_prompt_client = langfuse .get_prompt (prompt_name , type = "chat" )
111111
112112 messages = second_prompt_client .compile_with_placeholders (
113- variables = {"role" : "helpful" , "task" : "coding" },
114113 placeholders = {
115114 "history" : [
116115 {"role" : "user" , "content" : "Example: {{task}}" },
117116 {"role" : "assistant" , "content" : "Example response" },
118117 ],
119118 },
119+ variables = {"role" : "helpful" , "task" : "coding" },
120120 )
121121
122122 # Create a test generation using compiled messages
@@ -205,7 +205,7 @@ def test_get_prompt_with_placeholders():
205205
206206
207207@pytest .mark .parametrize (
208- "variables, placeholders, expected_len, expected_contents" ,
208+ ( "variables" , " placeholders" , " expected_len" , " expected_contents") ,
209209 [
210210 # Variables only, no placeholders
211211 (
@@ -223,7 +223,24 @@ def test_get_prompt_with_placeholders():
223223 "examples" : [
224224 {"role" : "user" , "content" : "Example question" },
225225 {"role" : "assistant" , "content" : "Example answer" },
226- ]
226+ ],
227+ },
228+ 4 ,
229+ [
230+ "You are a {{role}} assistant" ,
231+ "Example question" ,
232+ "Example answer" ,
233+ "Help me with {{task}}" ,
234+ ],
235+ ),
236+ # Placeholders only, variables None
237+ (
238+ None ,
239+ {
240+ "examples" : [
241+ {"role" : "user" , "content" : "Example question" },
242+ {"role" : "assistant" , "content" : "Example answer" },
243+ ],
227244 },
228245 4 ,
229246 [
@@ -240,7 +257,7 @@ def test_get_prompt_with_placeholders():
240257 "examples" : [
241258 {"role" : "user" , "content" : "Show me {{task}}" },
242259 {"role" : "assistant" , "content" : "Here's {{task}}" },
243- ]
260+ ],
244261 },
245262 4 ,
246263 [
@@ -250,13 +267,14 @@ def test_get_prompt_with_placeholders():
250267 "Help me with coding" ,
251268 ],
252269 ),
253- # Empty placeholder array
254- (
255- {"role" : "helpful" , "task" : "coding" },
256- {"examples" : []},
257- 2 ,
258- ["You are a helpful assistant" , "Help me with coding" ],
259- ),
270+ # # Empty placeholder array
271+ # This is expected to fail! If the user provides a placeholder, it should contain an array
272+ # (
273+ # {"role": "helpful", "task": "coding"},
274+ # {"examples": []},
275+ # 2,
276+ # ["You are a helpful assistant", "Help me with coding"],
277+ # ),
260278 # Unused placeholders
261279 (
262280 {"role" : "helpful" , "task" : "coding" },
@@ -288,7 +306,8 @@ def test_compile_with_placeholders(
288306 )
289307
290308 result = ChatPromptClient (mock_prompt ).compile_with_placeholders (
291- variables , placeholders
309+ placeholders ,
310+ variables ,
292311 )
293312
294313 assert len (result ) == expected_len
0 commit comments