llmasaservice-client 0.2.3 → 0.2.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/CHANGELOG.md +12 -0
- package/dist/index.js +3 -1
- package/dist/index.mjs +3 -1
- package/package.json +1 -1
- package/src/useLLM.ts +6 -3
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -182,8 +182,10 @@ var useLLM = (options) => {
|
|
|
182
182
|
reader.cancel();
|
|
183
183
|
setIdle(true);
|
|
184
184
|
}
|
|
185
|
+
console.log("about to call callback", onCompleteCallback);
|
|
185
186
|
if (onCompleteCallback) {
|
|
186
|
-
onCompleteCallback();
|
|
187
|
+
onCompleteCallback(result);
|
|
188
|
+
console.log("called callback");
|
|
187
189
|
}
|
|
188
190
|
return result;
|
|
189
191
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -145,8 +145,10 @@ var useLLM = (options) => {
|
|
|
145
145
|
reader.cancel();
|
|
146
146
|
setIdle(true);
|
|
147
147
|
}
|
|
148
|
+
console.log("about to call callback", onCompleteCallback);
|
|
148
149
|
if (onCompleteCallback) {
|
|
149
|
-
onCompleteCallback();
|
|
150
|
+
onCompleteCallback(result);
|
|
151
|
+
console.log("called callback");
|
|
150
152
|
}
|
|
151
153
|
return result;
|
|
152
154
|
});
|
package/package.json
CHANGED
package/src/useLLM.ts
CHANGED
|
@@ -46,6 +46,7 @@ export const useLLM = (options?: LLMServiceType): UseLLMReturnType => {
|
|
|
46
46
|
* @param stream Determines whether to stream results back in the response property as they return from the service or batch them up and return them all at once in the response property as a string.
|
|
47
47
|
* @param abortController The AbortController used to abort this request once its started. This allows you to add a stop button to your UI.
|
|
48
48
|
* @param service The service to use for the request. If null, load balancing will be applied. This is typically only used for testing.
|
|
49
|
+
* @param onCompleteCallback The callback function to be called once the stream completes, with the final result string.
|
|
49
50
|
* @returns a StreamReader object if stream is true, otherwise a string of the response. Typically this isn't used when streaming, the stream is exposed in the response property.
|
|
50
51
|
*/
|
|
51
52
|
async function send(
|
|
@@ -54,7 +55,7 @@ export const useLLM = (options?: LLMServiceType): UseLLMReturnType => {
|
|
|
54
55
|
stream: boolean = true,
|
|
55
56
|
abortController: AbortController = new AbortController(),
|
|
56
57
|
service: string | null = null, // null means use the default service and apply services load balancing
|
|
57
|
-
onCompleteCallback?:
|
|
58
|
+
onCompleteCallback?: (result: string) => void
|
|
58
59
|
): Promise<ReadableStreamDefaultReader<any> | string | undefined> {
|
|
59
60
|
setResponse("");
|
|
60
61
|
setIdle(false);
|
|
@@ -119,7 +120,7 @@ export const useLLM = (options?: LLMServiceType): UseLLMReturnType => {
|
|
|
119
120
|
decoder: TextDecoder,
|
|
120
121
|
stream: Boolean = true,
|
|
121
122
|
{ signal: signal }: { signal: AbortSignal },
|
|
122
|
-
onCompleteCallback?:
|
|
123
|
+
onCompleteCallback?: (result: string) => void
|
|
123
124
|
): Promise<string> {
|
|
124
125
|
let errorInRead = "";
|
|
125
126
|
let result = "";
|
|
@@ -170,8 +171,10 @@ export const useLLM = (options?: LLMServiceType): UseLLMReturnType => {
|
|
|
170
171
|
setIdle(true);
|
|
171
172
|
}
|
|
172
173
|
|
|
174
|
+
console.log("about to call callback", onCompleteCallback);
|
|
173
175
|
if (onCompleteCallback) {
|
|
174
|
-
onCompleteCallback();
|
|
176
|
+
onCompleteCallback(result);
|
|
177
|
+
console.log("called callback");
|
|
175
178
|
}
|
|
176
179
|
|
|
177
180
|
return result;
|