非思考模型支持ccr的工具调用格式
Browse files- src/utils/utils.js +17 -3
src/utils/utils.js
CHANGED
|
@@ -154,16 +154,30 @@ function generateGenerationConfig(parameters, enableThinking, actualModelName){
|
|
| 154 |
}
|
| 155 |
return generationConfig
|
| 156 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
function convertOpenAIToolsToAntigravity(openaiTools){
|
| 158 |
if (!openaiTools || openaiTools.length === 0) return [];
|
| 159 |
return openaiTools.map((tool)=>{
|
| 160 |
-
delete tool.function.parameters.$schema;
|
| 161 |
return {
|
| 162 |
functionDeclarations: [
|
| 163 |
{
|
| 164 |
name: tool.function.name,
|
| 165 |
description: tool.function.description,
|
| 166 |
-
parameters: tool.function.parameters
|
| 167 |
}
|
| 168 |
]
|
| 169 |
}
|
|
@@ -237,4 +251,4 @@ export{
|
|
| 237 |
generateRequestId,
|
| 238 |
generateRequestBody,
|
| 239 |
getDefaultIp
|
| 240 |
-
}
|
|
|
|
| 154 |
}
|
| 155 |
return generationConfig
|
| 156 |
}
|
| 157 |
+
const EXCLUDED_KEYS = new Set(['$schema', 'additionalProperties', 'minLength', 'maxLength', 'minItems', 'maxItems', 'uniqueItems']);
|
| 158 |
+
|
| 159 |
+
function cleanParameters(obj) {
|
| 160 |
+
if (!obj || typeof obj !== 'object') return obj;
|
| 161 |
+
|
| 162 |
+
const cleaned = Array.isArray(obj) ? [] : {};
|
| 163 |
+
|
| 164 |
+
for (const [key, value] of Object.entries(obj)) {
|
| 165 |
+
if (EXCLUDED_KEYS.has(key)) continue;
|
| 166 |
+
cleaned[key] = (value && typeof value === 'object') ? cleanParameters(value) : value;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
return cleaned;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
function convertOpenAIToolsToAntigravity(openaiTools){
|
| 173 |
if (!openaiTools || openaiTools.length === 0) return [];
|
| 174 |
return openaiTools.map((tool)=>{
|
|
|
|
| 175 |
return {
|
| 176 |
functionDeclarations: [
|
| 177 |
{
|
| 178 |
name: tool.function.name,
|
| 179 |
description: tool.function.description,
|
| 180 |
+
parameters: cleanParameters(tool.function.parameters)
|
| 181 |
}
|
| 182 |
]
|
| 183 |
}
|
|
|
|
| 251 |
generateRequestId,
|
| 252 |
generateRequestBody,
|
| 253 |
getDefaultIp
|
| 254 |
+
}
|