@xsai/stream-text 0.4.0-beta.3 → 0.4.0-beta.5

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.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { WithUnknown } from '@xsai/shared';
1
2
  import { CompletionToolCall, CompletionToolResult, FinishReason, Usage, ChatOptions, CompletionStep, Message } from '@xsai/shared-chat';
2
3
 
3
4
  type StreamTextEvent = (CompletionToolCall & {
@@ -54,6 +55,6 @@ interface StreamTextResult {
54
55
  totalUsage: Promise<undefined | Usage>;
55
56
  usage: Promise<undefined | Usage>;
56
57
  }
57
- declare const streamText: (options: StreamTextOptions) => StreamTextResult;
58
+ declare const streamText: (options: WithUnknown<StreamTextOptions>) => StreamTextResult;
58
59
 
59
60
  export { type StreamTextEvent, type StreamTextOptions, type StreamTextResult, streamText };
package/dist/index.js CHANGED
@@ -1,15 +1,6 @@
1
+ import { trampoline, objCamelToSnake } from '@xsai/shared';
1
2
  import { chat, executeTool, determineStepType } from '@xsai/shared-chat';
2
3
 
3
- const strCamelToSnake = (str) => str.replace(/[A-Z]/g, (s) => `_${s.toLowerCase()}`);
4
- const objCamelToSnake = (obj) => Object.fromEntries(Object.entries(obj).map(([k, v]) => [strCamelToSnake(k), v]));
5
-
6
- const trampoline = async (fn) => {
7
- let result = await fn();
8
- while (result instanceof Function)
9
- result = await result();
10
- return result;
11
- };
12
-
13
4
  class DelayedPromise {
14
5
  get promise() {
15
6
  if (this._promise == null) {
@@ -173,6 +164,8 @@ const streamText = (options) => {
173
164
  messages.push({ content: text, role: "assistant", tool_calls });
174
165
  if (tool_calls.length !== 0) {
175
166
  for (const toolCall of tool_calls) {
167
+ if (toolCall == null)
168
+ continue;
176
169
  const { completionToolCall, completionToolResult, message } = await executeTool({
177
170
  abortSignal: options.abortSignal,
178
171
  messages,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xsai/stream-text",
3
3
  "type": "module",
4
- "version": "0.4.0-beta.3",
4
+ "version": "0.4.0-beta.5",
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-chat": "~0.4.0-beta.3"
32
+ "@xsai/shared": "~0.4.0-beta.5",
33
+ "@xsai/shared-chat": "~0.4.0-beta.5"
33
34
  },
34
35
  "devDependencies": {
35
36
  "valibot": "^1.0.0",
36
- "@xsai/shared": "~0.4.0-beta.3",
37
- "@xsai/tool": "~0.4.0-beta.3"
37
+ "@xsai/tool": "~0.4.0-beta.5"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "pkgroll",