CoolFace
Apppublic

awacke1/Memory-Streamlit

sourceHugging Facemitupdated 3y agoView on Hugging Face
1likes
app.py88 linesDownload Raw Back to root
1# This streamlit demonstration is meant to simulate two types of memory within cognitive architecture:2# Each time we remember a moment, we construct it anew.3# We use the building blocks of Episodic Memory which is recall of feelings of being somewhere.4# We also use Semantic Memory which is concrete knowledge about our world and about our personal history.5# With Episodic Memory, its purpose is to provide us with coherence connecting events.  In Episodic Memory, accuracy is less important than consistency.6# In order to have a strong sense of self, it is important that our memories fit with our beliefs and feelings about ourselves.7 8import time9import re10import pandas as pd11import numpy as np12import torch13import torch.nn.functional as F14from transformers import AutoTokenizer, AutoModel15from tokenizers import Tokenizer, AddedToken16import streamlit as st17from st_click_detector import click_detector18 19 20# Initialization21if 'key' not in st.session_state:22    st.session_state['key'] = 'value'23 24# Session State also supports attribute based syntax25if 'key' not in st.session_state:26    st.session_state.key = 'value'27    28# Read29st.write(st.session_state.key)30 31# Outputs: value32 33st.session_state.key = 'value2'     # Attribute API34st.session_state['key'] = 'value2'  # Dictionary like API35 36st.write(st.session_state)37 38# With magic:39st.session_state40 41 42#st.write(st.session_state['value'])43# Throws an exception!44 45# Delete a single key-value pair46#del st.session_state[key]47 48# Delete all the items in Session state49for key in st.session_state.keys():50    del st.session_state[key]51    52 53st.text_input("Your name", key="name")54 55# This exists now:56st.session_state.name57 58def form_callback():59    st.write(st.session_state.my_slider)60    st.write(st.session_state.my_checkbox)61 62with st.form(key='my_form'):63    slider_input = st.slider('My slider', 0, 10, 5, key='my_slider')64    checkbox_input = st.checkbox('Yes or No', key='my_checkbox')65    submit_button = st.form_submit_button(label='Submit', on_click=form_callback)66    67slider = st.slider(68    label='My Slider', min_value=1,69    max_value=10, value=5, key='my_slider')70 71#st.session_state.my_slider = 772 73# Throws an exception!74 75#st.session_state.my_slider = 776 77slider = st.slider(78    label='Choose a Value', min_value=1,79    max_value=10, value=5, key='my_slider')80    81if 'my_button' not in st.session_state:82    st.session_state.my_button = True83 84#st.button('My button', key='my_button')85 86# Throws an exception!87 88