From 7965ce1167f32419661039565a06882e76c45a1a Mon Sep 17 00:00:00 2001 From: Han Xiao Date: Wed, 11 Jun 2025 15:35:53 -0700 Subject: [PATCH] refactor: remove searchGrounding config and related code --- config.json | 6 ------ jina-ai/config.json | 6 ++---- src/agent.ts | 1 - src/config.ts | 6 ------ src/tools/grounding.ts | 39 --------------------------------------- 5 files changed, 2 insertions(+), 56 deletions(-) delete mode 100644 src/tools/grounding.ts diff --git a/config.json b/config.json index 6145e1d..fcdad2c 100644 --- a/config.json +++ b/config.json @@ -36,9 +36,6 @@ "coder": { "temperature": 0.7 }, - "searchGrounding": { - "temperature": 0 - }, "evaluator": { "temperature": 0.6, "maxTokens": 200 @@ -73,9 +70,6 @@ "coder": { "temperature": 0.7 }, - "searchGrounding": { - "temperature": 0 - }, "researchPlanner": {}, "evaluator": {}, "errorAnalyzer": {}, diff --git a/jina-ai/config.json b/jina-ai/config.json index fc4ae36..a5059f0 100644 --- a/jina-ai/config.json +++ b/jina-ai/config.json @@ -43,7 +43,7 @@ "maxTokens": 2000, "model": "gemini-2.0-flash-lite" }, - "searchGrounding": {}, + "researchPlanner": {}, "evaluator": { "maxTokens": 2000 }, @@ -72,11 +72,9 @@ "coder": { "temperature": 0.7 }, - "searchGrounding": { - "temperature": 0 - }, "evaluator": {}, "errorAnalyzer": {}, + "researchPlanner": {}, "queryRewriter": { "temperature": 0.1 }, diff --git a/src/agent.ts b/src/agent.ts index cba3fa8..ea8180c 100644 --- a/src/agent.ts +++ b/src/agent.ts @@ -22,7 +22,6 @@ import { } from "./types"; import { TrackerContext } from "./types"; import { search } from "./tools/jina-search"; -// import {grounding} from "./tools/grounding"; import { zodToJsonSchema } from "zod-to-json-schema"; import { ObjectGeneratorSafe } from "./utils/safe-generator"; import { CodeSandbox } from "./tools/code-sandbox"; diff --git a/src/config.ts b/src/config.ts index ab16239..b42c5f2 100644 --- a/src/config.ts +++ b/src/config.ts @@ -114,9 +114,6 @@ export function getModel(toolName: ToolName) { if (LLM_PROVIDER === 'vertex') { const createVertex = require('@ai-sdk/google-vertex').createVertex; - if (toolName === 'searchGrounding') { - return createVertex({ project: process.env.GCLOUD_PROJECT, ...providerConfig?.clientConfig })(config.model, { useSearchGrounding: true }); - } return createVertex({ project: process.env.GCLOUD_PROJECT, ...providerConfig?.clientConfig })(config.model); } @@ -124,9 +121,6 @@ export function getModel(toolName: ToolName) { throw new Error('GEMINI_API_KEY not found'); } - if (toolName === 'searchGrounding') { - return createGoogleGenerativeAI({ apiKey: GEMINI_API_KEY })(config.model, { useSearchGrounding: true }); - } return createGoogleGenerativeAI({ apiKey: GEMINI_API_KEY })(config.model); } diff --git a/src/tools/grounding.ts b/src/tools/grounding.ts deleted file mode 100644 index f7c82e9..0000000 --- a/src/tools/grounding.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { generateText } from 'ai'; -import { getModel } from "../config"; -import { GoogleGenerativeAIProviderMetadata } from '@ai-sdk/google'; -import { TokenTracker } from "../utils/token-tracker"; -import { logInfo, logError, logDebug, logWarning } from '../logging'; - -const model = getModel('searchGrounding') - -export async function grounding(query: string, tracker?: TokenTracker): Promise { - try { - const { text, experimental_providerMetadata, usage } = await generateText({ - model, - prompt: - `Current date is ${new Date().toISOString()}. Find the latest answer to the following question: - -${query} - -Must include the date and time of the latest answer.`, - }); - - const metadata = experimental_providerMetadata?.google as - | GoogleGenerativeAIProviderMetadata - | undefined; - const groundingMetadata = metadata?.groundingMetadata; - - // Extract and concatenate all groundingSupport text into a single line - const groundedText = groundingMetadata?.groundingSupports - ?.map(support => support.segment.text) - .join(' ') || ''; - - (tracker || new TokenTracker()).trackUsage('grounding', usage); - logInfo('Grounding:', { text, groundedText }); - return text + '|' + groundedText; - - } catch (error) { - logError('Error in search:', { error }); - throw error; - } -} \ No newline at end of file