@kortexya/reasoninglayer 1.27.0 → 2.0.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 +38 -18
- package/dist/index.cjs +988 -125
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3107 -761
- package/dist/index.d.ts +3107 -761
- package/dist/index.js +986 -126
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -186,16 +186,31 @@ browser code that has already gone through the platform's login flow.
|
|
|
186
186
|
|
|
187
187
|
## Response Metadata
|
|
188
188
|
|
|
189
|
+
A resource method resolves to the parsed body alone. To see a **successful**
|
|
190
|
+
response's status, headers or rate-limit budget, register an interceptor — it
|
|
191
|
+
wraps every request the client makes.
|
|
192
|
+
|
|
189
193
|
```typescript
|
|
190
|
-
|
|
191
|
-
|
|
194
|
+
const client = new ReasoningLayerClient({
|
|
195
|
+
baseUrl: 'https://platform.ovh.reasoninglayer.ai',
|
|
196
|
+
tenantId: 'your-tenant-uuid',
|
|
197
|
+
auth: { mode: 'cookie' },
|
|
198
|
+
interceptors: [
|
|
199
|
+
async (request, next) => {
|
|
200
|
+
const response = await next(request);
|
|
201
|
+
console.log(response.status); // 201
|
|
202
|
+
console.log(response.headers.get('x-ratelimit-remaining')); // '99'
|
|
203
|
+
return response;
|
|
204
|
+
},
|
|
205
|
+
],
|
|
206
|
+
});
|
|
192
207
|
|
|
193
|
-
|
|
194
|
-
const result = await client.sorts.withMetadata().createSort({ name: 'person' });
|
|
195
|
-
console.log(result.status); // 201
|
|
196
|
-
console.log(result.rateLimit); // { limit, remaining, retryAfter }
|
|
208
|
+
const sort = await client.sorts.createSort({ name: 'person' });
|
|
197
209
|
```
|
|
198
210
|
|
|
211
|
+
On a **failure**, the thrown `ApiError` carries `status` and `headers`
|
|
212
|
+
directly — see Error Handling below.
|
|
213
|
+
|
|
199
214
|
## Error Handling
|
|
200
215
|
|
|
201
216
|
```typescript
|
|
@@ -227,23 +242,28 @@ try {
|
|
|
227
242
|
The SDK provides builder functions for constructing API request values with full type safety:
|
|
228
243
|
|
|
229
244
|
```typescript
|
|
230
|
-
import { Value,
|
|
245
|
+
import { Value, FuzzyShape, guard, constrained, allen, SortBuilder, psi, LP } from '@kortexya/reasoninglayer';
|
|
231
246
|
|
|
232
|
-
// Tagged values (term CRUD)
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
Value.
|
|
247
|
+
// Tagged values (term CRUD). A plain scalar needs no builder — the resource
|
|
248
|
+
// methods tag it for you. `Value.*` is for the shapes a scalar cannot express.
|
|
249
|
+
const features = { name: 'hello', age: 42 }; // tagged on the way to the wire
|
|
250
|
+
Value.reference('550e8400-e29b-41d4-a716-446655440000')
|
|
251
|
+
// { type: 'Reference', value: '550e8400-…' }
|
|
252
|
+
Value.fuzzyNumber(FuzzyShape.triangular(20, 22, 24))
|
|
253
|
+
// { type: 'FuzzyNumber', value: { kind: 'Triangular', … } }
|
|
236
254
|
|
|
237
|
-
// Untagged values (inference)
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
255
|
+
// Untagged values (inference). `psi()` writes them: a scalar stays a scalar,
|
|
256
|
+
// and a '?Name' string becomes a logic variable.
|
|
257
|
+
psi('employee', { name: '?Name', department: 'Engineering' })
|
|
258
|
+
// { sortName: 'employee', features: { name: { name: '?Name' }, … } }
|
|
241
259
|
|
|
242
|
-
// Guard constraints
|
|
243
|
-
guard('gt', 100) // {
|
|
260
|
+
// Guard constraints — a guard is itself a Ψ-term
|
|
261
|
+
guard('gt', 100) // { sortName: 'guard_constraint', features: { op: 'gt', right: 100 } }
|
|
262
|
+
constrained('?Salary', guard('gt', 80000))
|
|
244
263
|
|
|
245
264
|
// Allen temporal relations
|
|
246
|
-
allen('before'
|
|
265
|
+
allen('before', '?Employment', intervalTermId)
|
|
266
|
+
// { type: 'Allen', intervalA: '?Employment', … }
|
|
247
267
|
|
|
248
268
|
// LP optimization
|
|
249
269
|
LP.maximize({ x: 3, y: 5 }) // objective function
|