Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,6 +6,42 @@ import pandas as pd
|
|
6 |
import plotly.graph_objects as go
|
7 |
import time
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Function to call the Together AI model
|
10 |
def call_ai_model(all_message):
|
11 |
url = "https://api.together.xyz/v1/chat/completions"
|
@@ -36,17 +72,22 @@ def call_ai_model(all_message):
|
|
36 |
return response
|
37 |
|
38 |
# Streamlit app layout
|
39 |
-
st.
|
40 |
-
st.
|
41 |
|
42 |
-
#
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
45 |
|
46 |
-
|
47 |
-
region = st.text_input("Enter region in Kenya:")
|
48 |
-
gender_focus = st.multiselect("Select gender focus:", ["Male", "Female", "Non-binary", "All"])
|
|
|
49 |
|
|
|
50 |
if st.button("Generate Analysis"):
|
51 |
all_message = (
|
52 |
f"Analyze the impact of digital technologies on kinship and gender dynamics in Kenya. "
|
@@ -97,8 +138,10 @@ if st.button("Generate Analysis"):
|
|
97 |
|
98 |
st.success("Analysis completed!")
|
99 |
# Display analysis
|
|
|
100 |
st.subheader("Digital Technologies Impact Analysis in Kenya")
|
101 |
st.markdown(analysis_text.strip())
|
|
|
102 |
|
103 |
# Prepare data for visualization
|
104 |
results_data = {
|
@@ -108,10 +151,13 @@ if st.button("Generate Analysis"):
|
|
108 |
results_df = pd.DataFrame(results_data)
|
109 |
|
110 |
# Display results in a table
|
|
|
111 |
st.subheader("Digital Technologies Summary")
|
112 |
st.table(results_df)
|
|
|
113 |
|
114 |
# Create a radar chart for digital technology impacts
|
|
|
115 |
fig = go.Figure(data=go.Scatterpolar(
|
116 |
r=[len(digital_technologies), len(issues)],
|
117 |
theta=["Digital Technologies", "Issues of Concern"],
|
@@ -124,10 +170,13 @@ if st.button("Generate Analysis"):
|
|
124 |
showlegend=False
|
125 |
)
|
126 |
st.plotly_chart(fig)
|
|
|
127 |
|
128 |
# Display raw analysis result for debugging
|
|
|
129 |
with st.expander("Show Raw Analysis"):
|
130 |
st.text(analysis_text)
|
|
|
131 |
|
132 |
except ValueError as ve:
|
133 |
st.error(f"Configuration error: {ve}")
|
@@ -135,3 +184,6 @@ if st.button("Generate Analysis"):
|
|
135 |
st.error(f"Request error: {re}")
|
136 |
except Exception as e:
|
137 |
st.error(f"An unexpected error occurred: {e}")
|
|
|
|
|
|
|
|
6 |
import plotly.graph_objects as go
|
7 |
import time
|
8 |
|
9 |
+
# Custom CSS for styling
|
10 |
+
st.markdown("""
|
11 |
+
<style>
|
12 |
+
.stApp {
|
13 |
+
background: #f5f5f5;
|
14 |
+
}
|
15 |
+
.header {
|
16 |
+
font-size: 36px;
|
17 |
+
font-weight: bold;
|
18 |
+
color: #4CAF50;
|
19 |
+
text-align: center;
|
20 |
+
margin-bottom: 20px;
|
21 |
+
}
|
22 |
+
.subheader {
|
23 |
+
font-size: 24px;
|
24 |
+
font-weight: bold;
|
25 |
+
color: #4CAF50;
|
26 |
+
text-align: center;
|
27 |
+
margin-bottom: 20px;
|
28 |
+
}
|
29 |
+
.section {
|
30 |
+
background: white;
|
31 |
+
padding: 20px;
|
32 |
+
border-radius: 10px;
|
33 |
+
box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);
|
34 |
+
margin-bottom: 20px;
|
35 |
+
}
|
36 |
+
.footer {
|
37 |
+
text-align: center;
|
38 |
+
font-size: 14px;
|
39 |
+
color: #777;
|
40 |
+
margin-top: 20px;
|
41 |
+
}
|
42 |
+
</style>
|
43 |
+
""", unsafe_allow_html=True)
|
44 |
+
|
45 |
# Function to call the Together AI model
|
46 |
def call_ai_model(all_message):
|
47 |
url = "https://api.together.xyz/v1/chat/completions"
|
|
|
72 |
return response
|
73 |
|
74 |
# Streamlit app layout
|
75 |
+
st.markdown('<div class="header">Digital Technologies, Kinship, and Gender in Kenya</div>', unsafe_allow_html=True)
|
76 |
+
st.markdown('<div class="subheader">Analyze and visualize the impact of digital technologies on kinship and gender dynamics in Kenya.</div>', unsafe_allow_html=True)
|
77 |
|
78 |
+
# Input section
|
79 |
+
with st.container():
|
80 |
+
st.markdown('<div class="section">', unsafe_allow_html=True)
|
81 |
+
st.subheader("Digital Technology Impacts")
|
82 |
+
digital_technologies = st.multiselect("Select digital technologies:", ["Big Data Analytics", "Biometric Authentication", "Blockchain", "E-commerce", "Social Media Platforms"])
|
83 |
+
issues = st.multiselect("Select issues of concern:", ["Trust", "Mistrust", "Data Privacy", "Fraud", "Social Classification"])
|
84 |
|
85 |
+
st.subheader("Kenya-Specific Inputs")
|
86 |
+
region = st.text_input("Enter region in Kenya:")
|
87 |
+
gender_focus = st.multiselect("Select gender focus:", ["Male", "Female", "Non-binary", "All"])
|
88 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
89 |
|
90 |
+
# Button to generate analysis
|
91 |
if st.button("Generate Analysis"):
|
92 |
all_message = (
|
93 |
f"Analyze the impact of digital technologies on kinship and gender dynamics in Kenya. "
|
|
|
138 |
|
139 |
st.success("Analysis completed!")
|
140 |
# Display analysis
|
141 |
+
st.markdown('<div class="section">', unsafe_allow_html=True)
|
142 |
st.subheader("Digital Technologies Impact Analysis in Kenya")
|
143 |
st.markdown(analysis_text.strip())
|
144 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
145 |
|
146 |
# Prepare data for visualization
|
147 |
results_data = {
|
|
|
151 |
results_df = pd.DataFrame(results_data)
|
152 |
|
153 |
# Display results in a table
|
154 |
+
st.markdown('<div class="section">', unsafe_allow_html=True)
|
155 |
st.subheader("Digital Technologies Summary")
|
156 |
st.table(results_df)
|
157 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
158 |
|
159 |
# Create a radar chart for digital technology impacts
|
160 |
+
st.markdown('<div class="section">', unsafe_allow_html=True)
|
161 |
fig = go.Figure(data=go.Scatterpolar(
|
162 |
r=[len(digital_technologies), len(issues)],
|
163 |
theta=["Digital Technologies", "Issues of Concern"],
|
|
|
170 |
showlegend=False
|
171 |
)
|
172 |
st.plotly_chart(fig)
|
173 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
174 |
|
175 |
# Display raw analysis result for debugging
|
176 |
+
st.markdown('<div class="section">', unsafe_allow_html=True)
|
177 |
with st.expander("Show Raw Analysis"):
|
178 |
st.text(analysis_text)
|
179 |
+
st.markdown('</div>', unsafe_allow_html=True)
|
180 |
|
181 |
except ValueError as ve:
|
182 |
st.error(f"Configuration error: {ve}")
|
|
|
184 |
st.error(f"Request error: {re}")
|
185 |
except Exception as e:
|
186 |
st.error(f"An unexpected error occurred: {e}")
|
187 |
+
|
188 |
+
# Footer
|
189 |
+
st.markdown('<div class="footer">Powered by Together AI and Streamlit</div>', unsafe_allow_html=True)
|