Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +9 -10
src/streamlit_app.py
CHANGED
|
@@ -26,16 +26,15 @@ import json
|
|
| 26 |
from langchain.docstore.document import Document
|
| 27 |
from langchain_groq import ChatGroq
|
| 28 |
|
| 29 |
-
# PDF ๋ฌธ์๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋
|
| 30 |
def get_pdf_text(pdf_docs):
|
| 31 |
-
temp_dir = tempfile.TemporaryDirectory()
|
| 32 |
-
temp_filepath = os.path.join(temp_dir.name, pdf_docs.name)
|
| 33 |
-
with open(temp_filepath, "wb") as f:
|
| 34 |
-
f.write(pdf_docs.getvalue())
|
| 35 |
-
pdf_loader = PyPDFLoader(temp_filepath)
|
| 36 |
-
pdf_doc = pdf_loader.load()
|
| 37 |
-
return pdf_doc
|
| 38 |
-
|
| 39 |
|
| 40 |
# txt ํ์ผ๋ก๋ถํฐ text ์ถ์ถ
|
| 41 |
def get_text_file(txt_docs):
|
|
@@ -44,7 +43,7 @@ def get_text_file(txt_docs):
|
|
| 44 |
with open(temp_filepath, "wb") as f:
|
| 45 |
f.write(txt_docs.getvalue())
|
| 46 |
text_loader = TextLoader(temp_filepath)
|
| 47 |
-
text_doc = text_loader.load()
|
| 48 |
return text_doc
|
| 49 |
|
| 50 |
# csv ํ์ผ๋ก๋ถํฐ text ์ถ์ถ
|
|
|
|
| 26 |
from langchain.docstore.document import Document
|
| 27 |
from langchain_groq import ChatGroq
|
| 28 |
|
| 29 |
+
# PDF ๋ฌธ์๋ก๋ถํฐ ํ
์คํธ๋ฅผ ์ถ์ถํ๋ ํจ์
|
| 30 |
def get_pdf_text(pdf_docs):
|
| 31 |
+
temp_dir = tempfile.TemporaryDirectory()
|
| 32 |
+
temp_filepath = os.path.join(temp_dir.name, pdf_docs.name)
|
| 33 |
+
with open(temp_filepath, "wb") as f:
|
| 34 |
+
f.write(pdf_docs.getvalue())
|
| 35 |
+
pdf_loader = PyPDFLoader(temp_filepath)
|
| 36 |
+
pdf_doc = pdf_loader.load()
|
| 37 |
+
return pdf_doc
|
|
|
|
| 38 |
|
| 39 |
# txt ํ์ผ๋ก๋ถํฐ text ์ถ์ถ
|
| 40 |
def get_text_file(txt_docs):
|
|
|
|
| 43 |
with open(temp_filepath, "wb") as f:
|
| 44 |
f.write(txt_docs.getvalue())
|
| 45 |
text_loader = TextLoader(temp_filepath)
|
| 46 |
+
text_doc = text_loader.load()
|
| 47 |
return text_doc
|
| 48 |
|
| 49 |
# csv ํ์ผ๋ก๋ถํฐ text ์ถ์ถ
|