Skip to main content
Open on GitHub

Google

Google CloudGoogle Gemini及其他Google产品相关的所有功能。

  1. Google生成式AI(Gemini API和AI Studio): 通过Gemini API直接访问Google Gemini模型。使用Google AI Studio进行快速原型设计,借助langchain-google-genai包快速入门。这对个人开发者来说通常是最佳起点。
  2. Google Cloud(Vertex AI 及其他服务): 通过 Google Cloud Platform 访问 Gemini 模型、Anthropic on Vertex AI Model Garden以及多种云服务(数据库、存储、文档 AI 等)。使用 langchain-google-vertexai 包访问 Vertex AI 模型,使用特定包(例如 langchain-google-cloud-sql-pglangchain-google-community)访问其他云服务。这非常适合已在使用 Google Cloud 的开发者,或需要 MLOps、特定模型调优或企业支持等企业功能的用户。

有关差异的更多详情,请参阅 Google 的指南:从 Gemini API 迁移到 Vertex AI

Gemini模型和Vertex AI平台的集成包维护在 langchain-google仓库中。 您可以在 googleapis GitHub组织和langchain-google-community包中找到与其它Google API和服务的大量LangChain集成。

Google生成式AI(Gemini API与AI Studio)

使用 Gemini API 直接访问 Google Gemini 模型,最适合快速开发和实验。Gemini 模型可在 Google AI Studio 中获取。

pip install -U langchain-google-genai

免费开始并从 Google AI Studio 获取您的API密钥。

export GOOGLE_API_KEY="YOUR_API_KEY"

聊天模型

使用 ChatGoogleGenerativeAI 类与 Gemini 2.0 和 2.5 模型进行交互。详情请参见 此指南

from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_core.messages import HumanMessage

llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash")

# Simple text invocation
result = llm.invoke("Sing a ballad of LangChain.")
print(result.content)

# Multimodal invocation with gemini-pro-vision
message = HumanMessage(
content=[
{
"type": "text",
"text": "What's in this image?",
},
{"type": "image_url", "image_url": "https://picsum.photos/seed/picsum/200/300"},
]
)
result = llm.invoke([message])
print(result.content)

