Spaces:
Runtime error
Runtime error
import streamlit as st | |
from graphviz import Digraph | |
import json | |
import os | |
def create_amygdala_hijacking_graph(): | |
# ... (same as before) ... | |
def load_votes(): | |
if os.path.exists('votes.json'): | |
with open('votes.json', 'r') as f: | |
return json.load(f) | |
else: | |
return {'upvotes': {}, 'downvotes': {}} | |
def save_votes(votes): | |
with open('votes.json', 'w') as f: | |
json.dump(votes, f) | |
def display_votes(): | |
votes = load_votes() | |
st.write("Upvotes:") | |
for term, count in votes['upvotes'].items(): | |
st.write(f"{term}: {count}") | |
st.write("Downvotes:") | |
for term, count in votes['downvotes'].items(): | |
st.write(f"{term}: {count}") | |
def main(): | |
st.title("Amygdala Hijacking Visualization") | |
st.text("A simple graph model to represent amygdala hijacking in the brain.") | |
amygdala_hijacking_graph = create_amygdala_hijacking_graph() | |
st.graphviz_chart(amygdala_hijacking_graph) | |
terms = [ | |
'π Sensory Input', | |
'π‘ Thalamus', | |
'π΄ Amygdala', | |
'π Hippocampus', | |
'π‘ Prefrontal Cortex', | |
'π¬ Response' | |
] | |
for term in terms: | |
st.write(term) | |
upvote_button = st.button(f"π Upvote {term}") | |
downvote_button = st.button(f"π Downvote {term}") | |
if upvote_button or downvote_button: | |
votes = load_votes() | |
if upvote_button: | |
if term not in votes['upvotes']: | |
votes['upvotes'][term] = 0 | |
votes['upvotes'][term] += 1 | |
elif downvote_button: | |
if term not in votes['downvotes']: | |
votes['downvotes'][term] = 0 | |
votes['downvotes'][term] += 1 | |
save_votes(votes) | |
display_votes() | |
if __name__ == "__main__": | |
main() | |
st.markdown(""" | |
Explain amygdala hijacking using a graph model in streamlit python program using graphviz to represent levels or modes of thinking | |
Amygdala hijacking is a phenomenon where our emotional brain (amygdala) takes control over our rational brain (prefrontal cortex), leading to impulsive and irrational behavior. In this response, I'll guide you on how to create a Streamlit app with Graphviz to visualize the concept of amygdala hijacking using a graph model. | |
""") | |