Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,11 @@ from agents.analyzer_agent import AnalyzerAgent
|
|
23 |
from agents.content_agent import ContentAgent
|
24 |
|
25 |
class LinkedInEnhancerGradio:
|
26 |
-
"""Gradio
|
|
|
|
|
|
|
|
|
27 |
|
28 |
def __init__(self):
|
29 |
self.orchestrator = ProfileOrchestrator()
|
@@ -348,7 +352,7 @@ class LinkedInEnhancerGradio:
|
|
348 |
def export_results(self, linkedin_url: str) -> str:
|
349 |
"""Export all results to a comprehensive downloadable file"""
|
350 |
if not self.current_profile_data:
|
351 |
-
return
|
352 |
|
353 |
try:
|
354 |
# Create filename with timestamp
|
@@ -356,6 +360,9 @@ class LinkedInEnhancerGradio:
|
|
356 |
timestamp = time.strftime('%Y%m%d_%H%M%S')
|
357 |
filename = f"LinkedIn_Profile_Enhancement_{profile_name}_{timestamp}.md"
|
358 |
|
|
|
|
|
|
|
359 |
# Compile comprehensive report
|
360 |
content = f"""# π LinkedIn Profile Enhancement Report
|
361 |
|
@@ -564,13 +571,14 @@ This comprehensive report provides a detailed analysis of your LinkedIn profile
|
|
564 |
"""
|
565 |
|
566 |
# Save to file (this will be downloaded by the browser)
|
567 |
-
with open(
|
568 |
f.write(content)
|
569 |
|
570 |
-
return
|
571 |
|
572 |
except Exception as e:
|
573 |
-
|
|
|
574 |
|
575 |
def create_gradio_interface():
|
576 |
"""Create and return the Gradio interface"""
|
@@ -704,12 +712,13 @@ def create_gradio_interface():
|
|
704 |
with gr.TabItem("π‘ Enhancement Suggestions"):
|
705 |
suggestions_content = gr.Markdown(label="Enhancement Suggestions")
|
706 |
|
707 |
-
with gr.TabItem("
|
708 |
-
|
|
|
709 |
gr.Markdown("""
|
710 |
-
###
|
711 |
|
712 |
-
|
713 |
|
714 |
#### π **Complete Profile Analysis**
|
715 |
- Basic profile information and current content
|
@@ -738,10 +747,22 @@ def create_gradio_interface():
|
|
738 |
|
739 |
def on_enhance_profile(url, job_desc):
|
740 |
status, basic, about, exp, details, analysis, keywords, suggestions, image = app.enhance_linkedin_profile(url, job_desc)
|
741 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
742 |
|
743 |
-
def
|
744 |
-
|
|
|
|
|
|
|
745 |
|
746 |
# Connect events
|
747 |
test_btn.click(
|
@@ -752,13 +773,13 @@ def create_gradio_interface():
|
|
752 |
enhance_btn.click(
|
753 |
fn=on_enhance_profile,
|
754 |
inputs=[linkedin_url, job_description],
|
755 |
-
outputs=[enhance_status, basic_info, about_section, experience_info, education_skills, analysis_results, keyword_analysis, suggestions_content, profile_image]
|
756 |
)
|
757 |
|
758 |
-
|
759 |
-
fn=
|
760 |
inputs=[linkedin_url],
|
761 |
-
outputs=[
|
762 |
)
|
763 |
|
764 |
# Auto-test connections on load
|
@@ -819,4 +840,4 @@ Web Interface Features:
|
|
819 |
)
|
820 |
|
821 |
if __name__ == "__main__":
|
822 |
-
main()
|
|
|
23 |
from agents.content_agent import ContentAgent
|
24 |
|
25 |
class LinkedInEnhancerGradio:
|
26 |
+
"""Gradio # Action Buttons - Single Enhanced Button
|
27 |
+
with gr.Row():
|
28 |
+
enhance_btn = gr.Button("π Enhance LinkedIn Profile", variant="primary", size="lg") # Action Buttons - Single Enhanced Button with Download
|
29 |
+
with gr.Row():
|
30 |
+
enhance_btn = gr.Button("π Enhance LinkedIn Profile", variant="primary", size="lg")rface for LinkedIn Profile Enhancer"""
|
31 |
|
32 |
def __init__(self):
|
33 |
self.orchestrator = ProfileOrchestrator()
|
|
|
352 |
def export_results(self, linkedin_url: str) -> str:
|
353 |
"""Export all results to a comprehensive downloadable file"""
|
354 |
if not self.current_profile_data:
|
355 |
+
return None # Return None if no data
|
356 |
|
357 |
try:
|
358 |
# Create filename with timestamp
|
|
|
360 |
timestamp = time.strftime('%Y%m%d_%H%M%S')
|
361 |
filename = f"LinkedIn_Profile_Enhancement_{profile_name}_{timestamp}.md"
|
362 |
|
363 |
+
# Create full file path
|
364 |
+
file_path = os.path.join(os.getcwd(), filename)
|
365 |
+
|
366 |
# Compile comprehensive report
|
367 |
content = f"""# π LinkedIn Profile Enhancement Report
|
368 |
|
|
|
571 |
"""
|
572 |
|
573 |
# Save to file (this will be downloaded by the browser)
|
574 |
+
with open(file_path, 'w', encoding='utf-8') as f:
|
575 |
f.write(content)
|
576 |
|
577 |
+
return file_path # Return file path for download
|
578 |
|
579 |
except Exception as e:
|
580 |
+
print(f"Export error: {str(e)}")
|
581 |
+
return None
|
582 |
|
583 |
def create_gradio_interface():
|
584 |
"""Create and return the Gradio interface"""
|
|
|
712 |
with gr.TabItem("π‘ Enhancement Suggestions"):
|
713 |
suggestions_content = gr.Markdown(label="Enhancement Suggestions")
|
714 |
|
715 |
+
with gr.TabItem("οΏ½ Download Report"):
|
716 |
+
download_status = gr.Textbox(label="Download Status", interactive=False)
|
717 |
+
download_btn = gr.DownloadButton("π₯ Download Report", variant="secondary", visible=False)
|
718 |
gr.Markdown("""
|
719 |
+
### οΏ½ **Download Complete Report**
|
720 |
|
721 |
+
After enhancing your profile, click the **Download Report** button to get a comprehensive markdown file containing:
|
722 |
|
723 |
#### π **Complete Profile Analysis**
|
724 |
- Basic profile information and current content
|
|
|
747 |
|
748 |
def on_enhance_profile(url, job_desc):
|
749 |
status, basic, about, exp, details, analysis, keywords, suggestions, image = app.enhance_linkedin_profile(url, job_desc)
|
750 |
+
|
751 |
+
# Show download button if enhancement was successful
|
752 |
+
download_visible = status.startswith("β
")
|
753 |
+
download_message = "β
Profile enhanced! You can now download the report." if download_visible else "β Please enhance profile first to download report."
|
754 |
+
|
755 |
+
return (
|
756 |
+
status, basic, about, exp, details, analysis, keywords, suggestions, image,
|
757 |
+
gr.DownloadButton("π₯ Download Report", variant="secondary", visible=download_visible),
|
758 |
+
download_message
|
759 |
+
)
|
760 |
|
761 |
+
def on_download_report(url):
|
762 |
+
file_path = app.export_results(url)
|
763 |
+
if file_path and os.path.exists(file_path):
|
764 |
+
return file_path
|
765 |
+
return None
|
766 |
|
767 |
# Connect events
|
768 |
test_btn.click(
|
|
|
773 |
enhance_btn.click(
|
774 |
fn=on_enhance_profile,
|
775 |
inputs=[linkedin_url, job_description],
|
776 |
+
outputs=[enhance_status, basic_info, about_section, experience_info, education_skills, analysis_results, keyword_analysis, suggestions_content, profile_image, download_btn, download_status]
|
777 |
)
|
778 |
|
779 |
+
download_btn.click(
|
780 |
+
fn=on_download_report,
|
781 |
inputs=[linkedin_url],
|
782 |
+
outputs=[download_btn]
|
783 |
)
|
784 |
|
785 |
# Auto-test connections on load
|
|
|
840 |
)
|
841 |
|
842 |
if __name__ == "__main__":
|
843 |
+
main()
|