Skip to content

Commit fef3073

Browse files
committed
fix: Fixed search tool to enable judgment logic
1 parent 78fb38b commit fef3073

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

utils/chat.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ export function getSafetySettings(level: string) {
5656
})
5757
}
5858

59+
function canUseSearchAsTool(model: string) {
60+
if (model.startsWith('gemini-2.0-flash') || model.startsWith('gemini-2.0-pro')) {
61+
if (model.includes('lite') || model.includes('thinking')) return false
62+
return true
63+
}
64+
}
65+
5966
export default async function chat({
6067
messages = [],
6168
systemInstruction,
@@ -96,13 +103,11 @@ export default async function chat({
96103
}
97104
if (toolConfig) modelParams.toolConfig = toolConfig
98105
}
99-
if (model === 'gemini-2.0-flash-exp') {
106+
if (canUseSearchAsTool(model)) {
100107
const officialPlugins = [{ googleSearch: {} }]
101108
if (!tools) {
102109
modelParams.tools = officialPlugins
103110
}
104-
}
105-
if (model.startsWith('gemini-2.0-flash-exp')) {
106111
if (modelParams.safetySettings) {
107112
const safetySettings: NewModelParams['safetySettings'] = []
108113
modelParams.safetySettings.forEach((item) => {

0 commit comments

Comments
 (0)