Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,6 +33,140 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
|
|
@@ -55,7 +189,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 55 |
|
| 56 |
agent = CodeAgent(
|
| 57 |
model=model,
|
| 58 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 59 |
max_steps=6,
|
| 60 |
verbosity_level=1,
|
| 61 |
grammar=None,
|
|
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
+
@tool
|
| 37 |
+
def analyze_linkedin_profile(profile_url: str) -> str:
|
| 38 |
+
"""A tool that provides guidance on analyzing a LinkedIn profile and extracts basic public information.
|
| 39 |
+
|
| 40 |
+
Args:
|
| 41 |
+
profile_url: The LinkedIn profile URL (e.g., 'https://www.linkedin.com/in/username')
|
| 42 |
+
"""
|
| 43 |
+
try:
|
| 44 |
+
# Extract username from URL
|
| 45 |
+
username = profile_url.rstrip('/').split('/')[-1].replace('in/', '')
|
| 46 |
+
|
| 47 |
+
# Attempt to fetch basic info (note: LinkedIn blocks most automated requests)
|
| 48 |
+
headers = {
|
| 49 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
| 50 |
+
'Accept-Language': 'en-US,en;q=0.9',
|
| 51 |
+
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
try:
|
| 55 |
+
response = requests.get(profile_url, headers=headers, timeout=10, allow_redirects=True)
|
| 56 |
+
status = response.status_code
|
| 57 |
+
except:
|
| 58 |
+
status = 0
|
| 59 |
+
|
| 60 |
+
# Provide structured guidance regardless of access
|
| 61 |
+
analysis = f"""
|
| 62 |
+
👤 LinkedIn Profile Analysis Tool
|
| 63 |
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
| 64 |
+
🔗 Profile: linkedin.com/in/{username}
|
| 65 |
+
📊 Access Status: {'✅ Public profile detected' if status == 200 else '⚠️ Limited access (login may be required)'}
|
| 66 |
+
|
| 67 |
+
📋 Key Information to Extract Manually:
|
| 68 |
+
|
| 69 |
+
1️⃣ PROFESSIONAL SUMMARY
|
| 70 |
+
• Current job title and company
|
| 71 |
+
• Years of experience
|
| 72 |
+
• Industry sector
|
| 73 |
+
• Location
|
| 74 |
+
|
| 75 |
+
2️⃣ WORK EXPERIENCE
|
| 76 |
+
• Recent positions (last 3-5 roles)
|
| 77 |
+
• Duration at each company
|
| 78 |
+
• Key responsibilities
|
| 79 |
+
• Career progression
|
| 80 |
+
|
| 81 |
+
3️⃣ EDUCATION & CERTIFICATIONS
|
| 82 |
+
• Degrees and institutions
|
| 83 |
+
• Graduation years
|
| 84 |
+
• Professional certifications
|
| 85 |
+
• Specialized training
|
| 86 |
+
|
| 87 |
+
4️⃣ SKILLS & EXPERTISE
|
| 88 |
+
• Technical skills
|
| 89 |
+
• Soft skills
|
| 90 |
+
• Endorsements count
|
| 91 |
+
• Top 5-10 skills
|
| 92 |
+
|
| 93 |
+
5️⃣ ENGAGEMENT METRICS
|
| 94 |
+
• Number of connections (if visible)
|
| 95 |
+
• Activity level (posts, articles)
|
| 96 |
+
• Recommendations received
|
| 97 |
+
• Languages spoken
|
| 98 |
+
|
| 99 |
+
💡 ANALYSIS TIPS:
|
| 100 |
+
- Check for career gaps or transitions
|
| 101 |
+
- Look for consistent skill themes
|
| 102 |
+
- Note any volunteer work or side projects
|
| 103 |
+
- Review recommendations for insights
|
| 104 |
+
- Check mutual connections for context
|
| 105 |
+
|
| 106 |
+
🔍 To access full profile details:
|
| 107 |
+
Visit: {profile_url}
|
| 108 |
+
"""
|
| 109 |
+
|
| 110 |
+
return analysis
|
| 111 |
+
|
| 112 |
+
except Exception as e:
|
| 113 |
+
return f"""
|
| 114 |
+
❌ Error analyzing LinkedIn profile: {str(e)}
|
| 115 |
+
|
| 116 |
+
📌 Profile URL: {profile_url}
|
| 117 |
+
|
| 118 |
+
💡 Manual Analysis Checklist:
|
| 119 |
+
✓ Visit the profile directly
|
| 120 |
+
✓ Note current position and company
|
| 121 |
+
✓ Review work history
|
| 122 |
+
✓ Check skills and endorsements
|
| 123 |
+
✓ Read recommendations
|
| 124 |
+
✓ Assess profile completeness
|
| 125 |
+
"""
|
| 126 |
+
|
| 127 |
+
@tool
|
| 128 |
+
def analyze_github_repository(repo_url: str) -> str:
|
| 129 |
+
"""A tool that analyzes a GitHub repository and provides insights about its structure, activity, and health.
|
| 130 |
+
|
| 131 |
+
Args:
|
| 132 |
+
repo_url: The GitHub repository URL (e.g., 'https://github.com/user/repo')
|
| 133 |
+
"""
|
| 134 |
+
try:
|
| 135 |
+
# Extract owner and repo name from URL
|
| 136 |
+
parts = repo_url.rstrip('/').split('/')
|
| 137 |
+
owner, repo = parts[-2], parts[-1]
|
| 138 |
+
|
| 139 |
+
# GitHub API endpoint
|
| 140 |
+
api_url = f"https://api.github.com/repos/{owner}/{repo}"
|
| 141 |
+
|
| 142 |
+
# Fetch repository data
|
| 143 |
+
response = requests.get(api_url, timeout=10)
|
| 144 |
+
|
| 145 |
+
if response.status_code != 200:
|
| 146 |
+
return f"Error: Unable to fetch repository data (Status: {response.status_code})"
|
| 147 |
+
|
| 148 |
+
data = response.json()
|
| 149 |
+
|
| 150 |
+
# Extract key metrics
|
| 151 |
+
analysis = f"""
|
| 152 |
+
📊 Repository Analysis: {data['full_name']}
|
| 153 |
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
| 154 |
+
📝 Description: {data.get('description', 'No description')}
|
| 155 |
+
⭐ Stars: {data['stargazers_count']:,}
|
| 156 |
+
🍴 Forks: {data['forks_count']:,}
|
| 157 |
+
👀 Watchers: {data['watchers_count']:,}
|
| 158 |
+
🐛 Open Issues: {data['open_issues_count']:,}
|
| 159 |
+
📅 Created: {data['created_at'][:10]}
|
| 160 |
+
🔄 Last Updated: {data['updated_at'][:10]}
|
| 161 |
+
📚 Language: {data.get('language', 'Not specified')}
|
| 162 |
+
📜 License: {data.get('license', {}).get('name', 'No license')}
|
| 163 |
+
🌐 Homepage: {data.get('homepage', 'None')}
|
| 164 |
+
"""
|
| 165 |
+
return analysis
|
| 166 |
+
|
| 167 |
+
except Exception as e:
|
| 168 |
+
return f"Error analyzing repository: {str(e)}"
|
| 169 |
+
|
| 170 |
|
| 171 |
final_answer = FinalAnswerTool()
|
| 172 |
|
|
|
|
| 189 |
|
| 190 |
agent = CodeAgent(
|
| 191 |
model=model,
|
| 192 |
+
tools=[final_answer, analyze_github_repository, analyze_linkedin_profile], ## add your tools here (don't remove final answer)
|
| 193 |
max_steps=6,
|
| 194 |
verbosity_level=1,
|
| 195 |
grammar=None,
|