File size: 5,085 Bytes
5bf1f45
 
 
57f3b57
dce75da
57f3b57
5bf1f45
 
9347485
 
 
 
 
 
819725d
 
9347485
 
819725d
9347485
a81ee09
9347485
 
 
 
 
 
 
819725d
9347485
 
 
 
 
819725d
9347485
 
 
 
 
 
819725d
 
 
 
 
 
 
9347485
 
 
 
 
 
 
 
 
 
 
819725d
9347485
 
 
 
819725d
9347485
 
 
 
 
819725d
 
 
 
 
 
 
 
 
9347485
 
 
 
 
819725d
 
9347485
 
 
819725d
9347485
 
 
 
819725d
9347485
819725d
9347485
819725d
 
 
9347485
 
 
819725d
9347485
 
 
 
 
819725d
9347485
 
 
819725d
9347485
 
 
 
 
 
 
 
819725d
9347485
 
 
819725d
9347485
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131

import os

# Running the 'ls' command using Python's os module to list files in the current directory
print(os.listdir('/home/user/app'))



import gradio as gr
import nest_asyncio

# Apply nest_asyncio to allow nested event loops
nest_asyncio.apply()

from vsp.app.main import VspDataEnrichment

# Import your custom modules
from vsp.app.scrapers.linkedin_downloader import LinkedinDownloader



async def process_profile(profile_linkedin):
    downloader = LinkedinDownloader()
    enricher = VspDataEnrichment()
    profile = await downloader.fetch_linkedin_data(linkedin_url=profile_linkedin)
    enriched_profile = await enricher.process_linkedin_profile(profile=profile)
    return enriched_profile


async def analyze_profile(profile_linkedin):
    enriched_profile = await process_profile(profile_linkedin)
    # Generate output from enriched_profile
    education_outputs = []
    work_experience_outputs = []

    # Process classified educations
    for idx, edu in enumerate(enriched_profile.classified_educations, 1):
        school = edu.education.school_name
        degree = edu.education.degree
        year = edu.education.end.year if edu.education.end else "N/A"
        classification = edu.classification.output.value
        education_outputs.append(
            f"### Education {idx}\n"
            f"**School:** {school}\n\n"
            f"**Degree:** {degree}\n\n"
            f"**Year:** {year}\n\n"
            f"**Classification:** {classification}\n"
        )

    # Add total years of full-time work experience
    total_experience_years = enriched_profile.full_time_work_experience_years
    experience_by_secondary = enriched_profile.full_time_work_experience_by_secondary

    experience_output = f"### Total Full-Time Work Experience: {total_experience_years} years\n\n"

    if experience_by_secondary:
        experience_output += "### Work Experience by Secondary Job Type:\n"
        for secondary_job_type, years in experience_by_secondary.items():
            experience_output += f"- {secondary_job_type.value}: {years} years\n"

    # Process classified work experiences
    for idx, exp in enumerate(enriched_profile.classified_work_experiences, 1):
        company = exp.position.company_name
        start_year = exp.position.start.year if exp.position.start else "N/A"
        end_year = exp.position.end.year if (exp.position.end and exp.position.end.year) else "Present"
        time_range = f"{start_year} - {end_year}"
        title = exp.position.title
        primary_job_type = exp.work_experience_classification.primary_job_type.value
        secondary_job_type = exp.work_experience_classification.secondary_job_type.value

        work_exp_str = (
            f"### Work Experience {idx}\n"
            f"**Company:** {company}\n\n"
            f"**Time Range:** {time_range}\n\n"
            f"**Title:** {title}\n\n"
            f"**Primary Job Type:** {primary_job_type}\n\n"
            f"**Secondary Job Type:** {secondary_job_type}\n\n"
        )

        # Investing focus
        if exp.investing_focus_asset_class_classification:
            asset_class = exp.investing_focus_asset_class_classification.investing_focus_asset_class.value
            sector = (
                exp.investing_focus_sector_classification.investing_focus_sector.value
                if exp.investing_focus_sector_classification
                else "N/A"
            )
            work_exp_str += f"**Investing Focus (Asset Class):** {asset_class}\n\n"
            work_exp_str += f"**Investing Focus (Sector):** {sector}\n\n"

        # Investment banking classification
        if exp.investment_banking_classification:
            ib_group = exp.investment_banking_classification.investment_banking_group.value
            work_exp_str += f"**Investment Banking Group:** {ib_group}\n"

        work_experience_outputs.append(work_exp_str)

    # Combine outputs
    education_output = "\n\n".join(education_outputs)
    work_experience_output = "\n\n".join(work_experience_outputs)

    full_output = f"# Classified Educations\n\n{education_output}\n\n# Classified Work Experiences\n\n{experience_output}\n\n{work_experience_output}"
    return full_output


def main():
    # Define Gradio interface
    with gr.Blocks() as demo:
        gr.Markdown("# LinkedIn Profile Analyzer")
        gr.Markdown("Enter a LinkedIn profile URL to analyze educational and work experiences.")

        profile_linkedin = gr.Textbox(label="LinkedIn Profile URL")
        analyze_button = gr.Button("Analyze")
        output = gr.Markdown()

        async def on_analyze_click(profile_linkedin):
            if not profile_linkedin:
                return "Please enter a valid LinkedIn Profile URL."
            try:
                result = await analyze_profile(profile_linkedin)
                return result
            except Exception as e:
                return f"An error occurred: {str(e)}"

        analyze_button.click(fn=on_analyze_click, inputs=profile_linkedin, outputs=output)
    demo.launch()


if __name__ == "__main__":
    main()