Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
4a3d15b6
Unverified
Commit
4a3d15b6
authored
Jan 04, 2024
by
Jyong
Committed by
GitHub
Jan 04, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix customer spliter character (#1915)
Co-authored-by:
jyong
<
jyong@dify.ai
>
parent
a798dcfa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
file_extractor.py
api/core/data_loader/file_extractor.py
+4
-2
indexing_runner.py
api/core/indexing_runner.py
+8
-8
No files found.
api/core/data_loader/file_extractor.py
View file @
4a3d15b6
...
...
@@ -65,7 +65,8 @@ class FileExtractor:
elif
file_extension
==
'.pdf'
:
loader
=
PdfLoader
(
file_path
,
upload_file
=
upload_file
)
elif
file_extension
in
[
'.md'
,
'.markdown'
]:
loader
=
UnstructuredMarkdownLoader
(
file_path
,
unstructured_api_url
)
loader
=
UnstructuredMarkdownLoader
(
file_path
,
unstructured_api_url
)
if
is_automatic
\
else
MarkdownLoader
(
file_path
,
autodetect_encoding
=
True
)
elif
file_extension
in
[
'.htm'
,
'.html'
]:
loader
=
HTMLLoader
(
file_path
)
elif
file_extension
==
'.docx'
:
...
...
@@ -84,7 +85,8 @@ class FileExtractor:
loader
=
UnstructuredXmlLoader
(
file_path
,
unstructured_api_url
)
else
:
# txt
loader
=
UnstructuredTextLoader
(
file_path
,
unstructured_api_url
)
loader
=
UnstructuredTextLoader
(
file_path
,
unstructured_api_url
)
if
is_automatic
\
else
TextLoader
(
file_path
,
autodetect_encoding
=
True
)
else
:
if
file_extension
==
'.xlsx'
:
loader
=
ExcelLoader
(
file_path
)
...
...
api/core/indexing_runner.py
View file @
4a3d15b6
...
...
@@ -59,7 +59,7 @@ class IndexingRunner:
first
()
# load file
text_docs
=
self
.
_load_data
(
dataset_document
)
text_docs
=
self
.
_load_data
(
dataset_document
,
processing_rule
.
mode
==
'automatic'
)
# get splitter
splitter
=
self
.
_get_splitter
(
processing_rule
)
...
...
@@ -113,15 +113,14 @@ class IndexingRunner:
for
document_segment
in
document_segments
:
db
.
session
.
delete
(
document_segment
)
db
.
session
.
commit
()
# load file
text_docs
=
self
.
_load_data
(
dataset_document
)
# get the process rule
processing_rule
=
db
.
session
.
query
(
DatasetProcessRule
)
.
\
filter
(
DatasetProcessRule
.
id
==
dataset_document
.
dataset_process_rule_id
)
.
\
first
()
# load file
text_docs
=
self
.
_load_data
(
dataset_document
,
processing_rule
.
mode
==
'automatic'
)
# get splitter
splitter
=
self
.
_get_splitter
(
processing_rule
)
...
...
@@ -238,14 +237,15 @@ class IndexingRunner:
preview_texts
=
[]
total_segments
=
0
for
file_detail
in
file_details
:
# load data from file
text_docs
=
FileExtractor
.
load
(
file_detail
)
processing_rule
=
DatasetProcessRule
(
mode
=
tmp_processing_rule
[
"mode"
],
rules
=
json
.
dumps
(
tmp_processing_rule
[
"rules"
])
)
# load data from file
text_docs
=
FileExtractor
.
load
(
file_detail
,
is_automatic
=
processing_rule
.
mode
==
'automatic'
)
# get splitter
splitter
=
self
.
_get_splitter
(
processing_rule
)
...
...
@@ -459,7 +459,7 @@ class IndexingRunner:
one_or_none
()
if
file_detail
:
text_docs
=
FileExtractor
.
load
(
file_detail
,
is_automatic
=
True
)
text_docs
=
FileExtractor
.
load
(
file_detail
,
is_automatic
=
automatic
)
elif
dataset_document
.
data_source_type
==
'notion_import'
:
loader
=
NotionLoader
.
from_document
(
dataset_document
)
text_docs
=
loader
.
load
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment