from dataclasses import dataclass, field from typing import List, Dict, Any @dataclass(frozen=True) class Response: name: str sentence_texts: List[str] @dataclass(frozen=True) class Responses: responses: Dict[str, Response] @staticmethod def from_dict(input_dict: Dict[str, Any]) -> "Responses": # responses: # ResponseName: # data: # - sentences: # - "" return Responses( responses={ response_name: Response( name=response_name, sentence_texts=response_dict["sentences"] ) for response_name, response_dict in input_dict["responses"].items() }, )