awacke1 commited on
Commit
e45c3f5
โ€ข
1 Parent(s): 0890ebb

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +93 -0
app.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import asyncio
3
+ import threading
4
+ import random
5
+ import matplotlib.pyplot as plt
6
+ import numpy as np
7
+
8
+ # Yoruba gods and their roles
9
+ gods = {
10
+ "Olorun": "Supreme Creator",
11
+ "Obatala": "God of Creation",
12
+ "Eshu": "Trickster God of Crossroads and Fate",
13
+ "Orunmila": "God of Wisdom and Divination",
14
+ "Ikรบ": "God of Death",
15
+ "Shango": "God of Thunder and Lightning",
16
+ "Oshun": "Goddess of Love, Beauty, and Fertility",
17
+ "Ogun": "God of Iron and War"
18
+ }
19
+
20
+ # Story of Olorun and Yoruba gods
21
+ story = """
22
+ In the beginning, there was only Olorun, the supreme creator god, dwelling in the heavens above. ๐ŸŒค๏ธ Olorun, the almighty, decided to create the world and all that exists within it. He summoned Obatala, the god of creation, and tasked him with crafting the earth and all its inhabitants. ๐ŸŒ
23
+
24
+ Obatala descended from the heavens, carrying a snail shell filled with sacred sand, a chameleon, and a pigeon. ๐Ÿš๐ŸฆŽ๐Ÿ•Š๏ธ As he reached the watery void below, Obatala released the sand, and the chameleon stepped upon it, spreading the grains far and wide. Thus, the earth was formed, and the pigeon flew across its expanse, bringing life and vitality to the land. ๐ŸŒฟ
25
+
26
+ With the earth now created, Olorun sent down the other gods to populate and govern various aspects of the world. Among them was Eshu, the trickster god of crossroads and fate. ๐Ÿƒ Eshu, ever mischievous, would often play pranks on both mortals and gods alike, teaching valuable lessons through his cunning ways.
27
+
28
+ Orunmila, the god of wisdom and divination, also descended to guide humanity with his prophetic insights. ๐Ÿ”ฎ He introduced the sacred divination system called Ifa, which allowed mortals to communicate with the gods and seek guidance in their lives.
29
+
30
+ As the world flourished, Olorun watched from above, pleased with his creation. However, darkness crept in as Ikรบ, the god of death, began to claim the lives of mortals. ๐Ÿ’€ Olorun, in his infinite wisdom, knew that life and death were part of the natural cycle, and he allowed Ikรบ to maintain the balance.
31
+
32
+ Shango, the god of thunder and lightning, ruled the skies with his mighty axe. โšก His tempestuous nature mirrored the powerful storms that swept across the land, and mortals both feared and revered him.
33
+
34
+ Oshun, the goddess of love, beauty, and fertility, graced the earth with her presence. ๐Ÿ’› She brought joy, passion, and abundance to the lives of mortals, and her followers celebrated her with vibrant festivities and offerings.
35
+
36
+ Throughout the ages, the Yoruba gods continued to shape the world and guide humanity. They taught valuable lessons, bestowed blessings, and occasionally unleashed their wrath upon those who transgressed against them. ๐ŸŒˆ
37
+
38
+ The Yoruba mythology is a tapestry woven with tales of creation, destiny, and the eternal dance between the gods and mortals. These stories, passed down through generations, continue to inspire and teach the Yoruba people, reminding them of their rich heritage and the interconnectedness of all things in the cosmos. โœจ
39
+ """
40
+
41
+ # Streamlit app
42
+ def main():
43
+ st.title("Yoruba Gods and Mythology")
44
+ st.write(story)
45
+
46
+ st.sidebar.title("Agents")
47
+ agent_count = st.sidebar.slider("Number of Agents", min_value=1, max_value=8, value=8)
48
+
49
+ if st.sidebar.button("Start Agents"):
50
+ with st.spinner("Spawning agents..."):
51
+ agents = []
52
+ for i in range(agent_count):
53
+ agent = threading.Thread(target=agent_function, args=(i,))
54
+ agents.append(agent)
55
+ agent.start()
56
+
57
+ for agent in agents:
58
+ agent.join()
59
+
60
+ st.success("All agents have completed their tasks.")
61
+
62
+ st.sidebar.title("Heartbeat Graph")
63
+ if st.sidebar.button("Update Graph"):
64
+ update_heartbeat_graph()
65
+
66
+ def agent_function(agent_id):
67
+ god_name = list(gods.keys())[agent_id]
68
+ role = gods[god_name]
69
+ st.write(f"Agent {agent_id+1}: {god_name} - {role}")
70
+ asyncio.run(simulate_task(agent_id))
71
+
72
+ async def simulate_task(agent_id):
73
+ progress_bar = st.progress(0)
74
+ for i in range(100):
75
+ progress_bar.progress(i + 1)
76
+ await asyncio.sleep(random.uniform(0.01, 0.1))
77
+
78
+ def update_heartbeat_graph():
79
+ active_threads = threading.active_count() - 1 # Subtract 1 for the main thread
80
+ ip_addresses = [f"192.168.0.{i+1}" for i in range(active_threads)]
81
+
82
+ fig, ax = plt.subplots()
83
+ ax.bar(range(active_threads), [1] * active_threads, color='blue')
84
+ ax.set_xlabel("User")
85
+ ax.set_ylabel("Heartbeat")
86
+ ax.set_title("Active Users")
87
+ ax.set_xticks(range(active_threads))
88
+ ax.set_xticklabels(ip_addresses)
89
+
90
+ st.pyplot(fig)
91
+
92
+ if __name__ == "__main__":
93
+ main()