-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinkedin_url.py
More file actions
32 lines (25 loc) · 955 Bytes
/
linkedin_url.py
File metadata and controls
32 lines (25 loc) · 955 Bytes
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
import os
from langchain_tavily import TavilySearch
from langchain_core.tools import Tool
from dotenv import load_dotenv
load_dotenv()
def get_profile_url_tavily(name):
"""This Function Searches for LinkedinPage."""
try:
search = TavilySearch()
res = search.invoke(f"{name} linkedin profile")
return res
except Exception as e:
# Return a structured error response
return {
"error": str(e),
"search_query": f"{name} linkedin profile",
"fallback_url": f"https://www.linkedin.com/search/results/people/?keywords={name.replace(' ', '%20')}"
}
linkedin_url=Tool(
name="Crawl Google for linkedin profile page",
func=get_profile_url_tavily,
description="This tool is useful when you need get the Linkedin Page URL for a user",
)
# Example usage (uncomment to test)
# print(get_profile_url_tavily("Shagun Nagpal"))