Update pages/linkedin_extractor.py
Browse files- pages/linkedin_extractor.py +10 -12
pages/linkedin_extractor.py
CHANGED
|
@@ -102,7 +102,8 @@ This appears to be a professional developer/engineer who:
|
|
| 102 |
- Works on projects like University Information systems and LinkedIn data analysis"""
|
| 103 |
|
| 104 |
else:
|
| 105 |
-
|
|
|
|
| 106 |
|
| 107 |
I've analyzed this LinkedIn post for you.
|
| 108 |
|
|
@@ -117,6 +118,8 @@ This appears to be a post where the author is sharing their GitHub profile and s
|
|
| 117 |
- "Tell me about the GitHub profile"
|
| 118 |
- "What is the main purpose of this post?"
|
| 119 |
- "What skills does the author have?""""
|
|
|
|
|
|
|
| 120 |
|
| 121 |
except Exception as e:
|
| 122 |
return f"β Analysis error: {str(e)}"
|
|
@@ -208,7 +211,7 @@ def display_metrics(extracted_data):
|
|
| 208 |
def main():
|
| 209 |
st.title("πΌ LinkedIn AI Analyzer")
|
| 210 |
|
| 211 |
-
# Initialize session state
|
| 212 |
if "extracted_data" not in st.session_state:
|
| 213 |
st.session_state.extracted_data = None
|
| 214 |
if "chat_history" not in st.session_state:
|
|
@@ -267,8 +270,8 @@ def main():
|
|
| 267 |
if extracted_data.get("status") == "success":
|
| 268 |
st.session_state.extracted_data = extracted_data
|
| 269 |
st.session_state.current_url = url_to_use
|
| 270 |
-
st.session_state.chat_history = []
|
| 271 |
-
st.session_state.last_user_input = ""
|
| 272 |
st.success("β
Data extracted successfully!")
|
| 273 |
st.balloons()
|
| 274 |
else:
|
|
@@ -347,7 +350,7 @@ def main():
|
|
| 347 |
if has_data:
|
| 348 |
st.success("π¬ Chat ready! Ask questions about the LinkedIn data below.")
|
| 349 |
|
| 350 |
-
# Display chat history
|
| 351 |
for chat in st.session_state.chat_history:
|
| 352 |
if chat["role"] == "user":
|
| 353 |
with st.chat_message("user"):
|
|
@@ -372,26 +375,21 @@ def main():
|
|
| 372 |
if st.button(suggestion, key=f"sugg_{i}", use_container_width=True):
|
| 373 |
st.info(f"π‘ Type: '{suggestion}' in the chat below")
|
| 374 |
|
| 375 |
-
# CHAT INPUT
|
| 376 |
if has_data:
|
| 377 |
user_input = st.chat_input("Type your question about the LinkedIn data here...")
|
| 378 |
|
| 379 |
if user_input and user_input != st.session_state.last_user_input:
|
| 380 |
-
# Store the current input to prevent duplication
|
| 381 |
st.session_state.last_user_input = user_input
|
| 382 |
-
|
| 383 |
-
# Add user message
|
| 384 |
st.session_state.chat_history.append({"role": "user", "content": user_input})
|
| 385 |
|
| 386 |
-
# Generate and add AI response
|
| 387 |
with st.spinner("π€ Analyzing..."):
|
| 388 |
response = enhanced_chat_analysis(user_input, st.session_state.extracted_data)
|
| 389 |
st.session_state.chat_history.append({"role": "assistant", "content": response})
|
| 390 |
|
| 391 |
-
# Force rerun to show updated chat
|
| 392 |
st.rerun()
|
| 393 |
|
| 394 |
-
# Features section
|
| 395 |
st.markdown("---")
|
| 396 |
st.markdown("### π Features")
|
| 397 |
|
|
|
|
| 102 |
- Works on projects like University Information systems and LinkedIn data analysis"""
|
| 103 |
|
| 104 |
else:
|
| 105 |
+
# FIXED: Properly formatted string without syntax errors
|
| 106 |
+
response_text = f"""**π€ Analysis Response:**
|
| 107 |
|
| 108 |
I've analyzed this LinkedIn post for you.
|
| 109 |
|
|
|
|
| 118 |
- "Tell me about the GitHub profile"
|
| 119 |
- "What is the main purpose of this post?"
|
| 120 |
- "What skills does the author have?""""
|
| 121 |
+
|
| 122 |
+
return response_text
|
| 123 |
|
| 124 |
except Exception as e:
|
| 125 |
return f"β Analysis error: {str(e)}"
|
|
|
|
| 211 |
def main():
|
| 212 |
st.title("πΌ LinkedIn AI Analyzer")
|
| 213 |
|
| 214 |
+
# Initialize session state
|
| 215 |
if "extracted_data" not in st.session_state:
|
| 216 |
st.session_state.extracted_data = None
|
| 217 |
if "chat_history" not in st.session_state:
|
|
|
|
| 270 |
if extracted_data.get("status") == "success":
|
| 271 |
st.session_state.extracted_data = extracted_data
|
| 272 |
st.session_state.current_url = url_to_use
|
| 273 |
+
st.session_state.chat_history = []
|
| 274 |
+
st.session_state.last_user_input = ""
|
| 275 |
st.success("β
Data extracted successfully!")
|
| 276 |
st.balloons()
|
| 277 |
else:
|
|
|
|
| 350 |
if has_data:
|
| 351 |
st.success("π¬ Chat ready! Ask questions about the LinkedIn data below.")
|
| 352 |
|
| 353 |
+
# Display chat history
|
| 354 |
for chat in st.session_state.chat_history:
|
| 355 |
if chat["role"] == "user":
|
| 356 |
with st.chat_message("user"):
|
|
|
|
| 375 |
if st.button(suggestion, key=f"sugg_{i}", use_container_width=True):
|
| 376 |
st.info(f"π‘ Type: '{suggestion}' in the chat below")
|
| 377 |
|
| 378 |
+
# CHAT INPUT
|
| 379 |
if has_data:
|
| 380 |
user_input = st.chat_input("Type your question about the LinkedIn data here...")
|
| 381 |
|
| 382 |
if user_input and user_input != st.session_state.last_user_input:
|
|
|
|
| 383 |
st.session_state.last_user_input = user_input
|
|
|
|
|
|
|
| 384 |
st.session_state.chat_history.append({"role": "user", "content": user_input})
|
| 385 |
|
|
|
|
| 386 |
with st.spinner("π€ Analyzing..."):
|
| 387 |
response = enhanced_chat_analysis(user_input, st.session_state.extracted_data)
|
| 388 |
st.session_state.chat_history.append({"role": "assistant", "content": response})
|
| 389 |
|
|
|
|
| 390 |
st.rerun()
|
| 391 |
|
| 392 |
+
# Features section
|
| 393 |
st.markdown("---")
|
| 394 |
st.markdown("### π Features")
|
| 395 |
|