|
|
import streamlit as st |
|
|
import requests |
|
|
from groq import Groq |
|
|
|
|
|
|
|
|
def scrape_linkedin_profile(linkedin_url): |
|
|
api_url = "https://nubela.co/proxycurl/api/v2/linkedin" |
|
|
api_key = "Y5xigulf0B1C_wr20seh8g" |
|
|
headers = { |
|
|
"Authorization": f"Bearer {api_key}" |
|
|
} |
|
|
|
|
|
params = { |
|
|
"url": linkedin_url, |
|
|
"use_cache": "if-present" |
|
|
} |
|
|
|
|
|
response = requests.get(api_url, headers=headers, params=params) |
|
|
|
|
|
if response.status_code == 200: |
|
|
return response.json() |
|
|
else: |
|
|
return f"Error scraping LinkedIn profile: {response.text}" |
|
|
|
|
|
|
|
|
def generate_email(name, email, phone, role, tokens, linkedin_url): |
|
|
reasoning_trace = [] |
|
|
|
|
|
|
|
|
reasoning_trace.append(f"Initiating profile scrape for {name}.") |
|
|
profile_data = scrape_linkedin_profile(linkedin_url) |
|
|
|
|
|
if isinstance(profile_data, str) and "Error" in profile_data: |
|
|
return profile_data |
|
|
|
|
|
|
|
|
reasoning_trace.append(f"Obtained profile data: {profile_data}.") |
|
|
|
|
|
|
|
|
client = Groq(api_key='YOUR_GROQ_API_KEY') |
|
|
|
|
|
|
|
|
messages = [ |
|
|
{ |
|
|
"role": "user", |
|
|
"content": [ |
|
|
{"type": "text", "text": f"Generate an email for {name} applying for {role}."}, |
|
|
{"type": "text", "text": f"Email: {email}, Phone: {phone}, Profile Data: {profile_data}"} |
|
|
] |
|
|
} |
|
|
] |
|
|
|
|
|
|
|
|
completion = client.chat.completions.create( |
|
|
model="llama-3.2-90b-vision-preview", |
|
|
messages=messages, |
|
|
max_tokens=tokens, |
|
|
temperature=1, |
|
|
top_p=1, |
|
|
stream=False, |
|
|
stop=None |
|
|
) |
|
|
|
|
|
|
|
|
reasoning_trace.append("Email content generated.") |
|
|
|
|
|
email_body = completion['choices'][0]['message']['content'] |
|
|
|
|
|
|
|
|
return f"Email Content:\n{email_body}\n\nReasoning Trace: {'; '.join(reasoning_trace)}" |
|
|
|
|
|
|
|
|
def main(): |
|
|
st.title("LinkedIn Profile Scraper and Email Generator") |
|
|
|
|
|
|
|
|
name = st.text_input("Name of the Sender") |
|
|
email = st.text_input("Email Address of the Sender") |
|
|
phone = st.text_input("Phone Number of the Sender") |
|
|
linkedin_url = st.text_input("LinkedIn Profile URL") |
|
|
role = st.text_input("Role Applying For") |
|
|
tokens = st.number_input("Number of Tokens", min_value=1, max_value=500, value=50) |
|
|
|
|
|
|
|
|
if st.button("Scrape Profile and Generate Email"): |
|
|
if name and email and phone and linkedin_url and role and tokens: |
|
|
email_content = generate_email(name, email, phone, role, tokens, linkedin_url) |
|
|
st.subheader("Generated Email:") |
|
|
st.write(email_content) |
|
|
else: |
|
|
st.error("Please fill in all fields.") |
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
main() |