mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2026-03-22 07:29:35 +08:00
refactor: remove searchGrounding config and related code
This commit is contained in:
@@ -36,9 +36,6 @@
|
|||||||
"coder": {
|
"coder": {
|
||||||
"temperature": 0.7
|
"temperature": 0.7
|
||||||
},
|
},
|
||||||
"searchGrounding": {
|
|
||||||
"temperature": 0
|
|
||||||
},
|
|
||||||
"evaluator": {
|
"evaluator": {
|
||||||
"temperature": 0.6,
|
"temperature": 0.6,
|
||||||
"maxTokens": 200
|
"maxTokens": 200
|
||||||
@@ -73,9 +70,6 @@
|
|||||||
"coder": {
|
"coder": {
|
||||||
"temperature": 0.7
|
"temperature": 0.7
|
||||||
},
|
},
|
||||||
"searchGrounding": {
|
|
||||||
"temperature": 0
|
|
||||||
},
|
|
||||||
"researchPlanner": {},
|
"researchPlanner": {},
|
||||||
"evaluator": {},
|
"evaluator": {},
|
||||||
"errorAnalyzer": {},
|
"errorAnalyzer": {},
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
"maxTokens": 2000,
|
"maxTokens": 2000,
|
||||||
"model": "gemini-2.0-flash-lite"
|
"model": "gemini-2.0-flash-lite"
|
||||||
},
|
},
|
||||||
"searchGrounding": {},
|
"researchPlanner": {},
|
||||||
"evaluator": {
|
"evaluator": {
|
||||||
"maxTokens": 2000
|
"maxTokens": 2000
|
||||||
},
|
},
|
||||||
@@ -72,11 +72,9 @@
|
|||||||
"coder": {
|
"coder": {
|
||||||
"temperature": 0.7
|
"temperature": 0.7
|
||||||
},
|
},
|
||||||
"searchGrounding": {
|
|
||||||
"temperature": 0
|
|
||||||
},
|
|
||||||
"evaluator": {},
|
"evaluator": {},
|
||||||
"errorAnalyzer": {},
|
"errorAnalyzer": {},
|
||||||
|
"researchPlanner": {},
|
||||||
"queryRewriter": {
|
"queryRewriter": {
|
||||||
"temperature": 0.1
|
"temperature": 0.1
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import {
|
|||||||
} from "./types";
|
} from "./types";
|
||||||
import { TrackerContext } from "./types";
|
import { TrackerContext } from "./types";
|
||||||
import { search } from "./tools/jina-search";
|
import { search } from "./tools/jina-search";
|
||||||
// import {grounding} from "./tools/grounding";
|
|
||||||
import { zodToJsonSchema } from "zod-to-json-schema";
|
import { zodToJsonSchema } from "zod-to-json-schema";
|
||||||
import { ObjectGeneratorSafe } from "./utils/safe-generator";
|
import { ObjectGeneratorSafe } from "./utils/safe-generator";
|
||||||
import { CodeSandbox } from "./tools/code-sandbox";
|
import { CodeSandbox } from "./tools/code-sandbox";
|
||||||
|
|||||||
@@ -114,9 +114,6 @@ export function getModel(toolName: ToolName) {
|
|||||||
|
|
||||||
if (LLM_PROVIDER === 'vertex') {
|
if (LLM_PROVIDER === 'vertex') {
|
||||||
const createVertex = require('@ai-sdk/google-vertex').createVertex;
|
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);
|
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');
|
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);
|
return createGoogleGenerativeAI({ apiKey: GEMINI_API_KEY })(config.model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user