haystack
haystack copied to clipboard
MultiLabel serialization is broken
Describe the bug
When I convert a MultiLabel to dict via label.to_dict, then I can't convert it back to a MultiLabel
Test for reproducing
def test_deserialize():
x = {
"labels": [
{
"id": "011079cf-c93f-49e6-83bb-42cd850dce12",
"query": "When was the final season first shown on TV?",
"document": {
"content": "\n\n\n\n\nThe eighth and final season of the fantasy drama television series ''Game of Thrones'', produced by HBO, premiered on April 14, 2019, and concluded on May 19, 2019. Unlike the first six seasons, which consisted of ten episodes each, and the seventh season, which consisted of seven episodes, the eighth season consists of only six episodes.\n\nThe final season depicts the culmination of the series' two primary conflicts: the G",
"content_type": "text",
"id": "9c82c97c9dc8ba6895893a53aafa610f",
"meta": {},
"score": None,
"embedding": None,
},
"is_correct_answer": True,
"is_correct_document": True,
"origin": "user-feedback",
"answer": {
"answer": "April 14",
"type": "extractive",
"score": None,
"context": "\n\n\n\n\nThe eighth and final season of the fantasy drama television series ''Game of Thrones'', produced by HBO, premiered on April 14, 2019, and concluded on May 19, 2019. Unlike the first six seasons, which consisted of ten episodes each, and the seventh season, which consisted of seven episodes, the eighth season consists of only six episodes.\n\nThe final season depicts the culmination of the series' two primary conflicts: the G",
"offsets_in_document": [{"start": 124, "end": 132}],
"offsets_in_context": None,
"document_id": None,
"meta": {},
},
"no_answer": False,
"pipeline_id": None,
"created_at": "2022-07-22T13:29:33.699781+00:00",
"updated_at": "2022-07-22T13:29:33.784895+00:00",
"meta": {"answer_id": "374394", "document_id": "604995", "question_id": "345530"},
"filters": None,
}
],
"query": "When was the final season first shown on TV?",
"answers": ["April 14"],
"no_answer": False,
"document_ids": ["9c82c97c9dc8ba6895893a53aafa610f"],
"contexts": [
"\n\n\n\n\nThe eighth and final season of the fantasy drama television series ''Game of Thrones'', produced by HBO, premiered on April 14, 2019, and concluded on May 19, 2019. Unlike the first six seasons, which consisted of ten episodes each, and the seventh season, which consisted of seven episodes, the eighth season consists of only six episodes.\n\nThe final season depicts the culmination of the series' two primary conflicts: the G"
],
"offsets_in_contexts": [],
"offsets_in_documents": [{"start": 124, "end": 132}],
}
MultiLabel.from_dict(x)
Expected behavior This should work :-)