Skip to content

Commit 3b8a7d1

Browse files
committed
push
1 parent ef1701c commit 3b8a7d1

File tree

5 files changed

+41
-1204
lines changed

5 files changed

+41
-1204
lines changed

tests/test_prompt.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,3 +1081,36 @@ def test_variable_names_on_content_with_no_variable_names_chat_messages():
10811081
var_names = second_prompt_client.variables
10821082

10831083
assert var_names == []
1084+
1085+
1086+
def test_update_prompt():
1087+
langfuse = Langfuse()
1088+
prompt_name = create_uuid()
1089+
1090+
# Create initial prompt
1091+
langfuse.create_prompt(
1092+
name=prompt_name,
1093+
prompt="test prompt",
1094+
labels=["production"],
1095+
)
1096+
1097+
# Update prompt labels
1098+
updated_prompt = langfuse.update_prompt(
1099+
name=prompt_name,
1100+
version=1,
1101+
new_labels=["john", "doe"],
1102+
)
1103+
1104+
# Fetch prompt after update (should be invalidated)
1105+
fetched_prompt = langfuse.get_prompt(prompt_name)
1106+
1107+
# Verify the fetched prompt matches the updated values
1108+
assert fetched_prompt.name == prompt_name
1109+
assert fetched_prompt.version == 1
1110+
print(f"Fetched prompt labels: {fetched_prompt.labels}")
1111+
print(f"Updated prompt labels: {updated_prompt.labels}")
1112+
1113+
# production was set by the first call, latest is managed and set by Langfuse
1114+
expected_labels = sorted(["latest", "doe", "production", "john"])
1115+
assert sorted(fetched_prompt.labels) == expected_labels
1116+
assert sorted(updated_prompt.labels) == expected_labels

0 commit comments

Comments
 (0)