Update app.py
Browse files
app.py
CHANGED
@@ -48,10 +48,10 @@ def load_wikipedia_documents():
|
|
48 |
return []
|
49 |
|
50 |
@st.cache_resource
|
51 |
-
def split_documents(
|
52 |
"""Split documents into chunks."""
|
53 |
splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=50)
|
54 |
-
chunks = splitter.split_documents(
|
55 |
logger.info(f"Split into {len(chunks)} chunks")
|
56 |
return chunks
|
57 |
|
@@ -178,6 +178,8 @@ def main():
|
|
178 |
if not documents:
|
179 |
return
|
180 |
chunks = split_documents(documents)
|
|
|
|
|
181 |
embeddings = initialize_embeddings()
|
182 |
if embeddings is None:
|
183 |
return
|
|
|
48 |
return []
|
49 |
|
50 |
@st.cache_resource
|
51 |
+
def split_documents(_documents):
|
52 |
"""Split documents into chunks."""
|
53 |
splitter = RecursiveCharacterTextSplitter(chunk_size=500, chunk_overlap=50)
|
54 |
+
chunks = splitter.split_documents(_documents)
|
55 |
logger.info(f"Split into {len(chunks)} chunks")
|
56 |
return chunks
|
57 |
|
|
|
178 |
if not documents:
|
179 |
return
|
180 |
chunks = split_documents(documents)
|
181 |
+
if not chunks:
|
182 |
+
return
|
183 |
embeddings = initialize_embeddings()
|
184 |
if embeddings is None:
|
185 |
return
|