Semantic Scholar API Tool
本笔记本演示了如何使用语义学者工具与代理。
# start by installing semanticscholar api
%pip install --upgrade --quiet semanticscholar
from langchain import hub
from langchain.agents import AgentExecutor, create_openai_functions_agent
from langchain_openai import ChatOpenAI
instructions = """You are an expert researcher."""
base_prompt = hub.pull("langchain-ai/openai-functions-template")
prompt = base_prompt.partial(instructions=instructions)
llm = ChatOpenAI(temperature=0)
from langchain_community.tools.semanticscholar.tool import SemanticScholarQueryRun
tools = [SemanticScholarQueryRun()]
agent = create_openai_functions_agent(llm, tools, prompt)
agent_executor = AgentExecutor(
agent=agent,
tools=tools,
verbose=True,
)
agent_executor.invoke(
{
"input": "What are some biases in the large language models? How have people tried to mitigate them? "
"show me a list of papers and techniques. Based on your findings write new research questions "
"to work on. Break down the task into subtasks for search. Use the search tool"
}
)