-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
72 lines (60 loc) · 2.49 KB
/
app.py
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
import streamlit as st
from langchain.chains import LLMChain
from langchain_openai import ChatOpenAI
from langchain_core.prompts import PromptTemplate
import os, json
from dotenv import load_dotenv
from scrape_linkedin_profile import scrape_linkedin_profile
from serpapi_search_user import search_profile
import time
import re
load_dotenv()
OPENAI_API_KEY=os.getenv("OPENAI_API_KEY")
prompt_template = """You are an AI Assistant who is given the information about a person's Linkedin Profile scrapped.
You need to tell me following facts about the person which will help me in pitching the right sales pitch. the following material will be the ice breaker.
Given Informtaion: {profile_data}
Facts you need to tell me in json format:
Name:
Summary of working experience:
Industry:
Summary of education:
Location:
3 interesting facts:
Ice Breaker:
Profile Picture URL:
Do not assume anything on your own. Provide answers from the given information only.
"""
prompt = PromptTemplate(
input_variables=["profile_data"], template=prompt_template
)
st.title("Ice Breaking Your Next Sale")
name = st.text_input("Enter the name of the person you want to Ice break with: ")
if st.button("Break the Ice"):
try:
with st.spinner("Let me search on the web.."):
time.sleep(2)
link = search_profile(name)
if link == "No good search result found":
st.error("No good search result found")
st.stop()
with st.spinner(f"I got profile for {name}, let me find relevant data..."):
data = scrape_linkedin_profile(link)
with st.spinner("Cool, I got the data, let me process it for your Sales needs..."):
llm = LLMChain(llm=ChatOpenAI(model='gpt-4-1106-preview'), prompt=prompt)
#st.spinner("Initializing LLMChain... Done!")
res = llm.run({"profile_data":data})
#st.write(res)
#st.write(type(res))
#st.write("chaning to dic")
res = json.loads(str(res)[7:][:-3])
#print(res)
#st.write("chaning to dic done")
#st.write(type(res))
image_url = res["Profile Picture URL"]
st.image(image_url, width=300)
res.pop("Profile Picture URL")
for key, value in res.items():
st.write(f"**{key}**: {value}")
#st.write(llm.run({"profile_data":data}))
except Exception as e:
st.error(e)