image_url 可以是公共 URL、GCS URI (gs://...)、本地文件路径、base64 编码的图像字符串 (data:image/png;base64,...) 或 PIL 图像对象。

嵌入模型

使用类似于 gemini-embedding-exp-03-07 的模型,通过 GoogleGenerativeAIEmbeddings 类生成文本嵌入。

查看一个 使用示例

from langchain_google_genai import GoogleGenerativeAIEmbeddings

embeddings = GoogleGenerativeAIEmbeddings(model="models/gemini-embedding-exp-03-07")
vector = embeddings.embed_query("What are embeddings?")
print(vector[:5])

LLMs

使用 (旧版) LLM 接口访问相同的 Gemini 模型, 通过 GoogleGenerativeAI 类。

查看一个 使用示例

from langchain_google_genai import GoogleGenerativeAI

llm = GoogleGenerativeAI(model="gemini-2.0-flash")
result = llm.invoke("Sing a ballad of LangChain.")
print(result)
API 参考:GoogleGenerativeAI

Google Cloud

通过 Vertex AI 和特定云集成访问 Gemini 模型、Vertex AI Model Garden 及其他 Google Cloud 服务。

Vertex AI 模型需要 langchain-google-vertexai 包。其他服务可能还需要额外的包,例如 langchain-google-communitylangchain-google-cloud-sql-pg 等。

pip install langchain-google-vertexai
# pip install langchain-google-community[...] # For other services

Google Cloud 集成通常使用应用默认凭据 (ADC)。有关设置说明,请参阅 Google Cloud 认证文档(例如,使用 gcloud auth application-default login)。

聊天模型

Vertex AI

通过Vertex AI平台访问聊天模型,例如Gemini

查看一个 使用示例

from langchain_google_vertexai import ChatVertexAI
API 参考:ChatVertexAI

Anthropic on Vertex AI Model Garden

查看一个 使用示例

from langchain_google_vertexai.model_garden import ChatAnthropicVertex
API 参考:ChatAnthropicVertex

在Vertex AI模型花园中的Llama

from langchain_google_vertexai.model_garden_maas.llama import VertexModelGardenLlama

在Vertex AI模型花园中的Mistral

from langchain_google_vertexai.model_garden_maas.mistral import VertexModelGardenMistral

来自Hugging Face的Gemma本地版本

Local Gemma model loaded from HuggingFace. Requires langchain-google-vertexai.

from langchain_google_vertexai.gemma import GemmaChatLocalHF
API 参考:GemmaChatLocalHF

来自Kaggle的Gemma本地

Local Gemma model loaded from Kaggle. Requires langchain-google-vertexai.

from langchain_google_vertexai.gemma import GemmaChatLocalKaggle

在Vertex AI模型花园中的Gemma

Requires langchain-google-vertexai.

from langchain_google_vertexai.gemma import GemmaChatVertexAIModelGarden

Vertex AI 图像字幕生成

Implementation of the Image Captioning model as a chat. Requires langchain-google-vertexai.

from langchain_google_vertexai.vision_models import VertexAIImageCaptioningChat

Vertex AI 图像编辑器

Given an image and a prompt, edit the image. Currently only supports mask-free editing. Requires langchain-google-vertexai.

from langchain_google_vertexai.vision_models import VertexAIImageEditorChat

Vertex AI 图像生成器

Generates an image from a prompt. Requires langchain-google-vertexai.

from langchain_google_vertexai.vision_models import VertexAIImageGeneratorChat

Vertex AI 视觉问答

Chat implementation of a visual QnA model. Requires langchain-google-vertexai.

from langchain_google_vertexai.vision_models import VertexAIVisualQnAChat

LLMs

您也可以使用 (旧版) 字符串输入、字符串输出的LLM接口。

Anthropic on Vertex AI Model Garden

通过 Vertex AI Model Garden 服务访问 Gemini 和数百个开源模型(OSS)。需要 langchain-google-vertexai

查看一个 使用示例

from langchain_google_vertexai import VertexAIModelGarden
API 参考:VertexAIModelGarden

来自Hugging Face的Gemma本地版本

Local Gemma model loaded from HuggingFace. Requires langchain-google-vertexai.

from langchain_google_vertexai.gemma import GemmaLocalHF
API 参考:GemmaLocalHF

来自Kaggle的Gemma本地

Local Gemma model loaded from Kaggle. Requires langchain-google-vertexai.

from langchain_google_vertexai.gemma import GemmaLocalKaggle
API 参考:GemmaLocalKaggle

在Vertex AI模型花园中的Gemma

Requires langchain-google-vertexai.

from langchain_google_vertexai.gemma import GemmaVertexAIModelGarden

Vertex AI 图像字幕生成

Implementation of the Image Captioning model as an LLM. Requires langchain-google-vertexai.

from langchain_google_vertexai.vision_models import VertexAIImageCaptioning

嵌入模型

Vertex AI

使用部署在Vertex AI上的模型生成嵌入。需要 langchain-google-vertexai

查看一个 使用示例

from langchain_google_vertexai import VertexAIEmbeddings
API 参考:VertexAIEmbeddings

文档加载器

从各种Google Cloud源加载文档。

PostgreSQL的AlloyDB

Google Cloud AlloyDB is a fully managed PostgreSQL-compatible database service.

安装 Python 包:

pip install langchain-google-alloydb-pg

查看 使用示例

from langchain_google_alloydb_pg import AlloyDBLoader # AlloyDBEngine also available

BigQuery

Google Cloud BigQuery is a serverless data warehouse.

使用 BigQuery 依赖项安装:

pip install langchain-google-community[bigquery]

查看一个 使用示例

from langchain_google_community import BigQueryLoader
API 参考:BigQueryLoader

Bigtable

Google Cloud Bigtable is a fully managed NoSQL Big Data database service.

安装 Python 包:

pip install langchain-google-bigtable

查看 使用示例

from langchain_google_bigtable import BigtableLoader

适用于 MySQL 的 Cloud SQL

Google Cloud SQL for MySQL is a fully-managed MySQL database service.

安装 Python 包:

pip install langchain-google-cloud-sql-mysql

查看 使用示例

from langchain_google_cloud_sql_mysql import MySQLLoader # MySQLEngine also available

适用于 SQL Server 的 Cloud SQL

Google Cloud SQL for SQL Server is a fully-managed SQL Server database service.

安装 Python 包:

pip install langchain-google-cloud-sql-mssql

查看 使用示例

from langchain_google_cloud_sql_mssql import MSSQLLoader # MSSQLEngine also available

用于 PostgreSQL 的 Cloud SQL

Google Cloud SQL for PostgreSQL is a fully-managed PostgreSQL database service.

安装 Python 包:

pip install langchain-google-cloud-sql-pg

查看 使用示例

from langchain_google_cloud_sql_pg import PostgresLoader # PostgresEngine also available

云存储

Cloud Storage is a managed service for storing unstructured data.

使用GCS依赖项安装:

pip install langchain-google-community[gcs]

从目录或特定文件加载:

查看 目录使用示例

from langchain_google_community import GCSDirectoryLoader
API 参考:GCSDirectoryLoader

查看 文件使用示例

from langchain_google_community import GCSFileLoader
API 参考:GCSFileLoader

云视觉加载器

使用 Google Cloud Vision API 加载数据。

安装时包含视觉依赖项:

pip install langchain-google-community[vision]
from langchain_google_community.vision import CloudVisionLoader
API 参考:CloudVisionLoader

适用于Oracle工作负载的El Carro

Google El Carro Oracle Operator runs Oracle databases in Kubernetes.

安装 Python 包:

pip install langchain-google-el-carro

查看 使用示例

from langchain_google_el_carro import ElCarroLoader

Firestore(原生模式)

Google Cloud Firestore is a NoSQL document database.

安装 Python 包:

pip install langchain-google-firestore

查看 使用示例

from langchain_google_firestore import FirestoreLoader

Firestore(数据存储模式)

Google Cloud Firestore in Datastore mode.

安装 Python 包:

pip install langchain-google-datastore

查看 使用示例

from langchain_google_datastore import DatastoreLoader

Redis内存数据库

Google Cloud Memorystore for Redis is a fully managed Redis service.

安装 Python 包:

pip install langchain-google-memorystore-redis

查看 使用示例

from langchain_google_memorystore_redis import MemorystoreDocumentLoader

跨度

Google Cloud Spanner is a fully managed, globally distributed relational database service.

安装 Python 包:

pip install langchain-google-spanner

查看 使用示例

from langchain_google_spanner import SpannerLoader

Speech-to-Text

Google Cloud Speech-to-Text transcribes audio files.

安装时包含语音转文字依赖项:

pip install langchain-google-community[speech]

查看 使用示例和授权说明

from langchain_google_community import SpeechToTextLoader
API 参考:SpeechToTextLoader

文档转换器

使用 Google Cloud 服务转换文档。

文档智能

Google Cloud Document AI is a Google Cloud service that transforms unstructured data from documents into structured data, making it easier to understand, analyze, and consume.

我们需要设置一个 GCS 存储桶并创建您自己的 OCR 处理器 GCS_OUTPUT_PATH 应该是 GCS 上的一个文件夹路径(以 gs:// 开头) 并且处理器名称应类似于 projects/PROJECT_NUMBER/locations/LOCATION/processors/PROCESSOR_ID。 我们可以通过编程方式获取它,也可以从 Google Cloud Console 的 Prediction endpoint 选项卡中的 Processor details 部分复制。

pip install langchain-google-community[docai]

查看一个 使用示例

from langchain_core.document_loaders.blob_loaders import Blob
from langchain_google_community import DocAIParser
API 参考:Blob |DocAIParser

谷歌翻译

Google Translate is a multilingual neural machine translation service developed by Google to translate text, documents and websites from one language into another.

GoogleTranslateTransformer 允许您使用 Google Cloud Translation API 翻译文本和 HTML。

首先,我们需要安装带有翻译依赖项的 langchain-google-community

pip install langchain-google-community[translate]

查看 使用示例和授权说明

from langchain_google_community import GoogleTranslateTransformer

向量存储

使用 Google Cloud 数据库和 Vertex AI 向量搜索来存储和搜索向量。

PostgreSQL的AlloyDB

Google Cloud AlloyDB is a fully managed relational database service that offers high performance, seamless integration, and impressive scalability on Google Cloud. AlloyDB is 100% compatible with PostgreSQL.

安装 Python 包:

pip install langchain-google-alloydb-pg

查看 使用示例

from langchain_google_alloydb_pg import AlloyDBVectorStore # AlloyDBEngine also available

Google Cloud BigQuery, BigQuery is a serverless and cost-effective enterprise data warehouse in Google Cloud.

Google Cloud BigQuery Vector Search BigQuery vector search lets you use GoogleSQL to do semantic search, using vector indexes for fast but approximate results, or using brute force for exact results.

It can calculate Euclidean or Cosine distance. With LangChain, we default to use Euclidean distance.

我们需要安装几个 Python 包。

pip install google-cloud-bigquery

查看 使用示例

# Note: BigQueryVectorSearch might be in langchain or langchain_community depending on version
# Check imports in the usage example.
from langchain.vectorstores import BigQueryVectorSearch # Or langchain_community.vectorstores

Redis内存数据库

Vector store using Memorystore for Redis.

安装 Python 包:

pip install langchain-google-memorystore-redis

查看 使用示例

from langchain_google_memorystore_redis import RedisVectorStore

跨度

Vector store using Cloud Spanner.

安装 Python 包:

pip install langchain-google-spanner

查看 使用示例

from langchain_google_spanner import SpannerVectorStore

Firestore(原生模式)

Vector store using Firestore.

安装 Python 包:

pip install langchain-google-firestore

查看 使用示例

from langchain_google_firestore import FirestoreVectorStore

适用于 MySQL 的 Cloud SQL

Vector store using Cloud SQL for MySQL.

安装 Python 包:

pip install langchain-google-cloud-sql-mysql

查看 使用示例

from langchain_google_cloud_sql_mysql import MySQLVectorStore # MySQLEngine also available

用于 PostgreSQL 的 Cloud SQL

Vector store using Cloud SQL for PostgreSQL.

安装 Python 包:

pip install langchain-google-cloud-sql-pg

查看 使用示例

from langchain_google_cloud_sql_pg import PostgresVectorStore # PostgresEngine also available

Google Cloud Vertex AI Vector Search from Google Cloud, formerly known as Vertex AI Matching Engine, provides the industry's leading high-scale low latency vector database. These vector databases are commonly referred to as vector similarity-matching or an approximate nearest neighbor (ANN) service.

安装 Python 包:

pip install langchain-google-vertexai

查看一个 使用示例

from langchain_google_vertexai import VectorSearchVectorStore
使用DataStore后端

Vector search using Datastore for document storage.

查看 使用示例

from langchain_google_vertexai import VectorSearchVectorStoreDatastore
使用GCS后端

Alias for VectorSearchVectorStore storing documents/index in GCS.

from langchain_google_vertexai import VectorSearchVectorStoreGCS

检索器

使用 Google Cloud 服务检索信息。

Build generative AI powered search engines using Vertex AI Search. from Google Cloud allows developers to quickly build generative AI powered search engines for customers and employees.

查看一个 使用示例

注意:GoogleVertexAISearchRetriever 已弃用。请从 langchain-google-community 开始使用以下组件。

安装 google-cloud-discoveryengine 包以获得底层访问权限。

pip install google-cloud-discoveryengine langchain-google-community
VertexAIMultiTurnSearchRetriever
from langchain_google_community import VertexAIMultiTurnSearchRetriever
VertexAISearchRetriever
# Note: The example code shows VertexAIMultiTurnSearchRetriever, confirm if VertexAISearchRetriever is separate or related.
# Assuming it might be related or a typo in the original doc:
from langchain_google_community import VertexAISearchRetriever # Verify class name if needed
VertexAISearchSummaryTool
from langchain_google_community import VertexAISearchSummaryTool

文档AI仓库

Search, store, and manage documents using Document AI Warehouse.

注意: GoogleDocumentAIWarehouseRetriever(来自 langchain)已弃用。请使用 DocumentAIWarehouseRetriever 来自 langchain-google-community

需要安装相关的 Document AI 包(请参阅具体文档)。

pip install langchain-google-community # Add specific docai dependencies if needed
from langchain_google_community.documentai_warehouse import DocumentAIWarehouseRetriever

工具

集成代理与各种Google服务。

Text-to-Speech

Google Cloud Text-to-Speech is a Google Cloud service that enables developers to synthesize natural-sounding speech with 100+ voices, available in multiple languages and variants. It applies DeepMind's groundbreaking research in WaveNet and Google's powerful neural networks to deliver the highest fidelity possible.

安装所需包:

pip install google-cloud-text-to-speech langchain-google-community

查看 使用示例和授权说明

from langchain_google_community import TextToSpeechTool
API 参考:TextToSpeechTool

Google Drive

用于与 Google Drive 交互的工具。

安装所需包:

pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib langchain-googledrive

查看 使用示例和授权说明

from langchain_googledrive.utilities.google_drive import GoogleDriveAPIWrapper
from langchain_googledrive.tools.google_drive.tool import GoogleDriveSearchTool

谷歌财经

查询财务数据。需要 google-search-results 个包和 SerpApi 密钥。

pip install google-search-results langchain-community # Requires langchain-community

查看 使用示例和授权说明

from langchain_community.tools.google_finance import GoogleFinanceQueryRun
from langchain_community.utilities.google_finance import GoogleFinanceAPIWrapper

谷歌职位

查询职位列表。需要 google-search-results 个包和 SerpApi 密钥。

pip install google-search-results langchain-community # Requires langchain-community

查看 使用示例和授权说明

from langchain_community.tools.google_jobs import GoogleJobsQueryRun
# Note: Utilities might be shared, e.g., GoogleFinanceAPIWrapper was listed, verify correct utility
# from langchain_community.utilities.google_jobs import GoogleJobsAPIWrapper # If exists

谷歌Lens

执行视觉搜索。需要 google-search-results 个软件包和 SerpApi 密钥。

pip install google-search-results langchain-community # Requires langchain-community

查看 使用示例和授权说明

from langchain_community.tools.google_lens import GoogleLensQueryRun
from langchain_community.utilities.google_lens import GoogleLensAPIWrapper

谷歌地点

搜索地点信息。需要 googlemaps 个包和一个 Google Maps API 密钥。

pip install googlemaps langchain # Requires base langchain

查看 使用示例和授权说明

# Note: GooglePlacesTool might be in langchain or langchain_community depending on version
from langchain.tools import GooglePlacesTool # Or langchain_community.tools
API 参考:GooglePlacesTool

谷歌学术

搜索学术论文。需要 google-search-results 个包和 SerpApi 密钥。

pip install google-search-results langchain-community # Requires langchain-community

查看 使用示例和授权说明

from langchain_community.tools.google_scholar import GoogleScholarQueryRun
from langchain_community.utilities.google_scholar import GoogleScholarAPIWrapper

使用 Google 自定义搜索引擎 (CSE) 执行网络搜索。需要 GOOGLE_API_KEYGOOGLE_CSE_ID

安装 langchain-google-community:

pip install langchain-google-community

Wrapper:

from langchain_google_community import GoogleSearchAPIWrapper

Tools:

from langchain_community.tools import GoogleSearchRun, GoogleSearchResults

代理加载:

from langchain.agents import load_tools
tools = load_tools(["google-search"])
API 参考:load_tools

查看 详细笔记本

查询 Google 趋势数据。需要 google-search-results 个包和 SerpApi 密钥。

pip install google-search-results langchain-community # Requires langchain-community

查看 使用示例和授权说明

from langchain_community.tools.google_trends import GoogleTrendsQueryRun
from langchain_community.utilities.google_trends import GoogleTrendsAPIWrapper

工具包

特定 Google 服务的工具集合。

GMail

Google Gmail is a free email service provided by Google. This toolkit works with emails through the Gmail API.

pip install langchain-google-community[gmail]

查看 使用示例和授权说明

# Load the whole toolkit
from langchain_google_community import GmailToolkit

# Or use individual tools
from langchain_google_community.gmail.create_draft import GmailCreateDraft
from langchain_google_community.gmail.get_message import GmailGetMessage
from langchain_google_community.gmail.get_thread import GmailGetThread
from langchain_google_community.gmail.search import GmailSearch
from langchain_google_community.gmail.send_message import GmailSendMessage

存储

使用 Google Cloud 数据库存储对话历史记录。

PostgreSQL的AlloyDB

Chat memory using AlloyDB.

安装 Python 包:

pip install langchain-google-alloydb-pg

查看 使用示例

from langchain_google_alloydb_pg import AlloyDBChatMessageHistory # AlloyDBEngine also available

用于 PostgreSQL 的 Cloud SQL

Chat memory using Cloud SQL for PostgreSQL.

安装 Python 包:

pip install langchain-google-cloud-sql-pg

查看 使用示例

from langchain_google_cloud_sql_pg import PostgresChatMessageHistory # PostgresEngine also available

适用于 MySQL 的 Cloud SQL

Chat memory using Cloud SQL for MySQL.

安装 Python 包:

pip install langchain-google-cloud-sql-mysql

查看 使用示例

from langchain_google_cloud_sql_mysql import MySQLChatMessageHistory # MySQLEngine also available

适用于 SQL Server 的 Cloud SQL

Chat memory using Cloud SQL for SQL Server.

安装 Python 包:

pip install langchain-google-cloud-sql-mssql

查看 使用示例

from langchain_google_cloud_sql_mssql import MSSQLChatMessageHistory # MSSQLEngine also available

跨度

Chat memory using Cloud Spanner.

安装 Python 包:

pip install langchain-google-spanner

查看 使用示例

from langchain_google_spanner import SpannerChatMessageHistory

Redis内存数据库

Chat memory using Memorystore for Redis.

安装 Python 包:

pip install langchain-google-memorystore-redis

查看 使用示例

from langchain_google_memorystore_redis import MemorystoreChatMessageHistory

Bigtable

Chat memory using Cloud Bigtable.

安装 Python 包:

pip install langchain-google-bigtable

查看 使用示例

from langchain_google_bigtable import BigtableChatMessageHistory

Firestore(原生模式)

Chat memory using Firestore.

安装 Python 包:

pip install langchain-google-firestore

查看 使用示例

from langchain_google_firestore import FirestoreChatMessageHistory

Firestore(数据存储模式)

Chat memory using Firestore in Datastore mode.

安装 Python 包:

pip install langchain-google-datastore

查看 使用示例

from langchain_google_datastore import DatastoreChatMessageHistory

El Carro:Kubernetes的Oracle操作员

Chat memory using Oracle databases run via El Carro.

安装 Python 包:

pip install langchain-google-el-carro

查看 使用示例

from langchain_google_el_carro import ElCarroChatMessageHistory

回调

跟踪大型语言模型/聊天模型的使用情况。

Vertex AI 回调处理程序

Callback Handler that tracks VertexAI usage info.

需要 langchain-google-vertexai

from langchain_google_vertexai.callbacks import VertexAICallbackHandler

评估器

使用 Vertex AI 评估模型输出。

需要 langchain-google-vertexai

VertexPairWiseStringEvaluator

Pair-wise evaluation using Vertex AI models.

from langchain_google_vertexai.evaluators.evaluation import VertexPairWiseStringEvaluator

VertexStringEvaluator

Evaluate a single prediction string using Vertex AI models.

# Note: Original doc listed VertexPairWiseStringEvaluator twice. Assuming this class exists.
from langchain_google_vertexai.evaluators.evaluation import VertexStringEvaluator # Verify class name if needed

其他谷歌产品

除了核心云平台之外,与各种 Google 服务的集成。

文档加载器

Google Drive

Google Drive file storage. Currently supports Google Docs.

使用驱动依赖项安装:

pip install langchain-google-community[drive]

查看 使用示例和授权说明

from langchain_google_community import GoogleDriveLoader
API 参考:GoogleDriveLoader

向量存储

ScaNN (本地索引)

Google ScaNN (Scalable Nearest Neighbors) is a python package.

ScaNN is a method for efficient vector similarity search at scale.

ScaNN includes search space pruning and quantization for Maximum Inner Product Search and also supports other distance functions such as Euclidean distance. The implementation is optimized for x86 processors with AVX2 support. See its Google Research github for more details.

安装 scann 包:

pip install scann langchain-community # Requires langchain-community

查看一个 使用示例

from langchain_community.vectorstores import ScaNN
API 参考:ScaNN

检索器

Google Drive

从 Google Drive 检索文档。

安装所需包:

pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib langchain-googledrive

查看 使用示例和授权说明

from langchain_googledrive.retrievers import GoogleDriveRetriever

工具

Google Drive

用于与 Google Drive 交互的工具。

安装所需包:

pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib langchain-googledrive

查看 使用示例和授权说明

from langchain_googledrive.utilities.google_drive import GoogleDriveAPIWrapper
from langchain_googledrive.tools.google_drive.tool import GoogleDriveSearchTool

谷歌财经

查询财务数据。需要 google-search-results 个包和 SerpApi 密钥。

pip install google-search-results langchain-community # Requires langchain-community

查看 使用示例和授权说明

from langchain_community.tools.google_finance import GoogleFinanceQueryRun
from langchain_community.utilities.google_finance import GoogleFinanceAPIWrapper

谷歌职位

查询职位列表。需要 google-search-results 个包和 SerpApi 密钥。

pip install google-search-results langchain-community # Requires langchain-community

查看 使用示例和授权说明

from langchain_community.tools.google_jobs import GoogleJobsQueryRun
# Note: Utilities might be shared, e.g., GoogleFinanceAPIWrapper was listed, verify correct utility
# from langchain_community.utilities.google_jobs import GoogleJobsAPIWrapper # If exists

谷歌Lens

执行视觉搜索。需要 google-search-results 个软件包和 SerpApi 密钥。

pip install google-search-results langchain-community # Requires langchain-community

查看 使用示例和授权说明

from langchain_community.tools.google_lens import GoogleLensQueryRun
from langchain_community.utilities.google_lens import GoogleLensAPIWrapper

谷歌地点

搜索地点信息。需要 googlemaps 个包和一个 Google Maps API 密钥。

pip install googlemaps langchain # Requires base langchain

查看 使用示例和授权说明

# Note: GooglePlacesTool might be in langchain or langchain_community depending on version
from langchain.tools import GooglePlacesTool # Or langchain_community.tools
API 参考:GooglePlacesTool

谷歌学术

搜索学术论文。需要 google-search-results 个包和 SerpApi 密钥。

pip install google-search-results langchain-community # Requires langchain-community

查看 使用示例和授权说明

from langchain_community.tools.google_scholar import GoogleScholarQueryRun
from langchain_community.utilities.google_scholar import GoogleScholarAPIWrapper

谷歌搜索

使用 Google 自定义搜索引擎 (CSE) 执行网络搜索。需要 GOOGLE_API_KEYGOOGLE_CSE_ID

安装 langchain-google-community:

pip install langchain-google-community

Wrapper:

from langchain_google_community import GoogleSearchAPIWrapper

Tools:

from langchain_community.tools import GoogleSearchRun, GoogleSearchResults

代理加载:

from langchain.agents import load_tools
tools = load_tools(["google-search"])
API 参考:load_tools

查看 详细笔记本

查询 Google 趋势数据。需要 google-search-results 个包和 SerpApi 密钥。

pip install google-search-results langchain-community # Requires langchain-community

查看 使用示例和授权说明

from langchain_community.tools.google_trends import GoogleTrendsQueryRun
from langchain_community.utilities.google_trends import GoogleTrendsAPIWrapper

工具包

GMail

Google Gmail is a free email service provided by Google. This toolkit works with emails through the Gmail API.

pip install langchain-google-community[gmail]

查看 使用示例和授权说明

# Load the whole toolkit
from langchain_google_community import GmailToolkit

# Or use individual tools
from langchain_google_community.gmail.create_draft import GmailCreateDraft
from langchain_google_community.gmail.get_message import GmailGetMessage
from langchain_google_community.gmail.get_thread import GmailGetThread
from langchain_google_community.gmail.search import GmailSearch
from langchain_google_community.gmail.send_message import GmailSendMessage

聊天加载器

GMail

Load chat history from Gmail threads.

使用GMail依赖项安装:

pip install langchain-google-community[gmail]

查看 使用示例和授权说明

from langchain_google_community import GMailLoader
API 参考:GMailLoader

第三方集成

通过第三方API访问Google服务。

SearchApi

SearchApi provides API access to Google search, YouTube, etc. Requires langchain-community.

查看 使用示例和授权说明

from langchain_community.utilities import SearchApiAPIWrapper
API 参考:SearchApiAPIWrapper

SerpApi

SerpApi provides API access to Google search results. Requires langchain-community.

查看 使用示例和授权说明

from langchain_community.utilities import SerpAPIWrapper
API 参考:SerpAPIWrapper

Serper.dev

Google Serper provides API access to Google search results. Requires langchain-community.

查看 使用示例和授权说明

from langchain_community.utilities import GoogleSerperAPIWrapper

YouTube

YouTube搜索工具

Search YouTube videos without the official API. Requires youtube_search package.

pip install youtube_search langchain # Requires base langchain

查看一个 使用示例

# Note: YouTubeSearchTool might be in langchain or langchain_community
from langchain.tools import YouTubeSearchTool # Or langchain_community.tools
API 参考:YouTubeSearchTool

YouTube音频加载器

Download audio from YouTube videos. Requires yt_dlp, pydub, librosa.

pip install yt_dlp pydub librosa langchain-community # Requires langchain-community

查看 使用示例和授权说明

from langchain_community.document_loaders.blob_loaders.youtube_audio import YoutubeAudioLoader
# Often used with whisper parsers:
# from langchain_community.document_loaders.parsers import OpenAIWhisperParser, OpenAIWhisperParserLocal

YouTube字幕加载器

Load video transcripts. Requires youtube-transcript-api.

pip install youtube-transcript-api langchain-community # Requires langchain-community

查看一个 使用示例

from langchain_community.document_loaders import YoutubeLoader
API 参考:YoutubeLoader