forked from vicky-playground/portfolio-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1_Home.py
147 lines (121 loc) · 24 KB
/
1_Home.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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import streamlit as st
import requests
from streamlit_lottie import st_lottie
from streamlit_timeline import timeline
import streamlit.components.v1 as components
from llama_index import GPTVectorStoreIndex, SimpleDirectoryReader, LLMPredictor, ServiceContext
from constant import *
from PIL import Image
import openai
from langchain.chat_models import ChatOpenAI
st.set_page_config(page_title='Landing Zone' ,layout="wide",page_icon='📝')
# ----------------- chatbot ----------------- #
# Set up the OpenAI key
openai_api_key = st.secrets['OPENAI_API_KEY']
openai.api_key = (openai_api_key)
notion = Image.open("images/notion.jpg")
ghub = Image.open("images/github.png")
linked = Image.open("images/linkedin.png")
# load the file
documents = SimpleDirectoryReader(input_files=["bio.txt"]).load_data()
pronoun = info["Pronoun"]
name = info["Name"]
def ask_bot(input_text):
# define LLM
llm = ChatOpenAI(
model_name="gpt-3.5-turbo",
temperature=0,
openai_api_key=openai.api_key,
)
llm_predictor = LLMPredictor(llm=llm)
service_context = ServiceContext.from_defaults(llm_predictor=llm_predictor)
# load index
index = GPTVectorStoreIndex.from_documents(documents, service_context=service_context)
# query LlamaIndex and GPT-3.5 for the AI's response
PROMPT_QUESTION = f"""You are Buddy, an AI assistant dedicated to assisting {name} in his job search by providing recruiters with relevant and concise information.
If you do not know the answer, politely admit it and let recruiters know how to contact {name} to get more information directly from {pronoun}.
Don't put "Buddy" or a breakline in the front of your answer.
Human: {input}
"""
output = index.as_query_engine().query(PROMPT_QUESTION.format(input=input_text))
print(f"output: {output}")
return output.response
# get the user's input by calling the get_text function
def get_text():
input_text = st.text_input("You can send your questions and hit Enter to know more about me from my AI agent, Buddy!", key="input")
return input_text
#st.markdown("Chat With Me Now")
user_input = get_text()
if user_input:
#text = st.text_area('Enter your questions')
if not openai_api_key.startswith('sk-'):
st.warning('⚠️Please enter your OpenAI API key on the sidebar.', icon='⚠')
if openai_api_key.startswith('sk-'):
st.info(ask_bot(user_input))
def load_lottieurl(url: str):
r = requests.get(url)
if r.status_code != 200:
return None
return r.json()
def local_css(file_name):
with open(file_name) as f:
st.markdown('<style>{}</style>'.format(f.read()), unsafe_allow_html=True)
local_css("style/style.css")
# loading assets
lottie_gif = load_lottieurl("https://lottie.host/9b0af794-88be-4af1-b728-80508b884f55/r7isyhm6Ub.json")
python_lottie = load_lottieurl("https://assets6.lottiefiles.com/packages/lf20_2znxgjyt.json")
git_lottie = load_lottieurl("https://assets9.lottiefiles.com/private_files/lf30_03cuemhb.json")
github_lottie = load_lottieurl("https://assets8.lottiefiles.com/packages/lf20_6HFXXE.json")
js_lottie = load_lottieurl("https://lottie.host/fc1ad1cd-012a-4da2-8a11-0f00da670fb9/GqPujskDlr.json")
# ----------------- info ----------------- #
def gradient(color1, color2, color3, content1, content2):
st.markdown(f'<h1 style="text-align:center;background-image: linear-gradient(to right,{color1}, {color2});font-size:60px;border-radius:2%;">'
f'<span style="color:{color3};">{content1}</span><br>'
f'<span style="color:white;font-size:17px;">{content2}</span></h1>',
unsafe_allow_html=True)
with st.container():
col1,col2 = st.columns([8,3])
full_name = info['Full_Name']
with col1:
gradient('#003366', '#000000', '#FFA500',f"Hi, I'm {full_name}📖", info["Intro"])
st.write("")
st.write(info['About'])
with col2:
st_lottie(lottie_gif, height=280, key="data")
# ----------------- skillset ----------------- #
with st.container():
st.subheader('⚒️ Skills')
col1, col2, col3, col4 = st.columns([1, 1, 1, 1])
with col1:
st_lottie(python_lottie, height=70,width=70, key="python", speed=0)
with col2:
st_lottie(git_lottie, height=70,width=70, key="git", speed=0)
with col3:
st_lottie(github_lottie,height=70,width=70, key="github", speed=0)
with col4:
st_lottie(js_lottie,height=70,width=70, key="javascript", speed=1)
with col1:
st.subheader("📨 Contact Me")
contact_form = f"""
<form action="https://formsubmit.co/{info["Email"]}" method="POST">
<input type="hidden" name="_captcha value="false">
<input type="text" name="name" placeholder="Your name" required>
<input type="email" name="email" placeholder="Your email" required>
<textarea name="message" placeholder="Your message here" required></textarea>
<button type="submit">Send</button>
</form>
"""
st.markdown(contact_form, unsafe_allow_html=True)
with col2:
st.subheader("Portfolio")
# Embedding the links as images
st.write("Check out my portfolio on:")
st.markdown("[](https://palmetto.notion.site/The-Epting-Maker-s-Studio-0ea2942922a24ab3b7cd9a78774bd3d1?pvs=4)")
with col3:
st.subheader("Linkedin")
st.write("Connect with me on:")
st.markdown("[](https://www.linkedin.com/in/qepting)")
with col4:
st.subheader("Github")
st.write("Or check out my code:")
st.markdown("[](https://github.com/qepting91)")