与 Google Cloud、Google Gemini 和其他 Google 产品相关的所有功能。
- Google Generative AI (Gemini API & AI Studio):直接通过Gemini API访问Google Gemini模型。使用 Google AI Studio 进行快速原型设计,并快速开始使用
langchain-google-genai包。这通常是个人开发人员的最佳起点。 - Google Cloud (Vertex AI & other services):通过Google Cloud Platform访问Gemini模型、Vertex AI Model Garden和各种云服务(数据库、存储、文档AI等)。使用
langchain-google-vertexaipackage 和 Vertex AI 模型的特定软件包(例如langchain-google-cloud-sql-pg,langchain-google-community) 获取其他云服务。对于已经在使用 Google Cloud 或需要 MLOps、特定模型调整或企业支持等企业功能的开发人员来说,这是理想的选择。
有关差异的更多详细信息,请参阅 Google 关于从 Gemini API 迁移到 Vertex AI 的指南。
Gemini 模型和 Vertex AI 平台的集成包在
langchain-google 存储库。
您可以在 googleapis Github 组织和langchain-google-community包。
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 Image 对象。
嵌入模型
使用模型生成文本嵌入向量,例如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])
LLM
使用(旧版)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)
Google Cloud
通过 Vertex AI 和特定的云集成访问 Gemini 模型、Vertex AI Model Garden 和其他 Google Cloud 服务。
Vertex AI 模型需要langchain-google-vertexai包。其他服务可能需要其他软件包,例如langchain-google-community,langchain-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
访问聊天模型,例如Gemini通过 Vertex AI 平台。
请参阅使用示例。
from langchain_google_vertexai import ChatVertexAI
Anthropic on Vertex AI Model Garden上的 Anthropic
请参阅使用示例。
from langchain_google_vertexai.model_garden import ChatAnthropicVertex
Vertex AI Model Garden 上的 Llama
from langchain_google_vertexai.model_garden_maas.llama import VertexModelGardenLlama
Vertex AI Model Garden 上的 Mistral
from langchain_google_vertexai.model_garden_maas.mistral import VertexModelGardenMistral
来自 Hugging Face 的 Gemma 当地人
本地化
Gemma模型加载自HuggingFace.需要langchain-google-vertexai.
from langchain_google_vertexai.gemma import GemmaChatLocalHF
来自 Kaggle 的 Gemma 本地产品
本地化
Gemma模型加载自Kaggle.需要langchain-google-vertexai.
from langchain_google_vertexai.gemma import GemmaChatLocalKaggle
Gemma on Vertex AI Model Garden
需要
langchain-google-vertexai.
from langchain_google_vertexai.gemma import GemmaChatVertexAIModelGarden
Vertex AI 图像字幕
实现
Image Captioning model作为聊天。需要langchain-google-vertexai.
from langchain_google_vertexai.vision_models import VertexAIImageCaptioningChat
Vertex AI 图像编辑器
给定图像和提示,编辑图像。目前仅支持无遮罩编辑。需要
langchain-google-vertexai.
from langchain_google_vertexai.vision_models import VertexAIImageEditorChat
Vertex AI 图像生成器
从提示符生成图像。需要
langchain-google-vertexai.
from langchain_google_vertexai.vision_models import VertexAIImageGeneratorChat
Vertex AI 可视化 QnA
可视化 QnA 模型的聊天实现。需要
langchain-google-vertexai.
from langchain_google_vertexai.vision_models import VertexAIVisualQnAChat
LLM
您还可以使用(旧版)字符串输入、字符串输出 LLM 接口。
Vertex AI 模型园
访问Gemini和数百个 OSS 模型通过Vertex AI Model Garden服务。需要langchain-google-vertexai.
请参阅使用示例。
from langchain_google_vertexai import VertexAIModelGarden
来自 Hugging Face 的 Gemma 当地人
本地化
Gemma模型加载自HuggingFace.需要langchain-google-vertexai.
from langchain_google_vertexai.gemma import GemmaLocalHF
来自 Kaggle 的 Gemma 本地产品
本地化
Gemma模型加载自Kaggle.需要langchain-google-vertexai.
from langchain_google_vertexai.gemma import GemmaLocalKaggle
Gemma on Vertex AI Model Garden
需要
langchain-google-vertexai.
from langchain_google_vertexai.gemma import GemmaVertexAIModelGarden
Vertex AI 图像字幕
实现
Image Captioning model作为 LLM。需要langchain-google-vertexai.
from langchain_google_vertexai.vision_models import VertexAIImageCaptioning
嵌入模型
Vertex AI
使用 Vertex AI 上部署的模型生成嵌入。需要langchain-google-vertexai.
请参阅使用示例。
from langchain_google_vertexai import VertexAIEmbeddings
文档加载器
从各种 Google Cloud 来源加载文档。
AlloyDB PostgreSQL 版
Google Cloud AlloyDB 是一项完全托管的兼容 PostgreSQL 的数据库服务。
安装 python 包:
pip install langchain-google-alloydb-pg
请参阅使用示例。
from langchain_google_alloydb_pg import AlloyDBLoader # AlloyDBEngine also available
BigQuery 查询
Google Cloud BigQuery 是一个无服务器数据仓库。
使用 BigQuery 依赖项进行安装:
pip install langchain-google-community[bigquery]
请参阅使用示例。
from langchain_google_community import BigQueryLoader
Bigtable
Google Cloud Bigtable 是一项完全托管的 NoSQL 大数据数据库服务。
安装 python 包:
pip install langchain-google-bigtable
请参阅使用示例。
from langchain_google_bigtable import BigtableLoader
适用于 MySQL 的 Cloud SQL
Google Cloud SQL for MySQL 是一项完全托管的 MySQL 数据库服务。
安装 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 是一项完全托管的 SQL Server 数据库服务。
安装 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 是一项完全托管的 PostgreSQL 数据库服务。
安装 python 包:
pip install langchain-google-cloud-sql-pg
请参阅使用示例。
from langchain_google_cloud_sql_pg import PostgresLoader # PostgresEngine also available
云存储
Cloud Storage 是一种用于存储非结构化数据的托管服务。
使用 GCS 依赖项进行安装:
pip install langchain-google-community[gcs]
从目录或特定文件加载:
请参阅目录使用示例。
from langchain_google_community import GCSDirectoryLoader
请参阅文件使用示例。
from langchain_google_community import GCSFileLoader
Cloud Vision 加载程序
使用 Google Cloud Vision API 加载数据。
使用 Vision 依赖项进行安装:
pip install langchain-google-community[vision]
from langchain_google_community.vision import CloudVisionLoader
适用于 Oracle 工作负载的 El Carro
Google El Carro Oracle Operator 在 Kubernetes 中运行 Oracle 数据库。
安装 python 包:
pip install langchain-google-el-carro
请参阅使用示例。
from langchain_google_el_carro import ElCarroLoader
Firestore (本机模式)
Google Cloud Firestore 是一个 NoSQL 文档数据库。
安装 python 包:
pip install langchain-google-firestore
请参阅使用示例。
from langchain_google_firestore import FirestoreLoader
Firestore (数据存储模式)
安装 python 包:
pip install langchain-google-datastore
请参阅使用示例。
from langchain_google_datastore import DatastoreLoader
适用于 Redis 的内存存储
Google Cloud Memorystore for Redis 是一项完全托管的 Redis 服务。
安装 python 包:
pip install langchain-google-memorystore-redis
请参阅使用示例。
from langchain_google_memorystore_redis import MemorystoreDocumentLoader
扳手
Google Cloud Spanner 是一种完全托管的全球分布式关系数据库服务。
安装 python 包:
pip install langchain-google-spanner
请参阅使用示例。
from langchain_google_spanner import SpannerLoader
语音转文本
Google Cloud Speech-to-Text 转录音频文件。
使用 Speech-to-Text 依赖项进行安装:
pip install langchain-google-community[speech]
请参阅使用示例和授权说明。
from langchain_google_community import SpeechToTextLoader
文档转换器
使用 Google Cloud 服务转换文档。
文档 AI
Google Cloud Document AI 是一个 Google Cloud 将文档中的非结构化数据转换为结构化数据,使其更轻松的服务 来理解、分析和消费。
我们需要设置一个GCS存储桶并创建您自己的 OCR 处理器这GCS_OUTPUT_PATH应该是 GCS 上文件夹的路径(以gs://)
处理器名称应如下所示projects/PROJECT_NUMBER/locations/LOCATION/processors/PROCESSOR_ID.
我们可以通过编程方式获取它,也可以从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
谷歌翻译
Google 翻译是一种多语言神经机器 由 Google 开发的翻译服务,用于翻译文本、文档和网站 从一种语言到另一种语言。
这GoogleTranslateTransformer允许您使用 Google Cloud Translation API 翻译文本和 HTML。
首先,我们需要安装langchain-google-community与 translate 依赖项。
pip install langchain-google-community[translate]
请参阅使用示例和授权说明。
from langchain_google_community import GoogleTranslateTransformer
矢量存储
使用 Google Cloud 数据库和 Vertex AI Vector Search 存储和搜索矢量。
AlloyDB PostgreSQL 版
Google Cloud AlloyDB 是一项完全托管的关系数据库服务,可在 Google Cloud 上提供高性能、无缝集成和令人印象深刻的可扩展性。AlloyDB 与 PostgreSQL 100% 兼容。
安装 python 包:
pip install langchain-google-alloydb-pg
请参阅使用示例。
from langchain_google_alloydb_pg import AlloyDBVectorStore # AlloyDBEngine also available
BigQuery 矢量搜索
Google Cloud BigQuery、 BigQuery 是 Google Cloud 中一个无服务器且经济高效的企业数据仓库。
Google Cloud BigQuery 矢量搜索BigQuery 矢量搜索允许您使用 GoogleSQL 进行语义搜索,使用矢量索引获得快速但近似的结果,或使用蛮力获得精确结果。
它可以计算欧几里得或余弦距离。使用 LangChain 时,我们默认使用欧几里得距离。
我们需要安装几个 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 的内存存储
使用 Memorystore for Redis 的矢量存储。
安装 python 包:
pip install langchain-google-memorystore-redis
请参阅使用示例。
from langchain_google_memorystore_redis import RedisVectorStore
扳手
使用 Cloud Spanner 的矢量存储。
安装 python 包:
pip install langchain-google-spanner
请参阅使用示例。
from langchain_google_spanner import SpannerVectorStore
Firestore (本机模式)
使用 Firestore 的向量存储。
安装 python 包:
pip install langchain-google-firestore
请参阅使用示例。
from langchain_google_firestore import FirestoreVectorStore
适用于 MySQL 的 Cloud SQL
使用 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
使用 Cloud SQL for PostgreSQL 的矢量存储。
安装 python 包:
pip install langchain-google-cloud-sql-pg
请参阅使用示例。
from langchain_google_cloud_sql_pg import PostgresVectorStore # PostgresEngine also available
Vertex AI 矢量搜索
来自 Google Cloud 的 Google Cloud Vertex AI 矢量搜索, 以前称为
Vertex AI Matching Engine,提供业界领先的高规模 低延迟矢量数据库。这些向量数据库通常是 称为向量相似性匹配或近似最近邻 (ANN) 服务。
安装 python 包:
pip install langchain-google-vertexai
请参阅使用示例。
from langchain_google_vertexai import VectorSearchVectorStore
使用 DataStore 后端
使用 Datastore 进行矢量搜索以进行文档存储。
请参阅使用示例。
from langchain_google_vertexai import VectorSearchVectorStoreDatastore
使用 GCS 后端
别名
VectorSearchVectorStore在 GCS 中存储 documents/index。
from langchain_google_vertexai import VectorSearchVectorStoreGCS
Retriever
使用 Google Cloud 服务检索信息。
Vertex AI 搜索
使用 Vertex AI Search 构建生成式 AI 驱动的搜索引擎。 使开发人员能够为客户和员工快速构建生成式 AI 支持的搜索引擎。
请参阅使用示例。
注意:GoogleVertexAISearchRetriever已弃用。使用以下组件langchain-google-community.
安装google-cloud-discoveryenginepackage 进行底层访问。
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
VertexAISearch摘要工具
from langchain_google_community import VertexAISearchSummaryTool
文档 AI 仓库
使用 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 服务集成。
文本转语音
Google Cloud Text-to-Speech 是一项 Google Cloud 服务,使开发人员能够 使用 100+ 种语音合成听起来自然的语音,提供多种语言和变体。 它应用了 DeepMind 在 WaveNet 和 Google 强大的神经网络中的开创性研究 提供尽可能高的保真度。
安装所需的软件包:
pip install google-cloud-text-to-speech langchain-google-community
请参阅使用示例和授权说明。
from langchain_google_community import TextToSpeechTool
Google 云端硬盘
与 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-resultspackage 和 SerpApi key 的 API 密钥。
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 工作机会
查询职位列表。需要google-search-resultspackage 和 SerpApi key 的 API 密钥。
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
谷歌镜头
执行视觉搜索。需要google-search-resultspackage 和 SerpApi key 的 API 密钥。
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
Google 地方信息
搜索地点信息。需要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
谷歌学术
搜索学术论文。需要google-search-resultspackage 和 SerpApi key 的 API 密钥。
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 搜索
使用 Google 自定义搜索引擎 (CSE) 执行 Web 搜索。需要GOOGLE_API_KEY和GOOGLE_CSE_ID.
安装langchain-google-community:
pip install langchain-google-community
包装纸:
from langchain_google_community import GoogleSearchAPIWrapper
工具:
from langchain_community.tools import GoogleSearchRun, GoogleSearchResults
代理加载:
from langchain.agents import load_tools
tools = load_tools(["google-search"])
请参阅详细的笔记本。
Google 趋势
查询 Google Trends 数据。需要google-search-resultspackage 和 SerpApi key 的 API 密钥。
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 是 Google 提供的免费电子邮件服务。 此工具包通过
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 数据库存储对话历史记录。
AlloyDB PostgreSQL 版
使用 AlloyDB 的聊天内存。
安装 python 包:
pip install langchain-google-alloydb-pg
请参阅使用示例。
from langchain_google_alloydb_pg import AlloyDBChatMessageHistory # AlloyDBEngine also available
适用于 PostgreSQL 的 Cloud SQL
使用 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
使用 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
使用 Cloud SQL for SQL Server 的聊天内存。
安装 python 包:
pip install langchain-google-cloud-sql-mssql
请参阅使用示例。
from langchain_google_cloud_sql_mssql import MSSQLChatMessageHistory # MSSQLEngine also available
扳手
使用 Cloud Spanner 的聊天内存。
安装 python 包:
pip install langchain-google-spanner
请参阅使用示例。
from langchain_google_spanner import SpannerChatMessageHistory
适用于 Redis 的内存存储
使用 Memorystore for Redis 的聊天内存。
安装 python 包:
pip install langchain-google-memorystore-redis
请参阅使用示例。
from langchain_google_memorystore_redis import MemorystoreChatMessageHistory
Bigtable
使用 Cloud Bigtable 的聊天内存。
安装 python 包:
pip install langchain-google-bigtable
请参阅使用示例。
from langchain_google_bigtable import BigtableChatMessageHistory
Firestore (本机模式)
使用 Firestore 的聊天内存。
安装 python 包:
pip install langchain-google-firestore
请参阅使用示例。
from langchain_google_firestore import FirestoreChatMessageHistory
Firestore (数据存储模式)
在 Datastore 模式下使用 Firestore 的聊天内存。
安装 python 包:
pip install langchain-google-datastore
请参阅使用示例。
from langchain_google_datastore import DatastoreChatMessageHistory
El Carro:面向 Kubernetes 的 Oracle作员
使用通过 El Carro 运行的 Oracle 数据库的聊天内存。
安装 python 包:
pip install langchain-google-el-carro
请参阅使用示例。
from langchain_google_el_carro import ElCarroChatMessageHistory
回调
跟踪 LLM/Chat 模型的使用情况。
Vertex AI 回调处理程序
跟踪
VertexAI使用信息。
需要langchain-google-vertexai.
from langchain_google_vertexai.callbacks import VertexAICallbackHandler
评估员
使用 Vertex AI 评估模型输出。
需要langchain-google-vertexai.
VertexPairWiseStringEvaluator
使用 Vertex AI 模型进行成对评估。
from langchain_google_vertexai.evaluators.evaluation import VertexPairWiseStringEvaluator
VertexStringEvaluator (顶点字符串计算器)
使用 Vertex AI 模型评估单个预测字符串。
# Note: Original doc listed VertexPairWiseStringEvaluator twice. Assuming this class exists.
from langchain_google_vertexai.evaluators.evaluation import VertexStringEvaluator # Verify class name if needed
其他 Google 产品
与核心 Cloud Platform 之外的各种 Google 服务集成。
文档加载器
Google 云端硬盘
Google Drive 文件存储。目前支持
Google Docs.
使用 Drive 依赖项进行安装:
pip install langchain-google-community[drive]
请参阅使用示例和授权说明。
from langchain_google_community import GoogleDriveLoader
矢量存储
ScaNN (局部索引)
Google ScaNN(可扩展最近邻)是一个 python 包。
ScaNN是一种大规模高效向量相似性搜索的方法。
ScaNN包括 Maximum Inner 的搜索空间修剪和量化 Product Search 的 S 等,还支持其他距离功能,例如 欧几里得距离。该实施针对 x86 处理器进行了优化 支持 AVX2。有关更多详细信息,请参阅其 Google Research github。
安装scann包:
pip install scann langchain-community # Requires langchain-community
请参阅使用示例。
from langchain_community.vectorstores import ScaNN
Retriever
Google 云端硬盘
从 Google Drive 检索文档。
安装所需的软件包:
pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib langchain-googledrive
请参阅使用示例和授权说明。
from langchain_googledrive.retrievers import GoogleDriveRetriever
工具
Google 云端硬盘
与 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-resultspackage 和 SerpApi key 的 API 密钥。
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 工作机会
查询职位列表。需要google-search-resultspackage 和 SerpApi key 的 API 密钥。
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
谷歌镜头
执行视觉搜索。需要google-search-resultspackage 和 SerpApi key 的 API 密钥。
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
Google 地方信息
搜索地点信息。需要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
谷歌学术
搜索学术论文。需要google-search-resultspackage 和 SerpApi key 的 API 密钥。
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 搜索
使用 Google 自定义搜索引擎 (CSE) 执行 Web 搜索。需要GOOGLE_API_KEY和GOOGLE_CSE_ID.
安装langchain-google-community:
pip install langchain-google-community
包装纸:
from langchain_google_community import GoogleSearchAPIWrapper
工具:
from langchain_community.tools import GoogleSearchRun, GoogleSearchResults
代理加载:
from langchain.agents import load_tools
tools = load_tools(["google-search"])
请参阅详细的笔记本。
Google 趋势
查询 Google Trends 数据。需要google-search-resultspackage 和 SerpApi key 的 API 密钥。
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 是 Google 提供的免费电子邮件服务。 此工具包通过
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 公司
从 Gmail 会话加载聊天记录。
使用 GMail 依赖项进行安装:
pip install langchain-google-community[gmail]
请参阅使用示例和授权说明。
from langchain_google_community import GMailLoader
第三方集成
通过第三方 API 访问 Google 服务。
搜索 API
SearchApi 提供对 Google 搜索、YouTube 等的 API 访问。需要
langchain-community.
请参阅使用示例和授权说明。
from langchain_community.utilities import SearchApiAPIWrapper
SerpApi 的
SerpApi 提供对 Google 搜索结果的 API 访问。需要
langchain-community.
请参阅使用示例和授权说明。
from langchain_community.utilities import SerpAPIWrapper
Serper.dev
Google Serper 提供对 Google 搜索结果的 API 访问。需要
langchain-community.
请参阅使用示例和授权说明。
from langchain_community.utilities import GoogleSerperAPIWrapper
优酷
YouTube 搜索工具
搜索
YouTube没有官方 API 的视频。需要youtube_search包。
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
YouTube 音频加载器
从 YouTube 视频下载音频。需要
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 转录本加载器
加载视频脚本。需要
youtube-transcript-api.
pip install youtube-transcript-api langchain-community # Requires langchain-community
请参阅使用示例。
from langchain_community.document_loaders import YoutubeLoader