MCPcopy Create free account
hub / github.com/Rfym21/Qwen2API / attributeChatUsage

Function attributeChatUsage

src/controllers/chat.js:88–98  ·  view source on GitHub ↗
(account, usage)

Source from the content-addressed store, hash-verified

86/**
87 * 判断 tool_choice 是否要求强制调用工具
88 * @param {string|Object} toolChoice - OpenAI tool_choice
89 * @returns {boolean} 是否需要至少一次工具调用
90 */
91const 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

Callers 2

handleStreamResponseFunction · 0.70
handleNonStreamResponseFunction · 0.70

Calls 1

accumulateStatsMethod · 0.80

Tested by

no test coverage detected