Kaludi commited on
Commit
2b10eb4
β€’
1 Parent(s): 1fa1e8c

Upload 4 files

Browse files
VirtualBrainGPT.py CHANGED
@@ -24,7 +24,7 @@ st.markdown(
24
  To begin, simply select either **'Brain Entry'** or **'Brain Search'** from the **sidebar menu**! πŸ‘ˆ
25
 
26
  ### Brain Entry
27
- In the 'Brain Entry' section, users can create a new journal entry or edit an existing one by choosing a date using the date picker. Once you have completed your entry, click 'Submit' and it will be saved or updated to the diary_journal.txt file.
28
 
29
  ### Brain Search
30
  The 'Brain Search' section of the application unlocks the full potential of your digital journal. Here, you can ask any questions related to your journal entries, and the combination of OpenAI's Embeddings API and Langchain will provide accurate responses in seconds, no matter how long the entry or document may be. The virtual brain can help in all aspects of a user's life, enabling users to easily recall specific information, even if they can't remember it themselves. Users also have an option to select other file types if they wish to upload their own file, the current file types include TXT and PDF files, which can be selected in the file type dropdown option.
 
24
  To begin, simply select either **'Brain Entry'** or **'Brain Search'** from the **sidebar menu**! πŸ‘ˆ
25
 
26
  ### Brain Entry
27
+ In the 'Brain Entry' section, users can create a new journal entry or edit an existing one by choosing a date using the date picker. Once you have completed your entry, click 'Submit' and it will be saved or updated to the brain_journal.txt file in the brain folder.
28
 
29
  ### Brain Search
30
  The 'Brain Search' section of the application unlocks the full potential of your digital journal. Here, you can ask any questions related to your journal entries, and the combination of OpenAI's Embeddings API and Langchain will provide accurate responses in seconds, no matter how long the entry or document may be. The virtual brain can help in all aspects of a user's life, enabling users to easily recall specific information, even if they can't remember it themselves. Users also have an option to select other file types if they wish to upload their own file, the current file types include TXT and PDF files, which can be selected in the file type dropdown option.
brain/brain_journal.txt ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Date: 04-24-2023 Monday
2
+ Today was a rollercoaster of emotions. As we enter the last week of senior year, it's finally hitting me that college is coming to an end. I spent most of the day working on my final project for the Capstone course. I can't believe I'm just a few days away from presenting it. In the evening, I met up with my friends for a study session, but we mostly spent the time reminiscing and laughing about our college adventures.
3
+
4
+ Date: 04-25-2023 Tuesday
5
+ Another hectic day filled with finalizing projects and preparing for exams. I received an email from the Career Services office informing me of a potential job opportunity after graduation. The thought of starting my career is both exciting and nerve-wracking. I spent the evening with my roommate, talking about our post-graduation plans and the challenges we'll face in the "real world."
6
+
7
+ Date: 04-26-2023 Wednesday
8
+ Today was the last day of classes! It's such a surreal feeling. My professors shared some words of wisdom and encouragement, which was very touching. After class, I attended a senior send-off event on campus, where we were given our caps and gowns. As we tried them on, the reality of graduating really set in. We took lots of photos to commemorate the moment.
9
+
10
+ Date: 04-27-2023 Thursday
11
+ It's officially finals week. I spent most of my day in the library, studying and finishing up my final papers. My friends and I took a break in the afternoon to grab some ice cream and enjoy the sunshine. We discussed our plans for the upcoming summer and our future careers. The conversation was bittersweet, as we know that we'll soon be parting ways and entering new chapters in our lives.
12
+
13
+ Date: 04-28-2023 Friday
14
+ I had my first final exam this morning. I think it went well, but I'm just relieved it's over. I spent the rest of the day preparing for my Capstone presentation. I'm feeling pretty confident about it, and I can't wait to show my professor and classmates what I've been working on all semester. In the evening, I attended a pre-graduation party with my friends. We danced and sang, embracing every moment together.
15
+
16
+ Date: 04-29-2023 Saturday
17
+ Today was all about relaxation and self-care. I spent the morning catching up on sleep, then went for a run around campus to clear my head. In the afternoon, I attended a yoga class with my friends to destress before our final exams next week. It's important to find balance during these stressful times.
18
+
19
+ Date: 04-30-2023 Sunday
20
+ I'm in full-on study mode for my last two exams. The library was packed, but I managed to find a quiet spot to focus. I took a break in the evening to watch a movie with my roommates. It's our tradition to have a movie night every Sunday, and tonight's choice was a nostalgic throwback to our freshman year.
21
+
22
+ Date: 05-01-2023 Monday
23
+ One more exam down, just one more to go! After finishing today's exam, I met up with my Capstone group to finalize our presentation for tomorrow. We practiced our parts and made last-minute adjustments to our slides. We're all feeling confident and ready to present.
24
+
25
+ Date: 05-02-2023 Tuesday
26
+ We finally presented our Capstone project! It was a huge success, and our professor praised our hard work and dedication. It was such a rewarding feeling to see our project come together after months of effort. In the evening, I attended the Senior Awards Ceremony, where several of my friends received well-deserved awards for their achievements.
27
+
28
+ Date: 05-03-2023 Wednesday
29
+ I completed my final exam today! It's hard to believe that my college journey is coming to an end. To celebrate, my friends and I went out for dinner at our favorite restaurant, reminiscing about our college experiences and sharing our hopes for the future. After dinner, we took a long walk around campus, stopping at all the memorable spots and taking pictures to capture these precious moments. As we walked, we couldn't help but feel a mix of happiness, sadness, and anticipation for what lies ahead.
pages/Brain_Entry.py CHANGED
@@ -9,12 +9,12 @@ hide_streamlit_style = """
9
  """
10
  st.markdown(hide_streamlit_style, unsafe_allow_html=True)
11
 
12
- # Create a 'diary' folder in the current directory if it doesn't exist
13
- if not os.path.exists("diary"):
14
- os.makedirs("diary")
15
 
16
  # Name of the single journal file
17
- journal_file = "diary/diary_journal.txt"
18
 
19
  def parse_date(date_string):
20
  try:
@@ -54,30 +54,53 @@ def read_entry(date):
54
  return content
55
 
56
  def write_entry(date, content):
57
- new_entry = f"\nDate: {date}\n{content}\n"
58
 
59
- # Check if the entry already exists
60
- entry_exists = False
61
- if os.path.exists(journal_file):
62
- with open(journal_file, "r", encoding="utf-8") as f:
63
- lines = f.readlines()
64
- entry_exists = any(line.strip() == f"Date: {date}" for line in lines)
65
-
66
- # If the entry does not exist, append the new entry to the end of the file
67
- if not entry_exists:
68
- with open(journal_file, "a", encoding="utf-8") as f:
69
  f.write(new_entry)
70
  else:
71
- # If the entry exists, update the existing entry
72
  with open(journal_file, "r", encoding="utf-8") as f:
73
  lines = f.readlines()
74
 
75
  # Remove existing entry if present
76
- lines = [line for line in lines if line.strip() != f"Date: {date}"]
 
 
 
 
 
 
 
 
 
 
 
 
 
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  with open(journal_file, "w", encoding="utf-8") as f:
79
  f.writelines(lines)
80
- f.write(new_entry)
 
81
 
82
  st.title("Digital Brain Journal Entry ✍️")
83
  st.write("Write a diary journal entry or edit an existing one by selecting on the date picker.")
@@ -113,4 +136,4 @@ else:
113
 
114
  st.markdown("---")
115
  st.markdown("")
116
- st.markdown("<p style='text-align: center'><a href='https://github.com/Kaludii'>Github</a> | <a href='https://huggingface.co/Kaludi'>HuggingFace</a></p>", unsafe_allow_html=True)
 
9
  """
10
  st.markdown(hide_streamlit_style, unsafe_allow_html=True)
11
 
12
+ # Create a 'brain' folder in the current directory if it doesn't exist
13
+ if not os.path.exists("brain"):
14
+ os.makedirs("brain")
15
 
16
  # Name of the single journal file
17
+ journal_file = "brain/brain_journal.txt"
18
 
19
  def parse_date(date_string):
20
  try:
 
54
  return content
55
 
56
  def write_entry(date, content):
57
+ new_entry = f"\nDate: {date}\n{content}\n\n"
58
 
59
+ # If the journal file does not exist, create it with the new entry
60
+ if not os.path.exists(journal_file):
61
+ with open(journal_file, "w", encoding="utf-8") as f:
 
 
 
 
 
 
 
62
  f.write(new_entry)
63
  else:
 
64
  with open(journal_file, "r", encoding="utf-8") as f:
65
  lines = f.readlines()
66
 
67
  # Remove existing entry if present
68
+ lines_to_remove = set()
69
+ removing_entry = False
70
+ for i, line in enumerate(lines):
71
+ if line.startswith("Date: "):
72
+ if date == line[6:].strip():
73
+ removing_entry = True
74
+ lines_to_remove.add(i)
75
+ else:
76
+ removing_entry = False
77
+
78
+ if removing_entry:
79
+ lines_to_remove.add(i)
80
+
81
+ lines = [line for i, line in enumerate(lines) if i not in lines_to_remove]
82
 
83
+ # Find the correct position for the new entry based on its date
84
+ new_entry_date = parse_date(date)
85
+ position = None
86
+ for i, line in enumerate(lines):
87
+ if line.startswith("Date: "):
88
+ entry_date = parse_date(line[6:].strip())
89
+ if new_entry_date < entry_date:
90
+ position = i
91
+ break
92
+
93
+ # Insert the new entry at the correct position
94
+ if position is None:
95
+ lines.append(new_entry)
96
+ else:
97
+ lines.insert(position, new_entry)
98
+
99
+ # Write the updated journal entries to the file
100
  with open(journal_file, "w", encoding="utf-8") as f:
101
  f.writelines(lines)
102
+
103
+
104
 
105
  st.title("Digital Brain Journal Entry ✍️")
106
  st.write("Write a diary journal entry or edit an existing one by selecting on the date picker.")
 
136
 
137
  st.markdown("---")
138
  st.markdown("")
139
+ st.markdown("<p style='text-align: center'><a href='https://github.com/Kaludii'>Github</a> | <a href='https://huggingface.co/Kaludi'>HuggingFace</a></p>", unsafe_allow_html=True)