Spaces:
Sleeping
Sleeping
File size: 816 Bytes
b73a4fc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
def postprocess_label(labels: list[str]) -> str:
"""
Creates a label string with the format
"Partially generated by [label1] and [label2] and ...".
Removes duplicate labels while preserving the original order.
Args:
labels: A list of strings representing labels.
Returns:
A string with the formatted label.
"""
labels = list(set(labels))
label = "Partially generated by "
if len(label) == 1:
label += labels[0]
elif len(labels) == 2:
label += f"{labels[0]} and {labels[1]}"
else:
combination = ", ".join(labels[0 : len(labels) - 1])
label += f"{combination}, and {labels[-1]}"
return label
labels = ["gpt-4o", "gpt-4o-mini", "gpt-4o-l"]
postprocessed_label = postprocess_label(labels)
print(postprocessed_label)
|