Update app.py
Browse files
app.py
CHANGED
@@ -41,6 +41,12 @@ def view_episodic_memory(epi_mem):
|
|
41 |
for item in epi_mem:
|
42 |
st.write(f"**{item['event']}** ({item['sentiment']}) - {item['date']}")
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
def add_fact_to_semantic_memory(sem_mem):
|
45 |
fact = st.text_input("Enter a fact")
|
46 |
category = st.text_input("Enter a category")
|
@@ -78,9 +84,12 @@ def run_app():
|
|
78 |
elif option == "Add Event to Episodic Memory":
|
79 |
add_event_to_episodic_memory(epi_mem)
|
80 |
|
|
|
|
|
81 |
if __name__ == '__main__':
|
82 |
run_app()
|
83 |
|
|
|
84 |
# AW: Restructure the code listing into four functions. shorten the code by eliminating comments and unnecessary whitespace and empty lines.
|
85 |
# AI: This revised code splits the app into four functions: load_data, save_data, add_fact, and add_event. The run_app function handles the logic of the Streamlit app and calls these other functions as necessary. The code has been shortened by removing unnecessary whitespace and comments, but retains its functionality.
|
86 |
|
|
|
41 |
for item in epi_mem:
|
42 |
st.write(f"**{item['event']}** ({item['sentiment']}) - {item['date']}")
|
43 |
|
44 |
+
def add_fact(sem_mem, fact, category, source):
|
45 |
+
sem_mem.append({"fact": fact, "category": category, "source": source})
|
46 |
+
|
47 |
+
def add_event(epi_mem, event, sentiment, date):
|
48 |
+
epi_mem.append({"event": event, "sentiment": sentiment, "date": date})
|
49 |
+
|
50 |
def add_fact_to_semantic_memory(sem_mem):
|
51 |
fact = st.text_input("Enter a fact")
|
52 |
category = st.text_input("Enter a category")
|
|
|
84 |
elif option == "Add Event to Episodic Memory":
|
85 |
add_event_to_episodic_memory(epi_mem)
|
86 |
|
87 |
+
save_data(sem_mem, epi_mem)
|
88 |
+
|
89 |
if __name__ == '__main__':
|
90 |
run_app()
|
91 |
|
92 |
+
|
93 |
# AW: Restructure the code listing into four functions. shorten the code by eliminating comments and unnecessary whitespace and empty lines.
|
94 |
# AI: This revised code splits the app into four functions: load_data, save_data, add_fact, and add_event. The run_app function handles the logic of the Streamlit app and calls these other functions as necessary. The code has been shortened by removing unnecessary whitespace and comments, but retains its functionality.
|
95 |
|