Update app.py
Browse files
app.py
CHANGED
@@ -59,13 +59,23 @@ def get_json_file(docs):
|
|
59 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
60 |
def get_text_chunks(documents):
|
61 |
text_splitter = RecursiveCharacterTextSplitter(
|
62 |
-
chunk_size=1000,
|
63 |
-
chunk_overlap=200,
|
64 |
-
length_function=len
|
65 |
)
|
66 |
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
|
70 |
|
71 |
# ํ
์คํธ ์ฒญํฌ๋ค๋ก๋ถํฐ ๋ฒกํฐ ์คํ ์ด๋ฅผ ์์ฑํ๋ ํจ์์
๋๋ค.
|
|
|
59 |
# ๋ฌธ์๋ค์ ์ฒ๋ฆฌํ์ฌ ํ
์คํธ ์ฒญํฌ๋ก ๋๋๋ ํจ์์
๋๋ค.
|
60 |
def get_text_chunks(documents):
|
61 |
text_splitter = RecursiveCharacterTextSplitter(
|
62 |
+
chunk_size=1000,
|
63 |
+
chunk_overlap=200,
|
64 |
+
length_function=len
|
65 |
)
|
66 |
|
67 |
+
# ๊ฐ ๋ฌธ์์ ๋ด์ฉ์ ๋ฆฌ์คํธ์ ์ถ๊ฐ
|
68 |
+
texts = []
|
69 |
+
for doc in documents:
|
70 |
+
if isinstance(doc, str):
|
71 |
+
# ๋ฌธ์์ด์ธ ๊ฒฝ์ฐ ๊ทธ๋๋ก ์ถ๊ฐ
|
72 |
+
texts.append(doc)
|
73 |
+
else:
|
74 |
+
# ๊ทธ ์ธ์ ๊ฒฝ์ฐ์๋ ๋ฌธ์์ ๋ด์ฉ์ ์ถ๊ฐ
|
75 |
+
texts.append(doc.page_content)
|
76 |
+
|
77 |
+
# ๋๋ ์ฒญํฌ๋ฅผ ๋ฐํ
|
78 |
+
return text_splitter.split_documents(texts)
|
79 |
|
80 |
|
81 |
# ํ
์คํธ ์ฒญํฌ๋ค๋ก๋ถํฐ ๋ฒกํฐ ์คํ ์ด๋ฅผ ์์ฑํ๋ ํจ์์
๋๋ค.
|