| 178 | return True |
| 179 | |
| 180 | def _reduce_aggregate(self, schema: Optional[Dict[str, Any]], jsons: List[Dict[str, Any]], |
| 181 | prefix: str = '') -> Dict[str, Any]: |
| 182 | if not jsons: return {} |
| 183 | result = {} |
| 184 | for key, value in schema.items(): |
| 185 | if isinstance(value, dict): |
| 186 | result[key] = self._reduce_aggregate(value, [json[key] for json in jsons if json.get(key)], |
| 187 | f'{prefix}.{key}' if prefix else key) |
| 188 | else: |
| 189 | result[key] = [json[key] for json in jsons if key in json] |
| 190 | if self._llm is not None: |
| 191 | result[key] = self._llm(dict(key=key, value_list=str(result[key]))) |
| 192 | return result |
| 193 | |
| 194 | def _extract_schema(self, jsons: List[Dict[str, Any]], schema: Optional[Dict[str, Any]] = None, |
| 195 | prefix: str = '') -> Dict[str, Any]: |