refactor: remove searchGrounding config and related code

This commit is contained in:
Han Xiao 2025-06-11 15:35:53 -07:00
parent 3d10f25028
commit 7965ce1167
5 changed files with 2 additions and 56 deletions

View File

@ -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": {},

View File

@ -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
},

View File

@ -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";

View File

@ -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);
}

View File

@ -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<string> {
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>
${query}
</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;
}
}