@xsai/stream-text 0.4.2 → 0.4.3

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/dist/index.js +6 -5
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -165,15 +165,16 @@ const streamText = (options) => {
165
165
  tool_calls: tool_calls.length > 0 ? tool_calls : void 0
166
166
  });
167
167
  if (tool_calls.length !== 0) {
168
- for (const toolCall of tool_calls) {
169
- if (toolCall == null)
170
- continue;
171
- const { completionToolCall, completionToolResult, message } = await executeTool({
168
+ const validToolCalls = tool_calls.filter((tc) => tc != null);
169
+ const results = await Promise.all(
170
+ validToolCalls.map(async (toolCall) => executeTool({
172
171
  abortSignal: options.abortSignal,
173
172
  messages,
174
173
  toolCall,
175
174
  tools: options.tools
176
- });
175
+ }))
176
+ );
177
+ for (const { completionToolCall, completionToolResult, message } of results) {
177
178
  toolCalls.push(completionToolCall);
178
179
  toolResults.push(completionToolResult);
179
180
  messages.push(message);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xsai/stream-text",
3
3
  "type": "module",
4
- "version": "0.4.2",
4
+ "version": "0.4.3",
5
5
  "description": "extra-small AI SDK.",
6
6
  "author": "Moeru AI",
7
7
  "license": "MIT",
@@ -29,12 +29,12 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@xsai/shared": "~0.4.2",
33
- "@xsai/shared-chat": "~0.4.2"
32
+ "@xsai/shared": "~0.4.3",
33
+ "@xsai/shared-chat": "~0.4.3"
34
34
  },
35
35
  "devDependencies": {
36
36
  "valibot": "^1.0.0",
37
- "@xsai/tool": "~0.4.2"
37
+ "@xsai/tool": "~0.4.3"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "pkgroll",