MCPcopy
hub / github.com/LazyAGI/LazyLLM / _reduce_aggregate

Method _reduce_aggregate

lazyllm/tools/tools/json.py:180–192  ·  view source on GitHub ↗
(self, schema: Optional[Dict[str, Any]], jsons: List[Dict[str, Any]],
                          prefix: str = '')

Source from the content-addressed store, hash-verified

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]:

Callers 1

forwardMethod · 0.95

Calls 2

itemsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected