llmasaservice-client 0.2.1 → 0.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # llmasaservice-client
2
2
 
3
+ ## 0.2.3
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed callback
8
+
9
+ ## 0.2.2
10
+
11
+ ### Patch Changes
12
+
13
+ - Build fix
14
+
3
15
  ## 0.2.1
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -91,7 +91,7 @@ var useLLM = (options) => {
91
91
  setIdle(true);
92
92
  };
93
93
  function send(_0) {
94
- return __async(this, arguments, function* (prompt, messages = [], stream = true, abortController = new AbortController(), service = null) {
94
+ return __async(this, arguments, function* (prompt, messages = [], stream = true, abortController = new AbortController(), service = null, onCompleteCallback) {
95
95
  var _a, _b, _c, _d, _e;
96
96
  setResponse("");
97
97
  setIdle(false);
@@ -126,11 +126,11 @@ var useLLM = (options) => {
126
126
  if (!stream) {
127
127
  return yield readStream(reader, decoder, stream, {
128
128
  signal: options2.signal
129
- });
129
+ }, onCompleteCallback);
130
130
  } else {
131
131
  readStream(reader, decoder, stream, {
132
132
  signal: options2.signal
133
- });
133
+ }, onCompleteCallback);
134
134
  return reader;
135
135
  }
136
136
  }
@@ -144,7 +144,7 @@ var useLLM = (options) => {
144
144
  });
145
145
  }
146
146
  function readStream(_0, _1) {
147
- return __async(this, arguments, function* (reader, decoder, stream = true, { signal }) {
147
+ return __async(this, arguments, function* (reader, decoder, stream = true, { signal }, onCompleteCallback) {
148
148
  let errorInRead = "";
149
149
  let result = "";
150
150
  while (true) {
@@ -182,6 +182,9 @@ var useLLM = (options) => {
182
182
  reader.cancel();
183
183
  setIdle(true);
184
184
  }
185
+ if (onCompleteCallback) {
186
+ onCompleteCallback();
187
+ }
185
188
  return result;
186
189
  });
187
190
  }
package/dist/index.mjs CHANGED
@@ -54,7 +54,7 @@ var useLLM = (options) => {
54
54
  setIdle(true);
55
55
  };
56
56
  function send(_0) {
57
- return __async(this, arguments, function* (prompt, messages = [], stream = true, abortController = new AbortController(), service = null) {
57
+ return __async(this, arguments, function* (prompt, messages = [], stream = true, abortController = new AbortController(), service = null, onCompleteCallback) {
58
58
  var _a, _b, _c, _d, _e;
59
59
  setResponse("");
60
60
  setIdle(false);
@@ -89,11 +89,11 @@ var useLLM = (options) => {
89
89
  if (!stream) {
90
90
  return yield readStream(reader, decoder, stream, {
91
91
  signal: options2.signal
92
- });
92
+ }, onCompleteCallback);
93
93
  } else {
94
94
  readStream(reader, decoder, stream, {
95
95
  signal: options2.signal
96
- });
96
+ }, onCompleteCallback);
97
97
  return reader;
98
98
  }
99
99
  }
@@ -107,7 +107,7 @@ var useLLM = (options) => {
107
107
  });
108
108
  }
109
109
  function readStream(_0, _1) {
110
- return __async(this, arguments, function* (reader, decoder, stream = true, { signal }) {
110
+ return __async(this, arguments, function* (reader, decoder, stream = true, { signal }, onCompleteCallback) {
111
111
  let errorInRead = "";
112
112
  let result = "";
113
113
  while (true) {
@@ -145,6 +145,9 @@ var useLLM = (options) => {
145
145
  reader.cancel();
146
146
  setIdle(true);
147
147
  }
148
+ if (onCompleteCallback) {
149
+ onCompleteCallback();
150
+ }
148
151
  return result;
149
152
  });
150
153
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "llmasaservice-client",
3
3
  "license": "MIT",
4
- "version": "0.2.1",
4
+ "version": "0.2.3",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",
package/src/useLLM.ts CHANGED
@@ -144,12 +144,6 @@ export const useLLM = (options?: LLMServiceType): UseLLMReturnType => {
144
144
  // If the stream has been read to the end, exit the loop
145
145
  if (done) {
146
146
  setIdle(true);
147
-
148
- if (onCompleteCallback) {
149
- onCompleteCallback(result);
150
-
151
- }
152
-
153
147
  break;
154
148
  }
155
149
 
@@ -176,6 +170,10 @@ export const useLLM = (options?: LLMServiceType): UseLLMReturnType => {
176
170
  setIdle(true);
177
171
  }
178
172
 
173
+ if (onCompleteCallback) {
174
+ onCompleteCallback();
175
+ }
176
+
179
177
  return result;
180
178
  }
181
179