awacke1 commited on
Commit
aed8530
Β·
1 Parent(s): 0355ba0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +113 -0
app.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from graphviz import Digraph
3
+ import json
4
+ import os
5
+ import pandas as pd
6
+
7
+ def create_amygdala_hijacking_graph():
8
+ g = Digraph('Amygdala_Hijacking', format='png')
9
+ g.attr(fontname="Helvetica,Arial,sans-serif")
10
+ g.attr('node', fontname="Helvetica,Arial,sans-serif")
11
+ g.attr('edge', fontname="Helvetica,Arial,sans-serif")
12
+ g.attr('graph', newrank='true', nodesep='0.3', ranksep='0.2', overlap='true', splines='false')
13
+ g.attr('node', fixedsize='false', fontsize='24', height='1', shape='box', style='filled,setlinewidth(5)', width='2.2', penwidth='3')
14
+ g.attr('edge', arrowhead='none', arrowsize='0.5', labelfontname="Ubuntu", weight='10', style='filled,setlinewidth(5)')
15
+
16
+ g.node('1', 'πŸ‘‚ Sensory Input', fillcolor='lightblue')
17
+ g.node('2', 'πŸ“‘ Thalamus', fillcolor='palegreen')
18
+ g.node('3', 'πŸ”΄ Amygdala', color='red', fillcolor='red', fontcolor='white')
19
+ g.node('4', 'πŸ“š Hippocampus', fillcolor='lightyellow')
20
+ g.node('5', 'πŸ’‘ Prefrontal Cortex', fillcolor='lightpink')
21
+ g.node('6', '🎬 Response', fillcolor='lightgray')
22
+
23
+ g.edge('1', '2', label='🌐 Receives Signals')
24
+ g.edge('2', '3', label='⚑ Quick, Emotional Response')
25
+ g.edge('2', '4', label='πŸ”€ Sends Signals To')
26
+ g.edge('4', '5', label='πŸ”„ Relays Information')
27
+ g.edge('5', '3', label='🧠 Rational Control (If Not Hijacked)')
28
+ g.edge('3', '6', label='πŸƒ Generates Response')
29
+
30
+ return g
31
+
32
+ def display_graph():
33
+ st.title("Amygdala Hijacking Visualization")
34
+ amygdala_hijacking_graph = create_amygdala_hijacking_graph()
35
+ st.graphviz_chart(amygdala_hijacking_graph)
36
+
37
+ def display_table():
38
+ st.title("Fun Questions Table")
39
+
40
+ data = [
41
+ (1, "πŸ˜‚", "How many cups of coffee do you need to function like a normal human being?", "[Wikipedia](https://en.wikipedia.org/wiki/Coffee)"),
42
+ (2, "πŸ€”", "If animals could talk, which species do you think would be the most annoying?", "[Wikipedia](https://en.wikipedia.org/wiki/Animal_communication)"),
43
+ (3, "🀫", "What's the craziest conspiracy theory you've ever heard?", "[Wikipedia](https://en.wikipedia.org/wiki/Conspiracy_theory)"),
44
+ (4, "🀣", "What's the worst pickup line you've ever heard or used?", "[Wikipedia](https://en.wikipedia.org/wiki/Pick-up_line)"),
45
+ (5, "😜", "If you were a superhero, what would your superpower be?", "[Wikipedia](https://en.wikipedia.org/wiki/Superpower_(ability))"),
46
+ (6, "🀯", "If you could time travel, what period in history would you go to and why?", "[Wikipedia](https://en.wikipedia.org/wiki/Time_travel)"),
47
+ (7, "😝", "What's the weirdest thing you've ever eaten?", "[Wikipedia](https://en.wikipedia.org/wiki/List_of_delicacies)"),
48
+ (8, "πŸ€ͺ", "What's the most embarrassing thing that's ever happened to you in public?", "[Wikipedia](https://en.wikipedia.org/wiki/Embarrassment)"),
49
+ (9, "😈", "If you could be any movie villain, who would you choose and why?", "[Wikipedia](https://en.wikipedia.org/wiki/Villain)"),
50
+ (10, "πŸ™ƒ", "What's the most useless talent you have?", "[Wikipedia](https://en.wikipedia.org/wiki/Talent_(human))"),
51
+ ]
52
+
53
+ df=pd.DataFrame(data, columns=['Question', 'Emoji', 'Title', 'Description'])
54
+
55
+ st.table(df) # simplest dataframe view
56
+
57
+ #edited_df = st.data_editor(df) # robust df editor
58
+ #favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
59
+ #st.markdown(f"Your favorite command is **{favorite_command}** 🎈")
60
+
61
+ def update_vote_log(term, vote_type):
62
+ with open('vote.log.txt', 'a') as f:
63
+ f.write(json.dumps({'term': term, 'vote': vote_type}) + '\n')
64
+
65
+ def load_vote_log():
66
+ vote_data = []
67
+
68
+ if os.path.exists('vote.log.txt'):
69
+ with open('vote.log.txt', 'r') as f:
70
+ for line in f.readlines():
71
+ vote_data.append(json.loads(line.strip()))
72
+
73
+ return vote_data
74
+
75
+ def count_votes(vote_data, term):
76
+ upvotes = sum(1 for vote in vote_data if vote['term'] == term and vote['vote'] == 'upvote')
77
+ downvotes = sum(1 for vote in vote_data if vote['term'] == term and vote['vote'] == 'downvote')
78
+ return upvotes, downvotes
79
+
80
+ def main():
81
+ display_graph()
82
+ display_table()
83
+
84
+ terms = [
85
+ 'πŸ‘‚ Sensory Input',
86
+ 'πŸ“‘ Thalamus',
87
+ 'πŸ”΄ Amygdala',
88
+ 'πŸ“š Hippocampus',
89
+ 'πŸ’‘ Prefrontal Cortex',
90
+ '🎬 Response'
91
+ ]
92
+
93
+ vote_data = load_vote_log()
94
+
95
+ for term in terms:
96
+ st.write(term)
97
+ upvotes, downvotes = count_votes(vote_data, term)
98
+ st.write(f"Total upvotes: {upvotes}")
99
+ st.write(f"Total downvotes: {downvotes}")
100
+
101
+ upvote_button = st.button(f"πŸ‘ Upvote {term}")
102
+ downvote_button = st.button(f"πŸ‘Ž Downvote {term}")
103
+
104
+ if upvote_button:
105
+ update_vote_log(term, 'upvote')
106
+ st.experimental_rerun()
107
+
108
+ if downvote_button:
109
+ update_vote_log(term, 'downvote')
110
+ st.experimental_rerun()
111
+
112
+ if __name__ == "__main__":
113
+ main()