Skip to content

Commit c845762

Browse files
πŸ” feat: Add Google Search Grounding Toggle (danny-avila#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 <[email protected]>
1 parent ad1dad8 commit c845762

File tree

13 files changed

+59
-11
lines changed

13 files changed

+59
-11
lines changed

β€Žapi/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@langchain/google-genai": "^0.2.13",
4949
"@langchain/google-vertexai": "^0.2.13",
5050
"@langchain/textsplitters": "^0.1.0",
51-
"@librechat/agents": "^2.4.49",
51+
"@librechat/agents": "^2.4.50",
5252
"@librechat/api": "*",
5353
"@librechat/data-schemas": "*",
5454
"@node-saml/passport-saml": "^5.0.0",

β€Žapi/server/services/Endpoints/agents/agent.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ const initializeAgent = async ({
140140
agent.provider = options.provider;
141141
}
142142

143+
if (
144+
(agent.provider === Providers.GOOGLE || agent.provider === Providers.VERTEXAI) &&
145+
options?.tools?.length &&
146+
tools?.length
147+
) {
148+
throw new Error(`{ "type": "${ErrorTypes.GOOGLE_TOOL_CONFLICT}"}`);
149+
}
150+
143151
/** @type {import('@librechat/agents').ClientOptions} */
144152
agent.model_parameters = { ...options.llmConfig };
145153
if (options.configOptions) {
@@ -162,10 +170,10 @@ const initializeAgent = async ({
162170

163171
return {
164172
...agent,
165-
tools,
166173
attachments,
167174
resendFiles,
168175
toolContextMap,
176+
tools: options.tools ?? tools,
169177
maxContextTokens: (agentMaxContextTokens - maxTokens) * 0.9,
170178
};
171179
};

β€Žclient/src/components/Messages/Content/Error.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const errorMessages = {
6262
const { info } = json;
6363
return info;
6464
},
65+
[ErrorTypes.GOOGLE_TOOL_CONFLICT]: 'com_error_google_tool_conflict',
6566
[ViolationTypes.BAN]:
6667
'Your account has been temporarily banned due to violations of our service.',
6768
invalid_api_key:

β€Žclient/src/components/SidePanel/Parameters/DynamicSwitch.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function DynamicSwitch({
5050
<div className="flex justify-between">
5151
<Label
5252
htmlFor={`${settingKey}-dynamic-switch`}
53-
className="text-left text-sm font-medium"
53+
className="break-words text-left text-sm font-medium"
5454
>
5555
{labelCode ? (localize(label as TranslationKeys) ?? label) : label || settingKey}{' '}
5656
{showDefault && (

β€Žclient/src/locales/en/translation.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@
233233
"com_endpoint_openai_temp": "Higher values = more random, while lower values = more focused and deterministic. We recommend altering this or Top P but not both.",
234234
"com_endpoint_openai_topp": "An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We recommend altering this or temperature but not both.",
235235
"com_endpoint_openai_use_responses_api": "Use the Responses API instead of Chat Completions, which includes extended features from OpenAI. Required for o1-pro, o3-pro, and to enable reasoning summaries.",
236+
"com_endpoint_google_use_search_grounding": "Use Google's search grounding feature to enhance responses with real-time web search results. This enables models to access current information and provide more accurate, up-to-date answers.",
236237
"com_endpoint_output": "Output",
237238
"com_endpoint_plug_image_detail": "Image Detail",
238239
"com_endpoint_plug_resend_files": "Resend Files",
@@ -280,6 +281,7 @@
280281
"com_endpoint_top_p": "Top P",
281282
"com_endpoint_use_active_assistant": "Use Active Assistant",
282283
"com_endpoint_use_responses_api": "Use Responses API",
284+
"com_endpoint_use_search_grounding": "Grounding with Google Search",
283285
"com_error_expired_user_key": "Provided key for {{0}} expired at {{1}}. Please provide a new key and try again.",
284286
"com_error_files_dupe": "Duplicate file detected.",
285287
"com_error_files_empty": "Empty files are not allowed.",
@@ -291,6 +293,7 @@
291293
"com_error_heic_conversion": "Failed to convert HEIC image to JPEG. Please try converting the image manually or use a different format.",
292294
"com_error_input_length": "The latest message token count is too long, exceeding the token limit, or your token limit parameters are misconfigured, adversely affecting the context window. More info: {{0}}. Please shorten your message, adjust the max context size from the conversation parameters, or fork the conversation to continue.",
293295
"com_error_invalid_agent_provider": "The \"{{0}}\" provider is not available for use with Agents. Please go to your agent's settings and select a currently available provider.",
296+
"com_error_google_tool_conflict": "Usage of built-in Google tools are not supported with external tools. Please disable either the built-in tools or the external tools.",
294297
"com_error_invalid_user_key": "Invalid key provided. Please provide a valid key and try again.",
295298
"com_error_moderation": "It appears that the content submitted has been flagged by our moderation system for not aligning with our community guidelines. We're unable to proceed with this specific topic. If you have any other questions or topics you'd like to explore, please edit your message, or create a new conversation.",
296299
"com_error_no_base_url": "No base URL found. Please provide one and try again.",

β€Žpackage-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žpackages/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"registry": "https://registry.npmjs.org/"
7070
},
7171
"peerDependencies": {
72-
"@librechat/agents": "^2.4.49",
72+
"@librechat/agents": "^2.4.50",
7373
"@librechat/data-schemas": "*",
7474
"@modelcontextprotocol/sdk": "^1.12.3",
7575
"axios": "^1.8.2",

β€Žpackages/api/src/endpoints/google/llm.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Providers } from '@librechat/agents';
22
import { googleSettings, AuthKeys } from 'librechat-data-provider';
33
import type { GoogleClientOptions, VertexAIClientOptions } from '@librechat/agents';
4+
import type { GoogleAIToolType } from '@langchain/google-common';
45
import type * as t from '~/types';
56
import { isEnabled } from '~/utils';
67

@@ -105,6 +106,7 @@ export function getGoogleConfig(
105106
const authHeader = options.authHeader;
106107

107108
const {
109+
grounding,
108110
thinking = googleSettings.thinking.default,
109111
thinkingBudget = googleSettings.thinkingBudget.default,
110112
...modelOptions
@@ -187,8 +189,16 @@ export function getGoogleConfig(
187189
};
188190
}
189191

192+
const tools: GoogleAIToolType[] = [];
193+
194+
if (grounding) {
195+
tools.push({ googleSearch: {} });
196+
}
197+
190198
// Return the final shape
191199
return {
200+
/** @type {GoogleAIToolType[]} */
201+
tools,
192202
/** @type {Providers.GOOGLE | Providers.VERTEXAI} */
193203
provider,
194204
/** @type {GoogleClientOptions | VertexAIClientOptions} */

β€Žpackages/data-provider/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "librechat-data-provider",
3-
"version": "0.7.89",
3+
"version": "0.7.899",
44
"description": "data services for librechat apps",
55
"main": "dist/index.js",
66
"module": "dist/index.es.js",

β€Žpackages/data-provider/src/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,10 @@ export enum ErrorTypes {
12571257
* Google provider returned an error
12581258
*/
12591259
GOOGLE_ERROR = 'google_error',
1260+
/**
1261+
* Google provider does not allow custom tools with built-in tools
1262+
*/
1263+
GOOGLE_TOOL_CONFLICT = 'google_tool_conflict',
12601264
/**
12611265
* Invalid Agent Provider (excluded by Admin)
12621266
*/

0 commit comments

Comments
Β (0)