使用Claude和Gemini直接从PDF提取和处理信息
中级
这是一个AI领域的自动化工作流,包含 11 个节点。主要使用 Set, GoogleDrive, HttpRequest, ManualTrigger, ExtractFromFile 等节点,结合人工智能技术实现智能自动化。 使用Claude和Gemini直接从PDF提取和处理信息
前置要求
- •Google Drive API 凭证
- •可能需要目标 API 的认证凭证
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "f4f5d195bb2162a0972f737368404b18be694648d365d6c6771d7b4909d28167"
},
"nodes": [
{
"id": "b6cd232e-e82e-457b-9f03-c010b3eba148",
"name": "当点击'测试工作流'时",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-40,
0
],
"parameters": {},
"typeVersion": 1
},
{
"id": "2b734806-e3c0-4552-a491-54ca846ed3ac",
"name": "从文件中提取",
"type": "n8n-nodes-base.extractFromFile",
"position": [
620,
0
],
"parameters": {
"options": {},
"operation": "binaryToPropery"
},
"typeVersion": 1
},
{
"id": "2c199499-cc4f-405c-8560-765500b7acba",
"name": "Google Drive",
"type": "n8n-nodes-base.googleDrive",
"position": [
420,
0
],
"parameters": {
"fileId": {
"__rl": true,
"mode": "list",
"value": "18Ac2xorxirIBm9FNFDDB5aVUSPBCCg1U",
"cachedResultUrl": "https://drive.google.com/file/d/18Ac2xorxirIBm9FNFDDB5aVUSPBCCg1U/view?usp=drivesdk",
"cachedResultName": "Invoice-798FE2FA-0004.pdf"
},
"options": {},
"operation": "download"
},
"credentials": {
"googleDriveOAuth2Api": {
"id": "AUEpxwlqBJghNMtb",
"name": "Google Drive account"
}
},
"typeVersion": 3
},
{
"id": "e3031c0c-f059-4f30-9684-10014a277d55",
"name": "调用具有 PDF 功能的 Gemini 2.0 Flash",
"type": "n8n-nodes-base.httpRequest",
"position": [
880,
220
],
"parameters": {
"url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp:generateContent",
"method": "POST",
"options": {},
"jsonBody": "={\n \"contents\": [\n {\n \"parts\": [\n {\n \"inline_data\": {\n \"mime_type\": \"application/pdf\",\n \"data\": \"{{ $json.data }}\"\n }\n },\n {\n \"text\": \"{{ $('Define Prompt').item.json.prompt }}\"\n }\n ]\n }\n ]\n}",
"sendBody": true,
"specifyBody": "json",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "googlePalmApi"
},
"credentials": {
"anthropicApi": {
"id": "eOt6Ois0jSizRFMJ",
"name": "Anthropic Mira Account"
},
"googlePalmApi": {
"id": "IQrjvfoUd5LUft3b",
"name": "Google Gemini(PaLM) Api account"
}
},
"typeVersion": 4.2
},
{
"id": "135df716-32a1-47e8-9ed8-30c830b803d6",
"name": "调用具有 PDF 功能的 Claude 3.5 Sonnet",
"type": "n8n-nodes-base.httpRequest",
"position": [
880,
-140
],
"parameters": {
"url": "https://api.anthropic.com/v1/messages",
"method": "POST",
"options": {},
"jsonBody": "={\n \"model\": \"claude-3-5-sonnet-20241022\",\n \"max_tokens\": 1024,\n \"messages\": [{\n \"role\": \"user\",\n \"content\": [{\n \"type\": \"document\",\n \"source\": {\n \"type\": \"base64\",\n \"media_type\": \"application/pdf\",\n \"data\": \"{{$json.data}}\"\n }\n },\n {\n \"type\": \"text\",\n \"text\": \"{{ $('Define Prompt').item.json.prompt }}\"\n }]\n }]\n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"authentication": "predefinedCredentialType",
"headerParameters": {
"parameters": [
{
"name": "anthropic-version",
"value": "2023-06-01"
},
{
"name": "content-type",
"value": "application/json"
}
]
},
"nodeCredentialType": "anthropicApi"
},
"credentials": {
"anthropicApi": {
"id": "eOt6Ois0jSizRFMJ",
"name": "Anthropic Mira Account"
}
},
"typeVersion": 4.2
},
{
"id": "5b8994d1-4bfd-4776-84ac-b3141aca6378",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-700,
-280
],
"parameters": {
"color": 7,
"width": 601,
"height": 585,
"content": "## 工作流:使用 Claude 3.5 Sonnet 或 Gemini 2.0 Flash 从 PDF 提取数据"
},
"typeVersion": 1
},
{
"id": "616241a9-6199-406b-88dc-0afc7d974250",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
820,
60
],
"parameters": {
"color": 5,
"width": 320,
"height": 360,
"content": "您可以通过添加以下内容将结果输出为 JSON:"
},
"typeVersion": 1
},
{
"id": "bbac8d3d-d68f-4aa2-a41a-b06f7de2317b",
"name": "定义提示",
"type": "n8n-nodes-base.set",
"position": [
180,
0
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "dba23ef5-95df-496a-8e24-c7c1544533d2",
"name": "prompt",
"type": "string",
"value": "Extract the VAT numbers for each country"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "3c2e7265-76e5-4911-a950-7e6b0c89ec5a",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
820,
-200
],
"parameters": {
"color": 5,
"width": 320,
"height": 240,
"content": "您可以使用[预填充响应格式](https://docs.anthropic.com/en/docs/test-and-evaluate/strengthen-guardrails/increase-consistency#prefill-claudes-response)强制 Claude 输出 JSON"
},
"typeVersion": 1
},
{
"id": "f2b46305-5200-486e-ad4d-ecc0d2a14314",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
380,
-120
],
"parameters": {
"color": 5,
"width": 380,
"height": 280,
"content": "这两个步骤首先下载 PDF 文件,然后将其转换为 base64"
},
"typeVersion": 1
},
{
"id": "e5dff70f-b55a-4c23-9025-765a7cf19c4a",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
120,
-120
],
"parameters": {
"color": 5,
"width": 220,
"height": 280,
"content": "此提示用于 Gemini 和 Claude 的调用中,以定义应提取和处理哪些信息"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Google Drive": {
"main": [
[
{
"node": "Extract from File",
"type": "main",
"index": 0
}
]
]
},
"Define Prompt": {
"main": [
[
{
"node": "Google Drive",
"type": "main",
"index": 0
}
]
]
},
"Extract from File": {
"main": [
[
{
"node": "Call Claude 3.5 Sonnet with PDF Capabilities",
"type": "main",
"index": 0
},
{
"node": "Call Gemini 2.0 Flash with PDF Capabilities",
"type": "main",
"index": 0
}
]
]
},
"When clicking 'Test workflow'": {
"main": [
[
{
"node": "Define Prompt",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 人工智能
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
从Postgres导出AI代理对话日志到Google Sheets
从Postgres导出AI代理对话日志到Google Sheets
Set
Postgres
Http Request
+5
23 节点Agent Studio
工程
转录评估器
使用DeepGram和GPT-4o的音频对话分析与可视化
Set
Code
Html
+15
54 节点RealSimple Solutions
人工智能
使用 Google Sheets 和 OpenRouter 对法律文档进行 LLM 性能基准测试
使用 Google Sheets 和 OpenRouter 对法律文档进行 LLM 性能基准测试
If
Set
Limit
+11
23 节点Adam Janes
人工智能
构建基于n8n和Gemini AI图像编辑的图像修复服务
构建基于n8n和Gemini AI图像编辑的图像修复服务
Set
Split Out
Google Drive
+5
17 节点Jimleuk
设计
使用GraphRAG与PDF/MD/文本文件对话(无需向量存储)
使用GraphRAG与PDF/MD/文本文件对话(无需向量存储)
Set
Switch
Google Drive
+10
20 节点InfraNodus
客户支持
🦙👁️👁️ 通过比较找到最佳本地 Ollama 视觉模型
使用 Google Docs 比较本地 Ollama 视觉模型进行图像分析
Set
Split Out
Google Docs
+6
19 节点Joseph LePage
人工智能
工作流信息
难度等级
中级
节点数量11
分类1
节点类型6
作者
Agent Studio
@agentstudioWe are a product studio that helps organizations leverage no-code and generative AI to automate internal processes and launch new digital products.
外部链接
在 n8n.io 查看 →
分享此工作流