Spaces:
Build error
Build error
Ronio Jerico Roque commited on
Commit ·
53787bb
1
Parent(s): 444d183
Enhance social media analysis process and add sync button functionality
Browse files- classes/response_social_media.py +20 -19
- helper/sync_button.py +25 -0
- pages/analyzing_page.py +2 -3
classes/response_social_media.py
CHANGED
|
@@ -78,28 +78,29 @@ class SocialMedia:
|
|
| 78 |
return x
|
| 79 |
|
| 80 |
def process(self):
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
-
st.session_state['fb_upload'] = ''
|
| 92 |
-
st.session_state['ig_upload'] = ''
|
| 93 |
-
st.session_state['twitter_upload'] = ''
|
| 94 |
-
st.session_state['youtube_upload'] = ''
|
| 95 |
-
st.session_state['linkedin_upload'] = ''
|
| 96 |
-
st.session_state['tiktok_upload'] = ''
|
| 97 |
-
count = 0
|
| 98 |
-
|
| 99 |
-
except Exception as e:
|
| 100 |
-
pass
|
| 101 |
-
|
| 102 |
def row1(self):
|
|
|
|
| 103 |
self.payload = ""
|
| 104 |
count = 0
|
| 105 |
try:
|
|
|
|
| 78 |
return x
|
| 79 |
|
| 80 |
def process(self):
|
| 81 |
+
with st.spinner('Social Media Analyst...', show_time=True):
|
| 82 |
+
st.write('')
|
| 83 |
+
headers = {"Content-Type": "application/json", "x-api-key": f"{os.getenv('x-api-key')}"}
|
| 84 |
+
try:
|
| 85 |
+
payload_txt = {"input_value": self.payload, "output_type": "text", "input_type": "chat"}
|
| 86 |
+
payload_txt_model = self.request_model(payload_txt, headers)
|
| 87 |
+
debug_info = {'data_field' : 'Social Media Analyst', 'result': payload_txt_model}
|
| 88 |
+
upload_response(debug_info)
|
| 89 |
|
| 90 |
+
st.session_state['fb_upload'] = ''
|
| 91 |
+
st.session_state['ig_upload'] = ''
|
| 92 |
+
st.session_state['twitter_upload'] = ''
|
| 93 |
+
st.session_state['youtube_upload'] = ''
|
| 94 |
+
st.session_state['linkedin_upload'] = ''
|
| 95 |
+
st.session_state['tiktok_upload'] = ''
|
| 96 |
+
count = 0
|
| 97 |
+
|
| 98 |
+
except Exception as e:
|
| 99 |
+
pass
|
| 100 |
+
st.session_state['analyzing'] = False
|
| 101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
def row1(self):
|
| 103 |
+
st.session_state['analyzing'] = False
|
| 104 |
self.payload = ""
|
| 105 |
count = 0
|
| 106 |
try:
|
helper/sync_button.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
def hide_sync_button():
|
| 4 |
+
st.markdown(
|
| 5 |
+
"""
|
| 6 |
+
<style>
|
| 7 |
+
.element-container:nth-of-type(1) button {
|
| 8 |
+
display: none;
|
| 9 |
+
}
|
| 10 |
+
</style>
|
| 11 |
+
""",
|
| 12 |
+
unsafe_allow_html=True,
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
def unhide_sync_button():
|
| 16 |
+
st.markdown(
|
| 17 |
+
"""
|
| 18 |
+
<style>
|
| 19 |
+
element-container:nth-of-type(1) button {
|
| 20 |
+
display: inline;
|
| 21 |
+
}
|
| 22 |
+
</style>
|
| 23 |
+
""",
|
| 24 |
+
unsafe_allow_html=True,
|
| 25 |
+
)
|
pages/analyzing_page.py
CHANGED
|
@@ -92,13 +92,12 @@ def run_analysis():
|
|
| 92 |
on_page_thread.join()
|
| 93 |
website_and_tools_thread.join()
|
| 94 |
seo_thread.join()
|
|
|
|
|
|
|
| 95 |
st.success("🎉 All analyses completed!") # Final success message
|
| 96 |
# --- Display Button After Completion ---
|
| 97 |
if st.button("View Results"):
|
| 98 |
st.switch_page("pages/output.py")
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
|
| 103 |
|
| 104 |
# Execute the analysis
|
|
|
|
| 92 |
on_page_thread.join()
|
| 93 |
website_and_tools_thread.join()
|
| 94 |
seo_thread.join()
|
| 95 |
+
social_media_thread.join()
|
| 96 |
+
|
| 97 |
st.success("🎉 All analyses completed!") # Final success message
|
| 98 |
# --- Display Button After Completion ---
|
| 99 |
if st.button("View Results"):
|
| 100 |
st.switch_page("pages/output.py")
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
|
| 103 |
# Execute the analysis
|