Skip to content

Commit 8619e07

Browse files
authored
feat(core): Add SerpApi Google search support to Chat hub (#23199)
1 parent 568dba2 commit 8619e07

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

packages/@n8n/api-types/src/chat-hub.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
type StructuredChunk,
33
type JINA_AI_TOOL_NODE_TYPE,
4+
type SERP_API_TOOL_NODE_TYPE,
45
type INode,
56
INodeSchema,
67
} from 'n8n-workflow';
@@ -59,7 +60,7 @@ export const PROVIDER_CREDENTIAL_TYPE_MAP: Record<
5960
mistralCloud: 'mistralCloudApi',
6061
};
6162

62-
export type ChatHubAgentTool = typeof JINA_AI_TOOL_NODE_TYPE;
63+
export type ChatHubAgentTool = typeof JINA_AI_TOOL_NODE_TYPE | typeof SERP_API_TOOL_NODE_TYPE;
6364

6465
/**
6566
* Chat Hub conversation model configuration

packages/frontend/editor-ui/src/features/ai/chatHub/components/ToolsSelectorModal.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ import { useCredentialsStore } from '@/features/credentials/credentials.store';
1515
import type { ICredentialsResponse } from '@/features/credentials/credentials.types';
1616
import { createEventBus } from '@n8n/utils/event-bus';
1717
import { type ChatHubAgentTool } from '@n8n/api-types';
18-
import { type INode, deepCopy, JINA_AI_TOOL_NODE_TYPE } from 'n8n-workflow';
18+
import {
19+
type INode,
20+
deepCopy,
21+
JINA_AI_TOOL_NODE_TYPE,
22+
SERP_API_TOOL_NODE_TYPE,
23+
} from 'n8n-workflow';
1924
import { AVAILABLE_TOOLS, type ChatHubToolProvider } from '../composables/availableTools';
2025
import { ElSwitch } from 'element-plus';
2126
import { useUIStore } from '@/app/stores/ui.store';
@@ -46,18 +51,22 @@ const canCreateCredentials = computed(() => {
4651
});
4752
4853
const selectedByProvider = ref<Record<ChatHubAgentTool, Set<string>>>({
54+
[SERP_API_TOOL_NODE_TYPE]: new Set(),
4955
[JINA_AI_TOOL_NODE_TYPE]: new Set(),
5056
});
5157
5258
const credentialIdByProvider = ref<Record<ChatHubAgentTool, string | null>>({
59+
[SERP_API_TOOL_NODE_TYPE]: null,
5360
[JINA_AI_TOOL_NODE_TYPE]: null,
5461
});
5562
5663
function resetSelections() {
5764
selectedByProvider.value = {
65+
[SERP_API_TOOL_NODE_TYPE]: new Set(),
5866
[JINA_AI_TOOL_NODE_TYPE]: new Set(),
5967
};
6068
credentialIdByProvider.value = {
69+
[SERP_API_TOOL_NODE_TYPE]: null,
6170
[JINA_AI_TOOL_NODE_TYPE]: null,
6271
};
6372
}

packages/frontend/editor-ui/src/features/ai/chatHub/composables/availableTools.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type ChatHubAgentTool } from '@n8n/api-types';
2-
import { type INode, JINA_AI_TOOL_NODE_TYPE } from 'n8n-workflow';
2+
import { type INode, JINA_AI_TOOL_NODE_TYPE, SERP_API_TOOL_NODE_TYPE } from 'n8n-workflow';
33
import { v4 as uuidv4 } from 'uuid';
44

55
export interface ChatHubToolProvider {
@@ -17,6 +17,26 @@ export interface ChatHubToolProvider {
1717
// to re-select it at their current sessions. This won't affecet custom builder agents,
1818
// the tools defined on them are always used as-is.
1919
export const AVAILABLE_TOOLS: Record<ChatHubAgentTool, ChatHubToolProvider> = {
20+
[SERP_API_TOOL_NODE_TYPE]: {
21+
name: 'SerpApi',
22+
description: 'Use SerpApi to search the web for relevant information.',
23+
credentialType: 'serpApi',
24+
tools: [
25+
{
26+
title: 'Google Search',
27+
node: {
28+
parameters: {
29+
options: {},
30+
},
31+
type: SERP_API_TOOL_NODE_TYPE,
32+
typeVersion: 1,
33+
position: [0, 0],
34+
id: uuidv4(),
35+
name: 'SerpApi Google Search',
36+
},
37+
},
38+
],
39+
},
2040
[JINA_AI_TOOL_NODE_TYPE]: {
2141
name: 'Jina AI',
2242
description: 'Use Jina AI to search the web for relevant information.',

packages/workflow/src/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ export const MAILGUN_NODE_TYPE = 'n8n-nodes-base.mailgun';
4747
export const POSTGRES_NODE_TYPE = 'n8n-nodes-base.postgres';
4848
export const MYSQL_NODE_TYPE = 'n8n-nodes-base.mySql';
4949
export const SCHEDULE_TRIGGER_NODE_TYPE = 'n8n-nodes-base.scheduleTrigger';
50+
51+
// Chat hub (search) tools
5052
export const JINA_AI_TOOL_NODE_TYPE = 'n8n-nodes-base.jinaAiTool';
53+
export const SERP_API_TOOL_NODE_TYPE = '@n8n/n8n-nodes-langchain.toolSerpApi';
5154

5255
export const STARTING_NODE_TYPES = [
5356
MANUAL_TRIGGER_NODE_TYPE,

0 commit comments

Comments
 (0)