mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-12 09:19:03 +08:00
Fix json file parse (#4004)
### What problem does this PR solve? Fix json file parsing ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --------- Signed-off-by: jinhai <haijin.chn@gmail.com>
This commit is contained in:
parent
9ae81b42a3
commit
275b5d14f2
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from rag.nlp import find_codec
|
from rag.nlp import find_codec
|
||||||
class RAGFlowJsonParser:
|
class RAGFlowJsonParser:
|
||||||
def __init__(
|
def __init__(
|
||||||
@ -53,7 +54,7 @@ class RAGFlowJsonParser:
|
|||||||
|
|
||||||
def _json_split(
|
def _json_split(
|
||||||
self,
|
self,
|
||||||
data: dict[str, Any],
|
data,
|
||||||
current_path: list[str] | None,
|
current_path: list[str] | None,
|
||||||
chunks: list[dict] | None,
|
chunks: list[dict] | None,
|
||||||
) -> list[dict]:
|
) -> list[dict]:
|
||||||
@ -86,13 +87,14 @@ class RAGFlowJsonParser:
|
|||||||
|
|
||||||
def split_json(
|
def split_json(
|
||||||
self,
|
self,
|
||||||
json_data: dict[str, Any],
|
json_data,
|
||||||
convert_lists: bool = False,
|
convert_lists: bool = False,
|
||||||
) -> list[dict]:
|
) -> list[dict]:
|
||||||
"""Splits JSON into a list of JSON chunks"""
|
"""Splits JSON into a list of JSON chunks"""
|
||||||
|
|
||||||
if convert_lists:
|
if convert_lists:
|
||||||
chunks = self._json_split(self._list_to_dict_preprocessing(json_data), None, None)
|
preprocessed_data = self._list_to_dict_preprocessing(json_data)
|
||||||
|
chunks = self._json_split(preprocessed_data, None, None)
|
||||||
else:
|
else:
|
||||||
chunks = self._json_split(json_data, None, None)
|
chunks = self._json_split(json_data, None, None)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user