| 20 | |
| 21 | |
| 22 | class ProcessorArgs(BaseModel): |
| 23 | majority_voting: MajorityVotingArgs = Field(default=None) |
| 24 | answer_extraction: AnswerExtractionArgs = Field(default=None) |
| 25 | |
| 26 | @classmethod |
| 27 | def from_dict(cls, config_dict: Dict[str, Dict]) -> "ProcessorArgs": |
| 28 | answer_extraction: AnswerExtractionArgs = None |
| 29 | majority_voting: MajorityVotingArgs = None |
| 30 | |
| 31 | for method, arguments in config_dict.items(): |
| 32 | if method == "answer_extraction": |
| 33 | enable: bool = arguments.get("enable", True) |
| 34 | answer_extraction = AnswerExtractionArgs(enable=enable) |
| 35 | elif method == "majority_voting": |
| 36 | samples: Union[Dict, List[Dict]] = arguments.get("samples") |
| 37 | majority_voting = MajorityVotingArgs(enable=True, samples=samples) |
| 38 | # majority_voting need extract answers from LLM response, so enable answer_extraction at the same time |
| 39 | answer_extraction = AnswerExtractionArgs(enable=True) |
| 40 | else: |
| 41 | raise Exception(f"No process method named {method}.") |
| 42 | |
| 43 | return cls( |
| 44 | majority_voting=majority_voting, |
| 45 | answer_extraction=answer_extraction |
| 46 | ) |
no outgoing calls
no test coverage detected