-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithubfn.py
More file actions
271 lines (228 loc) · 10.4 KB
/
Copy pathgithubfn.py
File metadata and controls
271 lines (228 loc) · 10.4 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
import streamlit as st
import os
from dotenv import load_dotenv
import google.generativeai as genai
import pandas as pd
from analyze_github_with_ai import analyze_github_with_ai
from create_activity_tab import create_activity_chart
from fetch_github_profile import fetch_github_profile
from functions import (
create_language_chart,
)
import uuid
from read_pdf import read_pdf
load_dotenv()
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
model = genai.GenerativeModel("gemini-1.5-flash")
# Initialize session state for resume versions
if "resume_versions" not in st.session_state:
st.session_state.resume_versions = {}
# Initialize session state for GitHub profile cache
if "github_profiles" not in st.session_state:
st.session_state.github_profiles = {}
def githubfn():
st.header("🔎 GitHub Profile Analyzer")
st.markdown(
"""
### Enhance Your Resume with GitHub Analysis
Your GitHub profile is a powerful portfolio that showcases your coding skills and projects.
Let's analyze your GitHub profile to identify strengths that complement your resume!
"""
)
# Setup UI columns
col1, col2 = st.columns([2, 3])
with col1:
# Input GitHub username
github_username = st.text_input("Enter GitHub Username")
# Option to use resume from tab 1
use_resume = st.checkbox("Use resume from Resume Analysis tab", value=True)
# Select resume version if available
resume_version_id = None
resume_text = None
job_desc = None
if use_resume and st.session_state.resume_versions:
resume_version_id = st.selectbox(
"Select resume version",
options=list(st.session_state.resume_versions.keys()),
format_func=lambda x: st.session_state.resume_versions[x]["name"],
)
if resume_version_id:
resume_text = st.session_state.resume_versions[resume_version_id][
"text"
]
job_desc = st.session_state.resume_versions[resume_version_id][
"job_description"
]
# Option to upload a resume directly in this tab
if not use_resume:
upload_resume_file = st.file_uploader(
"Upload your resume (PDF)", type=["pdf"], key="github_resume_upload"
)
job_desc = st.text_area(
"Job Description (optional)", height=100, key="github_job_desc"
)
if upload_resume_file:
resume_text = read_pdf(upload_resume_file)
# Analysis button
analyze_github_button = st.button(
"Analyze GitHub Profile", key="analyze_github"
)
with col2:
st.markdown("### Benefits of GitHub Profile Analysis")
st.write(
"""
- **Identify Skill Gaps**: See if your GitHub projects showcase skills that are missing from your resume
- **Showcase Your Best Work**: Highlight projects that are most relevant to job applications
- **Technical Credibility**: Demonstrate coding ability beyond what's stated in your resume
- **Bridge the Resume-Code Gap**: Ensure your GitHub profile reinforces your resume claims
"""
)
st.info(
"""
**Pro Tip**: Technical recruiters and hiring managers often check candidates' GitHub profiles
to validate their technical skills and see real code examples. Make sure your profile is optimized!
"""
)
# Process and display results after button click
if analyze_github_button and github_username:
with st.spinner("Analyzing GitHub profile..."):
# Fetch GitHub profile
github_info = fetch_github_profile(github_username)
# Check for errors
if "error" in github_info:
st.error(f"Error: {github_info['error']}")
else:
# Display profile summary
st.subheader("GitHub Profile Summary")
# Profile header with image and basic info
col1, col2 = st.columns([1, 3])
with col1:
st.image(github_info["avatar_url"], width=150)
with col2:
st.markdown(
f"### [{github_info['name'] or github_info['username']}]({github_info['html_url']})"
)
if github_info["bio"]:
st.markdown(f"*{github_info['bio']}*")
st.markdown(
f"📍 Location: {github_info['location'] or 'Not specified'}"
)
st.markdown(f"🗓️ Joined: {github_info['joined_at'][:10]}")
# GitHub stats
st.markdown("### 📊 GitHub Statistics")
stat_cols = st.columns(4)
with stat_cols[0]:
st.markdown(
f"""
<div class="github-stat-item">
<h3>{github_info['public_repos']}</h3>
<p>Repositories</p>
</div>
""",
unsafe_allow_html=True,
)
with stat_cols[1]:
st.markdown(
f"""
<div class="github-stat-item">
<h3>{github_info['followers']}</h3>
<p>Followers</p>
</div>
""",
unsafe_allow_html=True,
)
with stat_cols[2]:
st.markdown(
f"""
<div class="github-stat-item">
<h3>{github_info['stargazers_total']}</h3>
<p>Total Stars</p>
</div>
""",
unsafe_allow_html=True,
)
with stat_cols[3]:
st.markdown(
f"""
<div class="github-stat-item">
<h3>{github_info['fork_total']}</h3>
<p>Total Forks</p>
</div>
""",
unsafe_allow_html=True,
)
# Top repositories
st.markdown("### 🏆 Top Repositories")
top_repos = github_info["repos"][:5] # Show top 5 repos
for repo in top_repos:
st.markdown(
f"""
<div class="repo-card">
<h4><a href="{repo['html_url']}" target="_blank">{repo['name']}</a></h4>
<p>{repo['description'] or 'No description available'}</p>
<p>
<strong>Language:</strong> {repo['language'] or 'Not specified'} |
<strong>Stars:</strong> {repo['stars']} |
<strong>Forks:</strong> {repo['forks']} |
<strong>Last updated:</strong> {repo['updated_at'][:10]}
</p>
</div>
""",
unsafe_allow_html=True,
)
# Language visualization
st.markdown("### 💻 Programming Languages")
lang_cols = st.columns(2)
with lang_cols[0]:
# Language chart
lang_chart = create_language_chart(github_info)
if lang_chart:
st.pyplot(lang_chart)
else:
st.info("No language data available")
with lang_cols[1]:
activity_chart = create_activity_chart(github_info)
if activity_chart:
st.pyplot(activity_chart)
else:
st.info("Not enough repository data available")
# AI analysis
st.markdown("### 🤖 AI Analysis")
with st.spinner("Generating AI insights..."):
ai_analysis = analyze_github_with_ai(
github_info, resume_text, job_desc
)
st.markdown(ai_analysis)
# Recommendations section
st.markdown("### 🚀 GitHub Profile Optimization")
st.markdown(
"""
#### General Recommendations:
1. **Pin Your Best Repositories**: Make sure your most impressive and relevant projects are pinned to the top
2. **Complete README Files**: Each repository should have a detailed README with project description, screenshots, and setup instructions
3. **Consistent Contributions**: Regular activity shows dedication and ongoing skill development
4. **Clean Code**: Ensure your repositories showcase good coding practices and documentation
5. **Link to Live Demos**: Where applicable, provide links to live versions of your projects
"""
)
# Save analysis option
save_analysis = st.checkbox("Save this GitHub analysis")
if save_analysis:
analysis_name = st.text_input(
"Analysis name", value=f"GitHub Analysis - {github_username}"
)
if st.button("Save Analysis"):
# Create a unique ID for this analysis
analysis_id = str(uuid.uuid4())[:8]
# Store in session state - we could create a new session state variable for GitHub analyses
if "github_analyses" not in st.session_state:
st.session_state.github_analyses = {}
st.session_state.github_analyses[analysis_id] = {
"name": analysis_name,
"github_username": github_username,
"github_info": github_info,
"ai_analysis": ai_analysis,
"resume_id": resume_version_id,
"timestamp": pd.Timestamp.now().strftime("%Y-%m-%d %H:%M"),
}
st.success(f"Analysis saved as '{analysis_name}'")