@coherentglobal/spark-execute-sdk 0.7.3 → 0.8.0
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/README.md +36 -0
- package/dist/browser.js +359 -143
- package/package.json +2 -2
- package/src/browser.js +42 -10
- package/src/error.js +11 -0
- package/src/helpers/utils.js +11 -10
- package/src/node.js +162 -75
- package/src/validate.js +1 -0
- package/types/browser.d.ts +15 -2
- package/types/browser.d.ts.map +1 -1
- package/types/error.d.ts +5 -0
- package/types/error.d.ts.map +1 -1
- package/types/helpers/utils.d.ts +1 -0
- package/types/helpers/utils.d.ts.map +1 -1
- package/types/node.d.ts +24 -3
- package/types/node.d.ts.map +1 -1
- package/types/validate.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -117,6 +117,42 @@ const response = await Spark.execute(input, version_id).catch((err) => {
|
|
|
117
117
|
});
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
+
### executeWithCancellationToken(input)
|
|
121
|
+
|
|
122
|
+
Perform the calculation with cancellationToken. The sdk will use the request_meta.version_uuid of input argument to locate the model
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
const execute = Spark.executeWithCancellationToken(input)
|
|
126
|
+
|
|
127
|
+
// Cancel the execution (best effort)
|
|
128
|
+
execute.cancellationToken.cancel()
|
|
129
|
+
|
|
130
|
+
execute.response.then((result) => {
|
|
131
|
+
// Do something here
|
|
132
|
+
})
|
|
133
|
+
.catch((err) => {
|
|
134
|
+
// Do something here
|
|
135
|
+
// If error is instance of Spark.WasmRunnerErrors.ExecuteCancelled, meaning the request has been cancelled
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
or
|
|
140
|
+
|
|
141
|
+
```js
|
|
142
|
+
const execute = Spark.executeWithCancellationToken(input)
|
|
143
|
+
|
|
144
|
+
// Cancel the execution (best effort)
|
|
145
|
+
execute.cancellationToken.cancel()
|
|
146
|
+
|
|
147
|
+
execute.response.then((result) => {
|
|
148
|
+
// Do something here
|
|
149
|
+
})
|
|
150
|
+
.catch((err) => {
|
|
151
|
+
// Do something here
|
|
152
|
+
// If error is instance of Spark.WasmRunnerErrors.ExecuteCancelled, meaning the request has been cancelled
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
120
156
|
Note: The second parameter (version_id) is optional if version_id is already included on request_meta
|
|
121
157
|
|
|
122
158
|
### Sample Input
|