MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / result_tree_to_paragraph

Function result_tree_to_paragraph

apps/common/utils/split_model.py:249–266  ·  view source on GitHub ↗

转换为分段对象 :param result_tree: 解析文本的树 :param result: 传[] 用于递归 :param parent_chain: 传[] 用户递归存储数据 :param with_filter: 是否过滤block :return: List[{'problem':'xx','content':'xx'}]

(result_tree: List[dict], result, parent_chain, with_filter: bool)

Source from the content-addressed store, hash-verified

247
248
249def result_tree_to_paragraph(result_tree: List[dict], result, parent_chain, with_filter: bool):
250 """
251 转换为分段对象
252 :param result_tree: 解析文本的树
253 :param result: 传[] 用于递归
254 :param parent_chain: 传[] 用户递归存储数据
255 :param with_filter: 是否过滤block
256 :return: List[{'problem':'xx','content':'xx'}]
257 """
258 for item in result_tree:
259 if item.get('state') == 'block':
260 result.append({'title': " ".join(parent_chain),
261 'content': filter_special_char(item.get("content")) if with_filter else item.get("content")})
262 children = item.get("children")
263 if children is not None and len(children) > 0:
264 result_tree_to_paragraph(children, result,
265 [*parent_chain, remove_special_symbol(item.get('content'))], with_filter)
266 return result
267
268
269def post_handler_paragraph(content: str, limit: int):

Callers 1

parseMethod · 0.85

Calls 4

filter_special_charFunction · 0.85
remove_special_symbolFunction · 0.85
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected