🔍 feat: Add Google Search Grounding Toggle (#8174)

*  feat: Add Google Search Grounding Feature and Update Agent Tool Initialization

- Introduced a new grounding option in the Google configuration to enable real-time web search results.
- Updated the agent initialization to concatenate additional tools from options.
- Enhanced translation files to include descriptions for the new grounding feature.
- Modified relevant schemas and parameter settings to support the grounding functionality.

* 🔑 chore: Update @librechat/agents dependency to version 2.4.50

*  fix: Ensure tools array is initialized before concatenation in initializeAgent function

* chore: Update version of librechat-data-provider to 0.7.899 and add GOOGLE_TOOL_CONFLICT error type

* fix: Adjust label class for better text wrapping in DynamicSwitch component

* fix: Handle Google tool conflict error and update error messages in translation

* fix: Restore grounding setting in googleCol2 configuration

---------

Co-authored-by: Danny Avila <danny@librechat.ai>
This commit is contained in:
Dustin Healy 2025-07-01 15:00:18 -07:00 committed by GitHub
parent 8a5dbac0f9
commit 738d04fac4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 59 additions and 11 deletions

View file

@ -69,7 +69,7 @@
"registry": "https://registry.npmjs.org/"
},
"peerDependencies": {
"@librechat/agents": "^2.4.49",
"@librechat/agents": "^2.4.50",
"@librechat/data-schemas": "*",
"@modelcontextprotocol/sdk": "^1.12.3",
"axios": "^1.8.2",

View file

@ -1,6 +1,7 @@
import { Providers } from '@librechat/agents';
import { googleSettings, AuthKeys } from 'librechat-data-provider';
import type { GoogleClientOptions, VertexAIClientOptions } from '@librechat/agents';
import type { GoogleAIToolType } from '@langchain/google-common';
import type * as t from '~/types';
import { isEnabled } from '~/utils';
@ -105,6 +106,7 @@ export function getGoogleConfig(
const authHeader = options.authHeader;
const {
grounding,
thinking = googleSettings.thinking.default,
thinkingBudget = googleSettings.thinkingBudget.default,
...modelOptions
@ -187,8 +189,16 @@ export function getGoogleConfig(
};
}
const tools: GoogleAIToolType[] = [];
if (grounding) {
tools.push({ googleSearch: {} });
}
// Return the final shape
return {
/** @type {GoogleAIToolType[]} */
tools,
/** @type {Providers.GOOGLE | Providers.VERTEXAI} */
provider,
/** @type {GoogleClientOptions | VertexAIClientOptions} */

View file

@ -1,6 +1,6 @@
{
"name": "librechat-data-provider",
"version": "0.7.89",
"version": "0.7.899",
"description": "data services for librechat apps",
"main": "dist/index.js",
"module": "dist/index.es.js",

View file

@ -1257,6 +1257,10 @@ export enum ErrorTypes {
* Google provider returned an error
*/
GOOGLE_ERROR = 'google_error',
/**
* Google provider does not allow custom tools with built-in tools
*/
GOOGLE_TOOL_CONFLICT = 'google_tool_conflict',
/**
* Invalid Agent Provider (excluded by Admin)
*/

View file

@ -537,6 +537,19 @@ const google: Record<string, SettingDefinition> = {
optionType: 'conversation',
columnSpan: 2,
},
grounding: {
key: 'grounding',
label: 'com_endpoint_use_search_grounding',
labelCode: true,
description: 'com_endpoint_google_use_search_grounding',
descriptionCode: true,
type: 'boolean',
default: false,
component: 'switch',
optionType: 'model',
showDefault: false,
columnSpan: 2,
},
};
const googleConfig: SettingsConfiguration = [
@ -550,6 +563,7 @@ const googleConfig: SettingsConfiguration = [
librechat.resendFiles,
google.thinking,
google.thinkingBudget,
google.grounding,
];
const googleCol1: SettingsConfiguration = [
@ -567,6 +581,7 @@ const googleCol2: SettingsConfiguration = [
librechat.resendFiles,
google.thinking,
google.thinkingBudget,
google.grounding,
];
const openAI: SettingsConfiguration = [

View file

@ -634,6 +634,8 @@ export const tConversationSchema = z.object({
reasoning_summary: eReasoningSummarySchema.optional().nullable(),
/* OpenAI: use Responses API */
useResponsesApi: z.boolean().optional(),
/* Google: use Search Grounding */
grounding: z.boolean().optional(),
/* assistant */
assistant_id: z.string().optional(),
/* agents */
@ -736,6 +738,8 @@ export const tQueryParamsSchema = tConversationSchema
reasoning_summary: true,
/** @endpoints openAI, custom, azureOpenAI */
useResponsesApi: true,
/** @endpoints google */
grounding: true,
/** @endpoints google, anthropic, bedrock */
topP: true,
/** @endpoints google, anthropic */
@ -818,6 +822,7 @@ export const googleBaseSchema = tConversationSchema.pick({
topK: true,
thinking: true,
thinkingBudget: true,
grounding: true,
iconURL: true,
greeting: true,
spec: true,
@ -849,6 +854,7 @@ export const googleGenConfigSchema = z
thinkingBudget: coerceNumber.optional(),
})
.optional(),
grounding: z.boolean().optional(),
})
.strip()
.optional();

View file

@ -47,6 +47,7 @@ export interface IConversation extends Document {
reasoning_effort?: string;
reasoning_summary?: string;
useResponsesApi?: boolean;
grounding?: boolean;
// Additional fields
files?: string[];
expiredAt?: Date;