Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- pages/Brain_Search.py +6 -6
pages/Brain_Search.py
CHANGED
@@ -23,8 +23,8 @@ def extract_text_from_txt(txt):
|
|
23 |
return text
|
24 |
|
25 |
|
26 |
-
def
|
27 |
-
with open('
|
28 |
text = file.read()
|
29 |
return text
|
30 |
|
@@ -47,7 +47,7 @@ def main():
|
|
47 |
if not api_key:
|
48 |
st.warning("Please enter your OpenAI API key to continue.")
|
49 |
else:
|
50 |
-
file_type = st.selectbox("Choose the file type", options=["
|
51 |
|
52 |
file = None
|
53 |
text = None
|
@@ -60,10 +60,10 @@ def main():
|
|
60 |
file = st.file_uploader("Upload your TXT", type="txt")
|
61 |
if file is not None:
|
62 |
text = extract_text_from_txt(file)
|
63 |
-
elif file_type == "
|
64 |
-
text =
|
65 |
|
66 |
-
if file is not None or file_type == "
|
67 |
# split into chunks
|
68 |
text_splitter = CharacterTextSplitter(
|
69 |
separator="\n",
|
|
|
23 |
return text
|
24 |
|
25 |
|
26 |
+
def extract_text_from_brain():
|
27 |
+
with open('brain/brain_journal.txt', 'r', encoding='utf-8') as file:
|
28 |
text = file.read()
|
29 |
return text
|
30 |
|
|
|
47 |
if not api_key:
|
48 |
st.warning("Please enter your OpenAI API key to continue.")
|
49 |
else:
|
50 |
+
file_type = st.selectbox("Choose the file type", options=["Brain", "PDF", "TXT"])
|
51 |
|
52 |
file = None
|
53 |
text = None
|
|
|
60 |
file = st.file_uploader("Upload your TXT", type="txt")
|
61 |
if file is not None:
|
62 |
text = extract_text_from_txt(file)
|
63 |
+
elif file_type == "Brain":
|
64 |
+
text = extract_text_from_brain()
|
65 |
|
66 |
+
if file is not None or file_type == "Brain":
|
67 |
# split into chunks
|
68 |
text_splitter = CharacterTextSplitter(
|
69 |
separator="\n",
|