Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -65,191 +65,37 @@ def respond(
|
|
65 |
|
66 |
print(f"{datetime.datetime.now()}::{messages[-1]['content']}->{response}\n")
|
67 |
|
|
|
68 |
# Encode image to base64
|
69 |
def encode_image(image_path):
|
70 |
with open(image_path, "rb") as image_file:
|
71 |
return base64.b64encode(image_file.read()).decode('utf-8')
|
72 |
|
|
|
73 |
# Load and encode logos
|
74 |
github_logo_encoded = encode_image("Images/github-logo.png")
|
75 |
linkedin_logo_encoded = encode_image("Images/linkedin-logo.png")
|
76 |
website_logo_encoded = encode_image("Images/ai-logo.png")
|
77 |
|
78 |
-
#
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
background-color: #f4f7fc;
|
83 |
-
font-family: 'Roboto Mono', monospace;
|
84 |
-
}
|
85 |
-
|
86 |
-
/* Chatbot container */
|
87 |
-
.gradio-container {
|
88 |
-
max-width: 1200px;
|
89 |
-
margin: 0 auto;
|
90 |
-
padding: 20px;
|
91 |
-
}
|
92 |
-
|
93 |
-
/* Tab styling */
|
94 |
-
.tab-nav {
|
95 |
-
background-color: #ffffff;
|
96 |
-
border-radius: 8px;
|
97 |
-
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
98 |
-
margin-bottom: 20px;
|
99 |
-
}
|
100 |
-
|
101 |
-
.tab-nav button {
|
102 |
-
font-weight: 600;
|
103 |
-
color: #333;
|
104 |
-
padding: 12px 24px;
|
105 |
-
}
|
106 |
-
|
107 |
-
.tab-nav button:hover {
|
108 |
-
background-color: #e6f0fa;
|
109 |
-
}
|
110 |
-
|
111 |
-
/* Chatbot area */
|
112 |
-
.chatbot {
|
113 |
-
border-radius: 8px;
|
114 |
-
background-color: #ffffff;
|
115 |
-
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
116 |
-
padding: 20px;
|
117 |
-
}
|
118 |
-
|
119 |
-
/* Chat messages */
|
120 |
-
.chatbot .message {
|
121 |
-
border-radius: 12px;
|
122 |
-
margin: 10px 0;
|
123 |
-
padding: 15px;
|
124 |
-
}
|
125 |
-
|
126 |
-
.chatbot .user-message {
|
127 |
-
background-color: #e6f0fa;
|
128 |
-
color: #1a3c6e;
|
129 |
-
}
|
130 |
-
|
131 |
-
.chatbot .bot-message {
|
132 |
-
background-color: #f0f4f8;
|
133 |
-
color: #2d3748;
|
134 |
-
}
|
135 |
-
|
136 |
-
/* Input box */
|
137 |
-
input[type="text"] {
|
138 |
-
border: 1px solid #d1d5db;
|
139 |
-
border-radius: 8px;
|
140 |
-
padding: 12px;
|
141 |
-
font-size: 16px;
|
142 |
-
}
|
143 |
-
|
144 |
-
/* Submit button */
|
145 |
-
button.submit {
|
146 |
-
background-color: #1a3c6e;
|
147 |
-
color: white;
|
148 |
-
border-radius: 8px;
|
149 |
-
padding: 12px 24px;
|
150 |
-
font-weight: 600;
|
151 |
-
transition: background-color 0.3s;
|
152 |
-
}
|
153 |
-
|
154 |
-
button.submit:hover {
|
155 |
-
background-color: #2b528b;
|
156 |
-
}
|
157 |
-
|
158 |
-
/* Example buttons */
|
159 |
-
.examples button {
|
160 |
-
background-color: #edf2f7;
|
161 |
-
color: #2d3748;
|
162 |
-
border-radius: 8px;
|
163 |
-
margin: 5px;
|
164 |
-
padding: 10px 20px;
|
165 |
-
font-size: 14px;
|
166 |
-
transition: background-color 0.3s;
|
167 |
-
}
|
168 |
-
|
169 |
-
.examples button:hover {
|
170 |
-
background-color: #e2e8f0;
|
171 |
-
}
|
172 |
-
|
173 |
-
/* Footer styling */
|
174 |
-
footer {
|
175 |
-
visibility: visible !important;
|
176 |
-
text-align: center;
|
177 |
-
margin-top: 20px;
|
178 |
-
padding: 20px;
|
179 |
-
background-color: #ffffff;
|
180 |
-
border-radius: 8px;
|
181 |
-
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
182 |
-
}
|
183 |
-
|
184 |
-
/* Logo styling */
|
185 |
-
footer img {
|
186 |
-
width: 32px;
|
187 |
-
height: 32px;
|
188 |
-
margin: 0 10px;
|
189 |
-
transition: transform 0.3s;
|
190 |
-
}
|
191 |
-
|
192 |
-
footer img:hover {
|
193 |
-
transform: scale(1.1);
|
194 |
-
}
|
195 |
-
|
196 |
-
/* Markdown content */
|
197 |
-
.markdown {
|
198 |
-
line-height: 1.6;
|
199 |
-
color: #2d3748;
|
200 |
-
}
|
201 |
-
"""
|
202 |
-
|
203 |
-
# Gradio interface with enhanced UI
|
204 |
-
with gr.Blocks(
|
205 |
-
theme=gr.themes.Soft(
|
206 |
-
primary_hue="blue",
|
207 |
-
secondary_hue="gray",
|
208 |
-
neutral_hue="slate",
|
209 |
-
font=[gr.themes.GoogleFont("Roboto Mono"), "Arial", "sans-serif"],
|
210 |
-
radius_size="lg",
|
211 |
-
spacing_size="md",
|
212 |
-
),
|
213 |
-
css=custom_css
|
214 |
-
) as main:
|
215 |
-
gr.Markdown(
|
216 |
-
md.title,
|
217 |
-
elem_classes=["markdown"],
|
218 |
-
header_links=True
|
219 |
-
)
|
220 |
-
with gr.Tabs(elem_classes=["tab-nav"]):
|
221 |
with gr.TabItem("My2.0", visible=True, interactive=True):
|
222 |
gr.ChatInterface(
|
223 |
respond,
|
224 |
-
chatbot=gr.Chatbot(
|
225 |
-
height=600,
|
226 |
-
elem_classes=["chatbot"],
|
227 |
-
bubble_full_width=False,
|
228 |
-
show_copy_button=True,
|
229 |
-
avatar_images=(None, "Images/ai-logo.png"),
|
230 |
-
render_markdown=True
|
231 |
-
),
|
232 |
-
textbox=gr.Textbox(
|
233 |
-
placeholder="Ask me about my skills, projects, or experience!",
|
234 |
-
scale=7,
|
235 |
-
max_lines=5
|
236 |
-
),
|
237 |
-
submit_btn=gr.Button("Send", variant="primary", elem_classes=["submit"]),
|
238 |
-
retry_btn=gr.Button("Retry", variant="secondary"),
|
239 |
-
undo_btn=gr.Button("Undo", variant="secondary"),
|
240 |
-
clear_btn=gr.Button("Clear", variant="stop"),
|
241 |
examples=[
|
242 |
"Tell me about yourself",
|
243 |
-
|
244 |
"What specific skills do you bring to the table that would benefit our company's AI/ML initiatives?",
|
245 |
"How do you stay updated with the latest trends and advancements in AI and Machine Learning?",
|
246 |
-
]
|
247 |
-
examples_per_page=4,
|
248 |
)
|
249 |
-
gr.Markdown(md.description
|
250 |
|
251 |
with gr.TabItem("Resume", visible=True, interactive=True):
|
252 |
-
gr.Markdown(data
|
253 |
|
254 |
gr.HTML(md.footer.format(github_logo_encoded, linkedin_logo_encoded, website_logo_encoded))
|
255 |
|
|
|
65 |
|
66 |
print(f"{datetime.datetime.now()}::{messages[-1]['content']}->{response}\n")
|
67 |
|
68 |
+
|
69 |
# Encode image to base64
|
70 |
def encode_image(image_path):
|
71 |
with open(image_path, "rb") as image_file:
|
72 |
return base64.b64encode(image_file.read()).decode('utf-8')
|
73 |
|
74 |
+
|
75 |
# Load and encode logos
|
76 |
github_logo_encoded = encode_image("Images/github-logo.png")
|
77 |
linkedin_logo_encoded = encode_image("Images/linkedin-logo.png")
|
78 |
website_logo_encoded = encode_image("Images/ai-logo.png")
|
79 |
|
80 |
+
# Gradio interface
|
81 |
+
with gr.Blocks(theme=gr.themes.Ocean(font=[gr.themes.GoogleFont("Roboto Mono")]), css='footer {visibility: hidden}') as main:
|
82 |
+
gr.Markdown(md.title)
|
83 |
+
with gr.Tabs():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
with gr.TabItem("My2.0", visible=True, interactive=True):
|
85 |
gr.ChatInterface(
|
86 |
respond,
|
87 |
+
chatbot=gr.Chatbot(height=500),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
examples=[
|
89 |
"Tell me about yourself",
|
90 |
+
'Can you walk me through some of your recent projects and explain the role you played in each?',
|
91 |
"What specific skills do you bring to the table that would benefit our company's AI/ML initiatives?",
|
92 |
"How do you stay updated with the latest trends and advancements in AI and Machine Learning?",
|
93 |
+
]
|
|
|
94 |
)
|
95 |
+
gr.Markdown(md.description)
|
96 |
|
97 |
with gr.TabItem("Resume", visible=True, interactive=True):
|
98 |
+
gr.Markdown(data)
|
99 |
|
100 |
gr.HTML(md.footer.format(github_logo_encoded, linkedin_logo_encoded, website_logo_encoded))
|
101 |
|