(account, usage)
| 86 | /** |
| 87 | * 判断 tool_choice 是否要求强制调用工具 |
| 88 | * @param {string|Object} toolChoice - OpenAI tool_choice |
| 89 | * @returns {boolean} 是否需要至少一次工具调用 |
| 90 | */ |
| 91 | const requiresToolCall = (toolChoice) => { |
| 92 | if (toolChoice === 'required') return true |
| 93 | if (toolChoice && typeof toolChoice === 'object' && toolChoice.type === 'function' && toolChoice.function?.name) { |
| 94 | return true |
| 95 | } |
| 96 | return false |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * 构建 tool_choice=required 重试时追加的强约束提示 |
| 101 | * @param {string|Object} toolChoice - OpenAI tool_choice |
no test coverage detected