✨ Add support for new filetypes#2429
Open
yzAiden wants to merge 3 commits intoModelEngine-Group:developfrom
Open
✨ Add support for new filetypes#2429yzAiden wants to merge 3 commits intoModelEngine-Group:developfrom
yzAiden wants to merge 3 commits intoModelEngine-Group:developfrom
Conversation
Jasonxia007
reviewed
Feb 25, 2026
backend/database/attachment_db.py
Outdated
| '.html': 'text/html', | ||
| '.htm': 'text/html', | ||
| '.json': 'application/json', | ||
| '.epub': 'application/epuub', |
Contributor
There was a problem hiding this comment.
拼写有误,应为 application/epub,请检查
Jasonxia007
reviewed
Feb 25, 2026
frontend/const/knowledgeBase.ts
Outdated
| [FILE_EXTENSIONS.MD]: FILE_TYPES.MARKDOWN | ||
| [FILE_EXTENSIONS.MD]: FILE_TYPES.MARKDOWN, | ||
| [FILE_EXTENSIONS.CSV]: FILE_TYPES.CSV, | ||
| [FILE_EXTENSIONS.JSON]: FILE_EXTENSIONS.JSON, |
Contributor
There was a problem hiding this comment.
这里似乎应该是 FILE_TYPES.JSON,请检查
Jasonxia007
reviewed
Feb 25, 2026
| Returns: | ||
| List of text chunks | ||
| """ | ||
| import orjson |
Jasonxia007
reviewed
Feb 25, 2026
|
|
||
| try: | ||
| data = orjson.loads(file_data) | ||
| except Exception: |
Contributor
There was a problem hiding this comment.
建议使用orjson的自定异常类,明确区分Decode问题和其他读取问题
Jasonxia007
reviewed
Feb 25, 2026
Comment on lines
+72
to
+73
| while i > 0 and text[i - 1] not in PUNCTS: | ||
| i -= 1 |
Contributor
There was a problem hiding this comment.
对于标点后带行尾空格的场景,建议先strip,否则下一分段头部会留有空格
Jasonxia007
requested changes
Feb 25, 2026
Comment on lines
+130
to
+135
| if c == "\\": | ||
| esc = True | ||
| continue | ||
| if c == '"': | ||
| in_str = not in_str | ||
| continue |
Contributor
There was a problem hiding this comment.
- 扫描是从右到左的,但 esc 却在保护 "\" 的下一个(即左侧的)字符,这与期望不一致;
- 似乎没有考虑注释行的场景。
建议仔细检查,并使用复杂json体进行自测:
{
# case1: 值中包含转义引号
"greeting": "hello \"world\", how are you",
# case2: 值中包含逗号
"address": "Beijing, Chaoyang, No.1",
# case3: 嵌套对象
"nested": {
"inner_key": "inner, value",
"deep": {"a": 1, "b": 2}
},
# case4: 数组
"scores": [10, 20, 30],
# case5: 值中包含花括号字符
"template": "use {var} and [idx] here",
# case6: 连续转义 \\\"
"escaped_bs": "path is C:\\\\server\\\\share\\\"name\\\"",
# case7: unicode 转义
"unicode": "emoji \u00e9\u00e0",
# case8: 空字符串
"empty": "",
# case9: 布尔和null
"flag": True,
"nothing": None,
# case10: 数字
"count": 42
}679ef3c to
2dfd444
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
一、功能:
1.提升数据清洗能力:支持.epub, .html, .csv, .json, .xml文件类型的清洗和检索。
二、设计:
1.所有新增文件类型均由UnstructuredProcessor进行处理。
2..epub, .html, .csv, .xml类型文件与现有处理逻辑完全一致。
3.对json类型文件的分片进行单独设计,方式为优先将 JSON 解析为文本并在不破坏最外层 key-value 语义的前提下按长度切分,无法安全按 KV 切分时退化为按标点的纯文本切分,解析失败则直接按纯文本策略分片。其余流程与现有处理方式一致。
三、主要改动的位置:
1.sdk/nexent/data_process
四、相关issue引用
#2258