mirror of
https://github.com/n8n-io/n8n.git
synced 2026-09-21 12:51:16 +08:00
feat(core): Add SerpApi Google search support to Chat hub (#23199)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
type StructuredChunk,
|
||||
type JINA_AI_TOOL_NODE_TYPE,
|
||||
type SERP_API_TOOL_NODE_TYPE,
|
||||
type INode,
|
||||
INodeSchema,
|
||||
} from 'n8n-workflow';
|
||||
@@ -59,7 +60,7 @@ export const PROVIDER_CREDENTIAL_TYPE_MAP: Record<
|
||||
mistralCloud: 'mistralCloudApi',
|
||||
};
|
||||
|
||||
export type ChatHubAgentTool = typeof JINA_AI_TOOL_NODE_TYPE;
|
||||
export type ChatHubAgentTool = typeof JINA_AI_TOOL_NODE_TYPE | typeof SERP_API_TOOL_NODE_TYPE;
|
||||
|
||||
/**
|
||||
* Chat Hub conversation model configuration
|
||||
|
||||
+10
-1
@@ -15,7 +15,12 @@ import { useCredentialsStore } from '@/features/credentials/credentials.store';
|
||||
import type { ICredentialsResponse } from '@/features/credentials/credentials.types';
|
||||
import { createEventBus } from '@n8n/utils/event-bus';
|
||||
import { type ChatHubAgentTool } from '@n8n/api-types';
|
||||
import { type INode, deepCopy, JINA_AI_TOOL_NODE_TYPE } from 'n8n-workflow';
|
||||
import {
|
||||
type INode,
|
||||
deepCopy,
|
||||
JINA_AI_TOOL_NODE_TYPE,
|
||||
SERP_API_TOOL_NODE_TYPE,
|
||||
} from 'n8n-workflow';
|
||||
import { AVAILABLE_TOOLS, type ChatHubToolProvider } from '../composables/availableTools';
|
||||
import { ElSwitch } from 'element-plus';
|
||||
import { useUIStore } from '@/app/stores/ui.store';
|
||||
@@ -46,18 +51,22 @@ const canCreateCredentials = computed(() => {
|
||||
});
|
||||
|
||||
const selectedByProvider = ref<Record<ChatHubAgentTool, Set<string>>>({
|
||||
[SERP_API_TOOL_NODE_TYPE]: new Set(),
|
||||
[JINA_AI_TOOL_NODE_TYPE]: new Set(),
|
||||
});
|
||||
|
||||
const credentialIdByProvider = ref<Record<ChatHubAgentTool, string | null>>({
|
||||
[SERP_API_TOOL_NODE_TYPE]: null,
|
||||
[JINA_AI_TOOL_NODE_TYPE]: null,
|
||||
});
|
||||
|
||||
function resetSelections() {
|
||||
selectedByProvider.value = {
|
||||
[SERP_API_TOOL_NODE_TYPE]: new Set(),
|
||||
[JINA_AI_TOOL_NODE_TYPE]: new Set(),
|
||||
};
|
||||
credentialIdByProvider.value = {
|
||||
[SERP_API_TOOL_NODE_TYPE]: null,
|
||||
[JINA_AI_TOOL_NODE_TYPE]: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { type ChatHubAgentTool } from '@n8n/api-types';
|
||||
import { type INode, JINA_AI_TOOL_NODE_TYPE } from 'n8n-workflow';
|
||||
import { type INode, JINA_AI_TOOL_NODE_TYPE, SERP_API_TOOL_NODE_TYPE } from 'n8n-workflow';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
export interface ChatHubToolProvider {
|
||||
@@ -17,6 +17,26 @@ export interface ChatHubToolProvider {
|
||||
// to re-select it at their current sessions. This won't affecet custom builder agents,
|
||||
// the tools defined on them are always used as-is.
|
||||
export const AVAILABLE_TOOLS: Record<ChatHubAgentTool, ChatHubToolProvider> = {
|
||||
[SERP_API_TOOL_NODE_TYPE]: {
|
||||
name: 'SerpApi',
|
||||
description: 'Use SerpApi to search the web for relevant information.',
|
||||
credentialType: 'serpApi',
|
||||
tools: [
|
||||
{
|
||||
title: 'Google Search',
|
||||
node: {
|
||||
parameters: {
|
||||
options: {},
|
||||
},
|
||||
type: SERP_API_TOOL_NODE_TYPE,
|
||||
typeVersion: 1,
|
||||
position: [0, 0],
|
||||
id: uuidv4(),
|
||||
name: 'SerpApi Google Search',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
[JINA_AI_TOOL_NODE_TYPE]: {
|
||||
name: 'Jina AI',
|
||||
description: 'Use Jina AI to search the web for relevant information.',
|
||||
|
||||
@@ -47,7 +47,10 @@ export const MAILGUN_NODE_TYPE = 'n8n-nodes-base.mailgun';
|
||||
export const POSTGRES_NODE_TYPE = 'n8n-nodes-base.postgres';
|
||||
export const MYSQL_NODE_TYPE = 'n8n-nodes-base.mySql';
|
||||
export const SCHEDULE_TRIGGER_NODE_TYPE = 'n8n-nodes-base.scheduleTrigger';
|
||||
|
||||
// Chat hub (search) tools
|
||||
export const JINA_AI_TOOL_NODE_TYPE = 'n8n-nodes-base.jinaAiTool';
|
||||
export const SERP_API_TOOL_NODE_TYPE = '@n8n/n8n-nodes-langchain.toolSerpApi';
|
||||
|
||||
export const STARTING_NODE_TYPES = [
|
||||
MANUAL_TRIGGER_NODE_TYPE,
|
||||
|
||||
Reference in New Issue
Block a user