Google Scholar Tool
This notebook provides a quick overview for getting started with
SERPGoogleScholarTool
.
For detailed documentation of all SERPGoogleScholarAPITool
features
and configurations, head to the API
reference.
Overviewβ
Integration detailsβ
Class | Package | PY support | Package latest |
---|---|---|---|
GoogleScholarTool | @langchain/community | β |
Tool featuresβ
- Retrieve academic publications by topic, author, or query.
- Fetch metadata such as title, author, and publication year.
- Advanced search filters, including citation count and journal name.
Setupβ
The integration lives in the @langchain/community
package.
npm install @langchain/community
Credentialsβ
Ensure you have the appropriate API key to access Google Scholar. Set it in your environment variables:
process.env.GOOGLE_SCHOLAR_API_KEY = "your-serp-api-key";
Itβs also helpful to set up LangSmith for best-in-class observability:
process.env.LANGCHAIN_TRACING_V2 = "true";
process.env.LANGCHAIN_API_KEY = "your-langchain-api-key";
Instantiationβ
You can import and instantiate an instance of the
SERPGoogleScholarAPITool
tool like this:
import { SERPGoogleScholarAPITool } from "@langchain/community/tools/google_scholar";
const tool = new SERPGoogleScholarAPITool({
apiKey: process.env.SERPAPI_API_KEY,
});
Invocationβ
Invoke directly with argsβ
You can invoke the tool directly with query arguments:
const results = await tool.invoke({
query: "neural networks",
maxResults: 5,
});
console.log(results);
Invoke with ToolCallβ
We can also invoke the tool with a model-generated ToolCall
:
const modelGeneratedToolCall = {
args: { query: "machine learning" },
id: "1",
name: tool.name,
type: "tool_call",
};
await tool.invoke(modelGeneratedToolCall);
API referenceβ
For detailed documentation of all SERPGoogleScholarAPITool
features
and configurations, head to the API
reference.
Relatedβ
- Tool conceptual guide
- Tool how-to guides