Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
8bfda730
Commit
8bfda730
authored
Jan 23, 2024
by
Marclass
Browse files
add excel document support
parent
7eea3ef3
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
backend/apps/rag/main.py
backend/apps/rag/main.py
+6
-0
backend/requirements.txt
backend/requirements.txt
+6
-1
No files found.
backend/apps/rag/main.py
View file @
8bfda730
...
...
@@ -23,6 +23,7 @@ from langchain_community.document_loaders import (
UnstructuredMarkdownLoader
,
UnstructuredXMLLoader
,
UnstructuredRSTLoader
,
UnstructuredExcelLoader
,
)
from
langchain.text_splitter
import
RecursiveCharacterTextSplitter
from
langchain_community.vectorstores
import
Chroma
...
...
@@ -157,6 +158,9 @@ def store_doc(
]
docx_type
=
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
known_doc_ext
=
[
"doc"
,
"docx"
]
excel_types
=
[
"application/vnd.ms-excel"
,
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
]
known_excel_ext
=
[
"xls"
,
"xlsx"
]
file_ext
=
file
.
filename
.
split
(
"."
)[
-
1
].
lower
()
known_type
=
True
...
...
@@ -179,6 +183,8 @@ def store_doc(
loader
=
Docx2txtLoader
(
file_path
)
elif
file_ext
==
"csv"
:
loader
=
CSVLoader
(
file_path
)
elif
(
file
.
content_type
in
excel_types
or
file_ext
in
known_excel_ext
):
loader
=
UnstructuredExcelLoader
(
file_path
)
elif
file_ext
==
"rst"
:
loader
=
UnstructuredRSTLoader
(
file_path
,
mode
=
"elements"
)
elif
file_ext
in
text_xml
:
...
...
backend/requirements.txt
View file @
8bfda730
...
...
@@ -29,3 +29,8 @@ PyJWT
pyjwt[crypto]
black
pandas
openpyxl
pyxlsb
xlrd
\ No newline at end of file
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