Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -419,29 +419,16 @@ def get_trust_tip_and_suggestion():
|
|
| 419 |
|
| 420 |
|
| 421 |
def load_main_data_source():
|
| 422 |
-
"""
|
| 423 |
-
Load the main data source and return a list of Document objects.
|
| 424 |
-
"""
|
| 425 |
try:
|
| 426 |
-
|
| 427 |
-
if not os.path.exists(data_path):
|
| 428 |
-
st.error(f"Data source file not found at: {data_path}")
|
| 429 |
-
return []
|
| 430 |
-
|
| 431 |
-
with open(data_path, "r") as f:
|
| 432 |
main_content = f.read()
|
| 433 |
-
|
| 434 |
-
# Split
|
| 435 |
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
|
| 436 |
main_texts = text_splitter.split_text(main_content)
|
| 437 |
|
| 438 |
-
# Create Document objects
|
| 439 |
main_documents = [Document(page_content=text) for text in main_texts]
|
| 440 |
-
if not main_documents:
|
| 441 |
-
st.error("No documents created. Data source may be empty.")
|
| 442 |
-
return []
|
| 443 |
-
|
| 444 |
-
st.write(f"Loaded {len(main_documents)} documents from the data source.")
|
| 445 |
return main_documents
|
| 446 |
except Exception as e:
|
| 447 |
st.error(f"Error loading main data source: {e}")
|
|
|
|
| 419 |
|
| 420 |
|
| 421 |
def load_main_data_source():
|
|
|
|
|
|
|
|
|
|
| 422 |
try:
|
| 423 |
+
with open("./data_source/time_to_rethink_trust_book.md", "r") as f:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 424 |
main_content = f.read()
|
| 425 |
+
|
| 426 |
+
# Split main content into chunks
|
| 427 |
text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
|
| 428 |
main_texts = text_splitter.split_text(main_content)
|
| 429 |
|
| 430 |
+
# Create Document objects for the main data source
|
| 431 |
main_documents = [Document(page_content=text) for text in main_texts]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 432 |
return main_documents
|
| 433 |
except Exception as e:
|
| 434 |
st.error(f"Error loading main data source: {e}")
|