@ww_nero/mini-cli 1.0.82 → 1.0.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/request.js +12 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ww_nero/mini-cli",
3
- "version": "1.0.82",
3
+ "version": "1.0.83",
4
4
  "description": "极简的 AI 命令行助手",
5
5
  "bin": {
6
6
  "mini": "bin/mini.js"
package/src/request.js CHANGED
@@ -159,20 +159,27 @@ const processStreamResponse = (response, options = {}) => {
159
159
  }
160
160
 
161
161
  if (includeToolCalls && Array.isArray(delta.tool_calls)) {
162
- delta.tool_calls.forEach((call, index) => {
163
- if (!toolCalls[index]) {
164
- toolCalls[index] = {
162
+ delta.tool_calls.forEach((call) => {
163
+ const idx = typeof call.index === 'number' ? call.index : toolCalls.length;
164
+ if (!toolCalls[idx]) {
165
+ toolCalls[idx] = {
165
166
  id: call.id || '',
166
167
  type: call.type || 'function',
167
168
  function: {
168
- name: (call.function && call.function.name) || '',
169
+ name: '',
169
170
  arguments: ''
170
171
  }
171
172
  };
172
173
  }
173
174
 
175
+ if (call.id) {
176
+ toolCalls[idx].id = call.id;
177
+ }
178
+ if (call.function && call.function.name) {
179
+ toolCalls[idx].function.name += call.function.name;
180
+ }
174
181
  if (call.function && typeof call.function.arguments === 'string') {
175
- toolCalls[index].function.arguments += call.function.arguments;
182
+ toolCalls[idx].function.arguments += call.function.arguments;
176
183
  }
177
184
  });
178
185
  }