@xsai/stream-text 0.1.3 → 0.2.0-beta.1

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 +4 -11
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -67,12 +67,6 @@ var streamText = async (options) => {
67
67
  if (state.endedToolCallIDs.has(id)) {
68
68
  return;
69
69
  }
70
- const toolCall = step.choices[state.index].message.tool_calls[id];
71
- try {
72
- toolCall.function.parsed_arguments = JSON.parse(toolCall.function.arguments);
73
- } catch (error) {
74
- state.toolCallErrors[id] = error;
75
- }
76
70
  state.endedToolCallIDs.add(id);
77
71
  state.currentToolID = null;
78
72
  };
@@ -199,12 +193,13 @@ var streamText = async (options) => {
199
193
  return;
200
194
  }
201
195
  try {
202
- const { result } = await executeTool({
196
+ const { parsedArgs, result, toolName } = await executeTool({
203
197
  abortSignal: options2.abortSignal,
204
198
  messages: options2.messages,
205
199
  toolCall,
206
200
  tools: options2.tools
207
201
  });
202
+ toolCall.function.parsed_arguments = parsedArgs;
208
203
  state.toolCallResults[id] = result;
209
204
  step.messages.push({
210
205
  content: result,
@@ -212,12 +207,10 @@ var streamText = async (options) => {
212
207
  tool_call_id: id
213
208
  });
214
209
  step.toolResults.push({
215
- args: toolCall.function.parsed_arguments,
216
- // TODO: use parsedArgs from executeTool
210
+ args: parsedArgs,
217
211
  result,
218
212
  toolCallId: id,
219
- toolName: toolCall.function.name
220
- // TODO: use toolName from executeTool
213
+ toolName
221
214
  });
222
215
  } catch (error) {
223
216
  state.toolCallErrors[id] = error;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xsai/stream-text",
3
3
  "type": "module",
4
- "version": "0.1.3",
4
+ "version": "0.2.0-beta.1",
5
5
  "description": "extra-small AI SDK for Browser, Node.js, Deno, Bun or Edge Runtime.",
6
6
  "author": "Moeru AI",
7
7
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "devDependencies": {
35
35
  "@xsai/shared": "",
36
36
  "@xsai/tool": "",
37
- "valibot": "^1.0.0-rc.3"
37
+ "valibot": "^1.0.0"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "tsup",