Spaces:
Sleeping
Sleeping
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) | |