> ## Documentation Index
> Fetch the complete documentation index at: https://cndoc-langchain.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Scholar 集成

> 使用 LangChain JavaScript 与 Google Scholar 工具集成。

本笔记本提供了开始使用 [`SERPGoogleScholarTool`](https://reference.langchain.com/javascript/langchain-community/tools/google_scholar/SERPGoogleScholarAPITool) 的快速概览。有关所有 `SERPGoogleScholarAPITool` 功能和配置的详细文档，请前往 [API 参考](https://reference.langchain.com/javascript/langchain-community/tools/google_scholar/SERPGoogleScholarAPITool)。

## 概览

### 集成详情

| 类                                                                                                                                   | 包                                                                            | [Python 支持](https://python.langchain.com/docs/integrations/tools/google_scholar/) |                                                 版本                                                |
| :---------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------- | :-------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------: |
| [`GoogleScholarTool`](https://reference.langchain.com/javascript/langchain-community/tools/google_scholar/SERPGoogleScholarAPITool) | [`@langchain/community`](https://www.npmjs.com/package/@langchain/community) |                                         ✅                                         | ![NPM - Version](https://img.shields.io/npm/v/@langchain/community?style=flat-square\&label=%20&) |

### 工具功能

* 按主题、作者或查询检索学术出版物。
* 获取元数据，如标题、作者和出版年份。
* 高级搜索过滤器，包括引用次数和期刊名称。

## 设置

该集成位于 `@langchain/community` 包中。

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
npm install @langchain/community
```

### 凭证

确保您拥有访问 Google Scholar 的适当 API 密钥。在环境变量中设置它：

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
SERPAPI_API_KEY="your-serp-api-key"
```

设置 [LangSmith](https://smith.langchain.com/) 以获得最佳可观测性也很有帮助：

```typescript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
process.env.LANGSMITH_TRACING="true"
process.env.LANGSMITH_API_KEY="your-langchain-api-key"
```

## 实例化

您可以像这样导入并实例化 `SERPGoogleScholarAPITool` 工具的实例：

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import { SERPGoogleScholarAPITool } from "@langchain/community/tools/google_scholar";

const tool = new SERPGoogleScholarAPITool({
  apiKey: process.env.SERPAPI_API_KEY,
});
```

## 调用

### 使用参数直接调用

您可以使用查询参数直接调用该工具：

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
const results = await tool.invoke({
  query: "neural networks",
  maxResults: 5,
});

console.log(results);
```

### 使用 ToolCall 调用

我们也可以使用模型生成的 `ToolCall` 来调用该工具：

```python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
const modelGeneratedToolCall = {
  args: { query: "machine learning" },
  id: "1",
  name: tool.name,
  type: "tool_call",
};
await tool.invoke(modelGeneratedToolCall);
```

***

## API 参考

有关所有 `SERPGoogleScholarAPITool` 功能和配置的详细文档，请前往 [API 参考](https://reference.langchain.com/javascript/langchain-community/tools/google_scholar/SERPGoogleScholarAPITool)。

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档](/use-these-docs)通过 MCP 连接到 Claude、VSCode 等，以获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/javascript/integrations/tools/google_scholar.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
