| 798 | if (Array.isArray(request.body.tools) && request.body.tools.length > 0) { | 798 | if (Array.isArray(request.body.tools) && request.body.tools.length > 0) { |
| 799 | bodyParams['tools'] = request.body.tools; | 799 | bodyParams['tools'] = request.body.tools; |
| 800 | bodyParams['tool_choice'] = request.body.tool_choice; | 800 | bodyParams['tool_choice'] = request.body.tool_choice; |
| | 801 | |
| | 802 | // DeepSeek doesn't permit empty required arrays |
| | 803 | bodyParams.tools.forEach(tool => { |
| | 804 | const required = tool?.function?.parameters?.required; |
| | 805 | if (Array.isArray(required) && required.length === 0) { |
| | 806 | delete tool.function.parameters.required; |
| | 807 | } |
| | 808 | }); |
| 801 | } | 809 | } |
| 802 | | 810 | |
| 803 | const postProcessType = String(request.body.model).endsWith('-reasoner') ? 'deepseek-reasoner' : 'deepseek'; | 811 | const postProcessType = String(request.body.model).endsWith('-reasoner') ? 'deepseek-reasoner' : 'deepseek'; |