@xsai/stream-text 0.2.0-beta.2 → 0.2.0-beta.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.
package/dist/index.d.ts CHANGED
@@ -50,9 +50,8 @@ interface StreamTextOptions extends ChatOptions {
50
50
  /**
51
51
  * Return usage.
52
52
  * @default `undefined`
53
- * @remarks Ollama doesn't support this, see {@link https://github.com/ollama/ollama/issues/5200}
54
53
  */
55
- usage?: boolean;
54
+ includeUsage?: boolean;
56
55
  };
57
56
  /**
58
57
  * List of tools to be used in the stream.
package/dist/index.js CHANGED
@@ -9,6 +9,9 @@ class XSAIError extends Error {
9
9
  }
10
10
  }
11
11
 
12
+ const strCamelToSnake = (str) => str.replace(/[A-Z]/g, (s) => `_${s.toLowerCase()}`);
13
+ const objCamelToSnake = (obj) => Object.fromEntries(Object.entries(obj).map(([k, v]) => [strCamelToSnake(k), v]));
14
+
12
15
  const CHUNK_HEADER_PREFIX = "data:";
13
16
  const parseChunk = (text) => {
14
17
  if (!text || !text.startsWith(CHUNK_HEADER_PREFIX))
@@ -68,7 +71,8 @@ const streamText = async (options) => {
68
71
  };
69
72
  await chat({
70
73
  ...options2,
71
- stream: true
74
+ stream: true,
75
+ streamOptions: options2.streamOptions != null ? objCamelToSnake(options2.streamOptions) : void 0
72
76
  }).then(
73
77
  async (res) => res.body.pipeThrough(new TransformStream({
74
78
  transform: async (chunk, controller) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xsai/stream-text",
3
3
  "type": "module",
4
- "version": "0.2.0-beta.2",
4
+ "version": "0.2.0-beta.3",
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",