Update app.py
Browse files
app.py
CHANGED
@@ -47,7 +47,7 @@ def add_fact(sem_mem, fact, category, source):
|
|
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")
|
53 |
source = st.text_input("Enter a source")
|
@@ -57,7 +57,7 @@ def add_fact_to_semantic_memory(sem_mem):
|
|
57 |
st.success("Fact added to semantic memory!")
|
58 |
st.sidebar.success("Fact added to semantic memory!")
|
59 |
|
60 |
-
def add_event_to_episodic_memory(epi_mem):
|
61 |
event = st.text_input("Enter an event")
|
62 |
sentiment = st.selectbox("Select a sentiment", ["happy", "sad", "neutral"])
|
63 |
date = st.date_input("Select a date")
|
@@ -80,9 +80,9 @@ def run_app():
|
|
80 |
elif option == "View Episodic Memory":
|
81 |
view_episodic_memory(epi_mem)
|
82 |
elif option == "Add Fact to Semantic Memory":
|
83 |
-
add_fact_to_semantic_memory(sem_mem)
|
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 |
|
@@ -90,6 +90,8 @@ 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 |
|
|
|
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, epi_mem):
|
51 |
fact = st.text_input("Enter a fact")
|
52 |
category = st.text_input("Enter a category")
|
53 |
source = st.text_input("Enter a source")
|
|
|
57 |
st.success("Fact added to semantic memory!")
|
58 |
st.sidebar.success("Fact added to semantic memory!")
|
59 |
|
60 |
+
def add_event_to_episodic_memory(epi_mem, sem_mem):
|
61 |
event = st.text_input("Enter an event")
|
62 |
sentiment = st.selectbox("Select a sentiment", ["happy", "sad", "neutral"])
|
63 |
date = st.date_input("Select a date")
|
|
|
80 |
elif option == "View Episodic Memory":
|
81 |
view_episodic_memory(epi_mem)
|
82 |
elif option == "Add Fact to Semantic Memory":
|
83 |
+
add_fact_to_semantic_memory(sem_mem, epi_mem)
|
84 |
elif option == "Add Event to Episodic Memory":
|
85 |
+
add_event_to_episodic_memory(epi_mem, sem_mem)
|
86 |
|
87 |
save_data(sem_mem, epi_mem)
|
88 |
|
|
|
90 |
run_app()
|
91 |
|
92 |
|
93 |
+
|
94 |
+
|
95 |
# AW: Restructure the code listing into four functions. shorten the code by eliminating comments and unnecessary whitespace and empty lines.
|
96 |
# 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.
|
97 |
|