in experiments/google/cloud/ml/applied/attributes/attributes.py [0:0]
def parse_answer(ans: str) -> dict[str, str]:
"""Translate LLM response into dict.
Args:
ans: '|' separated key value pairs e.g. 'color:red|size:large'
Returns:
ans as a dictionary
"""
d = {}
for a in ans.split("|"):
k, v = a.split(":")
d[k.strip()] = v.strip()
return d