File size: 1,439 Bytes
1830d05
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from tools.tools import get_profile_url
from dotenv import load_dotenv
from langchain import PromptTemplate
from langchain.llms.bedrock import Bedrock
from langchain.agents import initialize_agent, Tool, AgentType
import re 




def get_llm():

    bedrock_llm = Bedrock(model_id="anthropic.claude-v2",
                           model_kwargs={"temperature": 0.1,"max_tokens_to_sample": 4096})

    return bedrock_llm

def lookup(name: str) -> str:
    load_dotenv()

    template = """given the full name {name_of_person} I want you to get it me a link to their Linkedin profile page.
                  Your answer should contain only a URL of the LinkedIN profile"""

    tools_for_agent = [
        Tool(
            name="Crawl Google 4 linkedin profile page",
            func=get_profile_url,
            description="useful for when you need get the Linkedin Page URL",
        ),
    ]
    llm = get_llm()
    agent_chain = initialize_agent(tools_for_agent, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)

    prompt_template = PromptTemplate(
        input_variables=["name_of_person"], template=template
    )

    # Get the LLM's output
    try:
        linkedin_username = agent_chain.run(handle_parsing_errors=True, input=prompt_template.format_prompt(name_of_person=name))

    except ValueError as e:
        print("Error while parsing LLM output:", e)
        return None
    
    return linkedin_username