@@ -1410,3 +1410,37 @@ def test_update_prompt():
14101410 expected_labels = sorted (["latest" , "doe" , "production" , "john" ])
14111411 assert sorted (fetched_prompt .labels ) == expected_labels
14121412 assert sorted (updated_prompt .labels ) == expected_labels
1413+
1414+
1415+ def test_update_prompt_in_folder ():
1416+ langfuse = Langfuse ()
1417+ prompt_name = f"some-folder/{ create_uuid ()} "
1418+
1419+ # Create initial prompt
1420+ langfuse .create_prompt (
1421+ name = prompt_name ,
1422+ prompt = "test prompt" ,
1423+ labels = ["production" ],
1424+ )
1425+
1426+ old_prompt_obj = langfuse .get_prompt (prompt_name )
1427+
1428+ updated_prompt = langfuse .update_prompt (
1429+ name = old_prompt_obj .name ,
1430+ version = old_prompt_obj .version ,
1431+ new_labels = ["john" , "doe" ],
1432+ )
1433+
1434+ # Fetch prompt after update (should be invalidated)
1435+ fetched_prompt = langfuse .get_prompt (prompt_name )
1436+
1437+ # Verify the fetched prompt matches the updated values
1438+ assert fetched_prompt .name == prompt_name
1439+ assert fetched_prompt .version == 1
1440+ print (f"Fetched prompt labels: { fetched_prompt .labels } " )
1441+ print (f"Updated prompt labels: { updated_prompt .labels } " )
1442+
1443+ # production was set by the first call, latest is managed and set by Langfuse
1444+ expected_labels = sorted (["latest" , "doe" , "production" , "john" ])
1445+ assert sorted (fetched_prompt .labels ) == expected_labels
1446+ assert sorted (updated_prompt .labels ) == expected_labels
0 commit comments