feat(Jina AI Node): Add Jina AI node (#15094)

This commit is contained in:
RomanDavydchuk
2025-05-09 12:12:49 +03:00
committed by GitHub
parent 4824798db0
commit e9ef193eaa
13 changed files with 1333 additions and 0 deletions

View File

@@ -0,0 +1,109 @@
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
import nock from 'nock';
import deepResearchResult from './fixtures/deepResearch.json';
import readResult from './fixtures/read.json';
import searchResult from './fixtures/search.json';
describe('JinaAI Node', () => {
const credentials = {
jinaAiApi: {
apiKey: 'API-KEY',
},
};
describe('Reader -> Read', () => {
const jinaAiNock = nock('https://r.jina.ai');
beforeAll(() => {
jinaAiNock.get('/https://first.com/some/path').times(2).reply(200, readResult);
jinaAiNock
.get('/https://second.com/other')
.query({
foo: 'bar',
})
.matchHeader('X-Return-Format', 'markdown')
.matchHeader('X-Target-Selector', 'article')
.matchHeader('X-Remove-Selector', '.ad')
.matchHeader('X-With-Generated-Alt', 'true')
.matchHeader('X-Wait-For-Selector', '#posts')
.reply(200, readResult);
});
afterAll(() => jinaAiNock.done());
new NodeTestHarness().setupTests({
credentials,
workflowFiles: ['read.workflow.json'],
});
});
describe('Reader -> Search', () => {
const jinaAiNock = nock('https://s.jina.ai');
beforeAll(() => {
jinaAiNock
.get('/')
.query({
q: 'Jina AI',
})
.times(2)
.reply(200, searchResult);
jinaAiNock
.get('/')
.query({
q: 'Jina AI',
page: 2,
})
.matchHeader('X-Return-Format', 'markdown')
.matchHeader('X-Site', 'jina.ai')
.reply(200, searchResult);
});
afterAll(() => jinaAiNock.done());
new NodeTestHarness().setupTests({
credentials,
workflowFiles: ['search.workflow.json'],
});
});
describe('Research -> Deep Research', () => {
const jinaAiNock = nock('https://deepsearch.jina.ai');
beforeAll(() => {
jinaAiNock
.post('/v1/chat/completions', {
messages: [
{
role: 'user',
content: 'Describe the latest features in Jina AI',
},
],
})
.times(2)
.reply(200, deepResearchResult);
jinaAiNock
.post('/v1/chat/completions', {
messages: [
{
role: 'user',
content: 'Describe the latest features in Jina AI',
},
],
max_returned_urls: 5,
boost_hostnames: ['jina.ai'],
bad_hostnames: ['medium.com'],
only_hostnames: ['jina.ai', 'github.com'],
})
.reply(200, deepResearchResult);
});
afterAll(() => jinaAiNock.done());
new NodeTestHarness().setupTests({
credentials,
workflowFiles: ['deepResearch.workflow.json'],
});
});
});

View File

@@ -0,0 +1,226 @@
{
"name": "Jina AI -> Research -> Deep Research",
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [-240, 260],
"id": "8a73e8c0-c2b8-4933-98e1-a2577b9f4902",
"name": "When clicking Test workflow"
},
{
"parameters": {
"resource": "research",
"researchQuery": "Describe the latest features in Jina AI",
"simplify": false,
"options": {},
"requestOptions": {}
},
"type": "n8n-nodes-base.jinaAi",
"typeVersion": 1,
"position": [-20, 60],
"id": "cf8f337f-841c-4715-9ecd-d1b877d5b098",
"name": "No options",
"credentials": {
"jinaAiApi": {
"id": "8ph5AE62dQFfqkLx",
"name": "Jina AI account"
}
}
},
{
"parameters": {
"resource": "research",
"researchQuery": "Describe the latest features in Jina AI",
"simplify": false,
"options": {
"maxReturnedSources": 5,
"prioritizeSources": "jina.ai",
"excludeSources": "medium.com",
"siteFilter": "jina.ai, github.com"
},
"requestOptions": {}
},
"type": "n8n-nodes-base.jinaAi",
"typeVersion": 1,
"position": [-20, 260],
"id": "c353f860-0bc4-453f-a620-2f054721f52a",
"name": "With options",
"credentials": {
"jinaAiApi": {
"id": "8ph5AE62dQFfqkLx",
"name": "Jina AI account"
}
}
},
{
"parameters": {
"resource": "research",
"researchQuery": "Describe the latest features in Jina AI",
"options": {},
"requestOptions": {}
},
"type": "n8n-nodes-base.jinaAi",
"typeVersion": 1,
"position": [-20, 460],
"id": "91269e77-35b1-4bf5-b0b6-8876e0126b36",
"name": "Simplified",
"credentials": {
"jinaAiApi": {
"id": "8ph5AE62dQFfqkLx",
"name": "Jina AI account"
}
}
}
],
"pinData": {
"No options": [
{
"json": {
"id": "123",
"object": "chat.completion",
"created": 1746186539,
"system_fingerprint": "fp_123",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"type": "text",
"annotations": [
{
"type": "url_citation",
"url_citation": {
"title": "Lorem ipsum dolor sit amet",
"exactQuote": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"url": "https://some.referenced.site.com/article",
"dateTime": "Aug 30, 2024"
}
}
]
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 456,
"total_tokens": 579
},
"visitedURLs": ["https://first.com/some/path", "https://second.com/?foo=bar"],
"readURLs": [
"https://example.com",
"https://example.com/2",
"https://some.other.site.com/path"
],
"numURLs": 5
}
}
],
"With options": [
{
"json": {
"id": "123",
"object": "chat.completion",
"created": 1746186539,
"system_fingerprint": "fp_123",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"type": "text",
"annotations": [
{
"type": "url_citation",
"url_citation": {
"title": "Lorem ipsum dolor sit amet",
"exactQuote": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"url": "https://some.referenced.site.com/article",
"dateTime": "Aug 30, 2024"
}
}
]
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 456,
"total_tokens": 579
},
"visitedURLs": ["https://first.com/some/path", "https://second.com/?foo=bar"],
"readURLs": [
"https://example.com",
"https://example.com/2",
"https://some.other.site.com/path"
],
"numURLs": 5
}
}
],
"Simplified": [
{
"json": {
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"annotations": [
{
"type": "url_citation",
"url_citation": {
"title": "Lorem ipsum dolor sit amet",
"exactQuote": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"url": "https://some.referenced.site.com/article",
"dateTime": "Aug 30, 2024"
}
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 456,
"total_tokens": 579
}
}
}
]
},
"connections": {
"When clicking Test workflow": {
"main": [
[
{
"node": "No options",
"type": "main",
"index": 0
},
{
"node": "With options",
"type": "main",
"index": 0
},
{
"node": "Simplified",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "b822e0dc-3c01-43d5-ad56-419814a40af7",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "e115be144a6a5547dbfca93e774dfffa178aa94a181854c13e2ce5e14d195b2e"
},
"id": "Qttu9wESqI9vHYBA",
"tags": []
}

View File

@@ -0,0 +1,37 @@
{
"id": "123",
"object": "chat.completion",
"created": 1746186539,
"system_fingerprint": "fp_123",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"type": "text",
"annotations": [
{
"type": "url_citation",
"url_citation": {
"title": "Lorem ipsum dolor sit amet",
"exactQuote": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
"url": "https://some.referenced.site.com/article",
"dateTime": "Aug 30, 2024"
}
}
]
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 456,
"total_tokens": 579
},
"visitedURLs": ["https://first.com/some/path", "https://second.com/?foo=bar"],
"readURLs": ["https://example.com", "https://example.com/2", "https://some.other.site.com/path"],
"numURLs": 5
}

View File

@@ -0,0 +1,18 @@
{
"code": 200,
"status": 20000,
"data": {
"title": "Jina AI - Your Search Foundation, Supercharged.",
"url": "https://jina.ai/",
"description": "Best-in-class embeddings, rerankers, web crawler scraper, deepsearch, small LMs. The search AI for multilingual and multimodal data.",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"usage": {
"tokens": 123
}
},
"meta": {
"usage": {
"tokens": 123
}
}
}

View File

@@ -0,0 +1,30 @@
{
"code": 200,
"status": 20000,
"data": [
{
"title": "Jina AI - Your Search Foundation, Supercharged.",
"url": "https://jina.ai/",
"description": "Best-in-class embeddings, rerankers, web crawler scraper, deepsearch, small LMs. The search AI for multilingual and multimodal data.",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"usage": {
"tokens": 123
}
},
{
"title": "Jina AI",
"url": "https://github.com/jina-ai",
"description": "Your Search Foundation, Supercharged! Jina AI has 243 repositories available. Follow their code on GitHub.",
"date": "Mar 24, 2025",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"usage": {
"tokens": 123
}
}
],
"meta": {
"usage": {
"tokens": 246
}
}
}

View File

@@ -0,0 +1,168 @@
{
"name": "Jina AI -> Reader -> Read",
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [0, 100],
"id": "75a081a7-14e6-4f63-a0b6-86f54937d59d",
"name": "When clicking Test workflow"
},
{
"parameters": {
"url": "https://first.com/some/path",
"simplify": false,
"options": {},
"requestOptions": {}
},
"type": "n8n-nodes-base.jinaAi",
"typeVersion": 1,
"position": [220, -100],
"id": "92e091b7-42dd-4751-8432-58a211840b35",
"name": "No options",
"credentials": {
"jinaAiApi": {
"id": "8ph5AE62dQFfqkLx",
"name": "Jina AI account"
}
}
},
{
"parameters": {
"url": "https://second.com/other?foo=bar",
"simplify": false,
"options": {
"outputFormat": "markdown",
"targetSelector": "article",
"excludeSelector": ".ad",
"enableImageCaptioning": true,
"waitForSelector": "#posts"
},
"requestOptions": {}
},
"type": "n8n-nodes-base.jinaAi",
"typeVersion": 1,
"position": [220, 100],
"id": "f598a0ee-794e-4c31-8833-327768f7eecb",
"name": "With options",
"credentials": {
"jinaAiApi": {
"id": "8ph5AE62dQFfqkLx",
"name": "Jina AI account"
}
}
},
{
"parameters": {
"url": "https://first.com/some/path",
"options": {},
"requestOptions": {}
},
"type": "n8n-nodes-base.jinaAi",
"typeVersion": 1,
"position": [220, 300],
"id": "79d27978-20af-494d-b9bd-32f68883ac54",
"name": "Simplified",
"credentials": {
"jinaAiApi": {
"id": "8ph5AE62dQFfqkLx",
"name": "Jina AI account"
}
}
}
],
"pinData": {
"No options": [
{
"json": {
"code": 200,
"status": 20000,
"data": {
"title": "Jina AI - Your Search Foundation, Supercharged.",
"url": "https://jina.ai/",
"description": "Best-in-class embeddings, rerankers, web crawler scraper, deepsearch, small LMs. The search AI for multilingual and multimodal data.",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"usage": {
"tokens": 123
}
},
"meta": {
"usage": {
"tokens": 123
}
}
}
}
],
"With options": [
{
"json": {
"code": 200,
"status": 20000,
"data": {
"title": "Jina AI - Your Search Foundation, Supercharged.",
"url": "https://jina.ai/",
"description": "Best-in-class embeddings, rerankers, web crawler scraper, deepsearch, small LMs. The search AI for multilingual and multimodal data.",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"usage": {
"tokens": 123
}
},
"meta": {
"usage": {
"tokens": 123
}
}
}
}
],
"Simplified": [
{
"json": {
"title": "Jina AI - Your Search Foundation, Supercharged.",
"url": "https://jina.ai/",
"description": "Best-in-class embeddings, rerankers, web crawler scraper, deepsearch, small LMs. The search AI for multilingual and multimodal data.",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"usage": {
"tokens": 123
}
}
}
]
},
"connections": {
"When clicking Test workflow": {
"main": [
[
{
"node": "No options",
"type": "main",
"index": 0
},
{
"node": "With options",
"type": "main",
"index": 0
},
{
"node": "Simplified",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "41f0e679-7754-4b3c-a86c-e130a18d4378",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "e115be144a6a5547dbfca93e774dfffa178aa94a181854c13e2ce5e14d195b2e"
},
"id": "MFBoiglfRhCu9HgF",
"tags": []
}

View File

@@ -0,0 +1,205 @@
{
"name": "Jina AI -> Reader -> Search",
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [-360, 40],
"id": "b7e0a085-eb10-48a7-a25e-853b36aef252",
"name": "When clicking Test workflow"
},
{
"parameters": {
"operation": "search",
"searchQuery": "Jina AI",
"simplify": false,
"options": {},
"requestOptions": {}
},
"type": "n8n-nodes-base.jinaAi",
"typeVersion": 1,
"position": [-140, -160],
"id": "ea197991-8539-4221-9798-842f4026f31b",
"name": "No options",
"credentials": {
"jinaAiApi": {
"id": "8ph5AE62dQFfqkLx",
"name": "Jina AI account"
}
}
},
{
"parameters": {
"operation": "search",
"searchQuery": "Jina AI",
"simplify": false,
"options": {
"outputFormat": "markdown",
"siteFilter": "jina.ai",
"pageNumber": 2
},
"requestOptions": {}
},
"type": "n8n-nodes-base.jinaAi",
"typeVersion": 1,
"position": [-140, 40],
"id": "dbfbbf4a-caa1-4922-b200-723748636773",
"name": "With options",
"credentials": {
"jinaAiApi": {
"id": "8ph5AE62dQFfqkLx",
"name": "Jina AI account"
}
}
},
{
"parameters": {
"operation": "search",
"searchQuery": "Jina AI",
"options": {},
"requestOptions": {}
},
"type": "n8n-nodes-base.jinaAi",
"typeVersion": 1,
"position": [-140, 240],
"id": "91ca27b2-eab4-4131-a544-5ae4794ac0b3",
"name": "Simplified",
"credentials": {
"jinaAiApi": {
"id": "8ph5AE62dQFfqkLx",
"name": "Jina AI account"
}
}
}
],
"pinData": {
"No options": [
{
"json": {
"code": 200,
"status": 20000,
"data": [
{
"title": "Jina AI - Your Search Foundation, Supercharged.",
"url": "https://jina.ai/",
"description": "Best-in-class embeddings, rerankers, web crawler scraper, deepsearch, small LMs. The search AI for multilingual and multimodal data.",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"usage": {
"tokens": 123
}
},
{
"title": "Jina AI",
"url": "https://github.com/jina-ai",
"description": "Your Search Foundation, Supercharged! Jina AI has 243 repositories available. Follow their code on GitHub.",
"date": "Mar 24, 2025",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"usage": {
"tokens": 123
}
}
],
"meta": {
"usage": {
"tokens": 246
}
}
}
}
],
"With options": [
{
"json": {
"code": 200,
"status": 20000,
"data": [
{
"title": "Jina AI - Your Search Foundation, Supercharged.",
"url": "https://jina.ai/",
"description": "Best-in-class embeddings, rerankers, web crawler scraper, deepsearch, small LMs. The search AI for multilingual and multimodal data.",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"usage": {
"tokens": 123
}
},
{
"title": "Jina AI",
"url": "https://github.com/jina-ai",
"description": "Your Search Foundation, Supercharged! Jina AI has 243 repositories available. Follow their code on GitHub.",
"date": "Mar 24, 2025",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"usage": {
"tokens": 123
}
}
],
"meta": {
"usage": {
"tokens": 246
}
}
}
}
],
"Simplified": [
{
"json": {
"title": "Jina AI - Your Search Foundation, Supercharged.",
"url": "https://jina.ai/",
"description": "Best-in-class embeddings, rerankers, web crawler scraper, deepsearch, small LMs. The search AI for multilingual and multimodal data.",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"usage": {
"tokens": 123
}
}
},
{
"json": {
"title": "Jina AI",
"url": "https://github.com/jina-ai",
"description": "Your Search Foundation, Supercharged! Jina AI has 243 repositories available. Follow their code on GitHub.",
"date": "Mar 24, 2025",
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
"usage": {
"tokens": 123
}
}
}
]
},
"connections": {
"When clicking Test workflow": {
"main": [
[
{
"node": "No options",
"type": "main",
"index": 0
},
{
"node": "With options",
"type": "main",
"index": 0
},
{
"node": "Simplified",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "b425b5ec-f0b1-4f81-a83b-ca6a787d7a1d",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "e115be144a6a5547dbfca93e774dfffa178aa94a181854c13e2ce5e14d195b2e"
},
"id": "QVbuEahHyMKrgfFc",
"tags": []
}