.ipynb
.pdf
Human as a tool
Human as a tool#
Human are AGI so they can certainly be used as a tool to help out AI agent
when it is confused.
import sys
from langchain.chat_models import ChatOpenAI
from langchain.llms import OpenAI
from langchain.agents import load_tools, initialize_agent
llm = ChatOpenAI(temperature=0.0)
math_llm = OpenAI(temperature=0.0)
tools = load_tools(
    ["human", "llm-math"], 
    llm=math_llm,
)
agent_chain = initialize_agent(
    tools,
    llm,
    agent="zero-shot-react-description",
    verbose=True,
)
In the above code you can see the tool takes input directly from command line.
You can customize prompt_func and input_func according to your need.
agent_chain.run("What is Eric Zhu's birthday?")
# Answer with "last week"
> Entering new AgentExecutor chain...
I don't know Eric Zhu, so I should ask a human for guidance.
Action: Human
Action Input: "Do you know when Eric Zhu's birthday is?"
Do you know when Eric Zhu's birthday is?
last week
Observation: last week
Thought:That's not very helpful. I should ask for more information.
Action: Human
Action Input: "Do you know the specific date of Eric Zhu's birthday?"
Do you know the specific date of Eric Zhu's birthday?
august 1st
Observation: august 1st
Thought:Now that I have the date, I can check if it's a leap year or not.
Action: Calculator
Action Input: "Is 2021 a leap year?"
Observation: Answer: False