jevais 0.1.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/LICENSE +21 -0
- package/README.md +152 -0
- package/dist/client.d.ts +38 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +196 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/meaning.d.ts +40 -0
- package/dist/meaning.d.ts.map +1 -0
- package/dist/meaning.js +116 -0
- package/dist/meaning.js.map +1 -0
- package/dist/types.d.ts +77 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ivo-toby
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
10
|
+
so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# jevais
|
|
2
|
+
|
|
3
|
+
Small semantic functions on top of the [TypeSafe Jev](https://docs.typesafe.ai) API.
|
|
4
|
+
Zero runtime dependencies, native `fetch`, strict TypeScript, ESM only (Node >= 20).
|
|
5
|
+
|
|
6
|
+
Every function makes probability judgments and keeps them honest: a network, API,
|
|
7
|
+
timeout, or malformed-response failure throws a `JevError` — it is never converted
|
|
8
|
+
into `false` or an empty result — and an uncertain judgment is never silently
|
|
9
|
+
treated as `no`.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install jevais
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Auth
|
|
18
|
+
|
|
19
|
+
The `TYPESAFE_API_KEY` environment variable is the default key source, or set it
|
|
20
|
+
once with `configure()`:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { configure } from 'jevais';
|
|
24
|
+
|
|
25
|
+
configure({ apiKey: process.env.TYPESAFE_API_KEY });
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Every function also accepts these options per call (per-call > `configure()` >
|
|
29
|
+
defaults):
|
|
30
|
+
|
|
31
|
+
| option | default | meaning |
|
|
32
|
+
| ----------- | ------------------ | ------------------------------------------------------------------ |
|
|
33
|
+
| `apiKey` | `TYPESAFE_API_KEY` | TypeSafe API key |
|
|
34
|
+
| `model` | `"jev-latest"` | model id sent with every request |
|
|
35
|
+
| `timeoutMs` | `30000` | per-attempt request timeout |
|
|
36
|
+
| `retries` | `3` | retries on HTTP 429/529, exponential backoff, honors `Retry-After` |
|
|
37
|
+
|
|
38
|
+
## ifjev
|
|
39
|
+
|
|
40
|
+
One yes/no question over one state. Resolves `true` when P(yes) >= threshold
|
|
41
|
+
(default 0.85).
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { ifjev } from 'jevais';
|
|
45
|
+
|
|
46
|
+
if (await ifjev('user reacts angry', userResponse, 0.85)) {
|
|
47
|
+
// do thing
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## findMeaning
|
|
52
|
+
|
|
53
|
+
The first item (original order) whose P(yes) >= threshold, or `undefined`.
|
|
54
|
+
One request per item with bounded concurrency (default 4), so completion order
|
|
55
|
+
never changes the result.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { findMeaning } from 'jevais';
|
|
59
|
+
|
|
60
|
+
const match = await findMeaning(messages, 'the customer wants to cancel');
|
|
61
|
+
if (match) {
|
|
62
|
+
// offer the cancellation flow
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## partitionMeaning
|
|
67
|
+
|
|
68
|
+
Splits items by P(yes): `p >= threshold` -> `yes`, `p <= 1 - threshold` -> `no`,
|
|
69
|
+
the rest -> `uncertain`. Uncertain stays explicit — never silently `no`.
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { partitionMeaning } from 'jevais';
|
|
73
|
+
|
|
74
|
+
const { yes, no, uncertain } = await partitionMeaning(
|
|
75
|
+
tickets,
|
|
76
|
+
'the customer explicitly requests a refund',
|
|
77
|
+
{ threshold: 0.85 },
|
|
78
|
+
);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## rankMeaning
|
|
82
|
+
|
|
83
|
+
Orders items by a Score judgment using the identical 2-to-10-level rubric for
|
|
84
|
+
every item; sorted by score descending, stable for ties. Returns the items only.
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import { rankMeaning } from 'jevais';
|
|
88
|
+
|
|
89
|
+
const ranked = await rankMeaning(feedback, [
|
|
90
|
+
'irrelevant noise',
|
|
91
|
+
'minor, optional improvement',
|
|
92
|
+
'clear, actionable improvement',
|
|
93
|
+
'critical, must fix now',
|
|
94
|
+
]);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## changedMeaning
|
|
98
|
+
|
|
99
|
+
Detects a substantive change between two states while ignoring rewording.
|
|
100
|
+
One Noul question over the structured state `{ before, after }`.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { changedMeaning } from 'jevais';
|
|
104
|
+
|
|
105
|
+
if (await changedMeaning(oldConfig, newConfig, 'deployment requirements changed')) {
|
|
106
|
+
// redeploy
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Like `partitionMeaning`, it accepts `threshold` through the options object
|
|
111
|
+
(default `0.85`).
|
|
112
|
+
|
|
113
|
+
## Errors
|
|
114
|
+
|
|
115
|
+
All failures throw `JevError`, which carries the HTTP `status` (when the failure
|
|
116
|
+
came from a response) and a raw `body` snippet:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
import { JevError, ifjev } from 'jevais';
|
|
120
|
+
|
|
121
|
+
try {
|
|
122
|
+
await ifjev('user reacts angry', userResponse);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
if (error instanceof JevError) {
|
|
125
|
+
console.error(`jev failed: ${error.status ?? 'network'} - ${error.message}`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
HTTP 429/529 are retried up to `retries` times with exponential backoff (honoring
|
|
131
|
+
`Retry-After` when present); 401, 422, and everything else throw immediately.
|
|
132
|
+
Empty item arrays resolve with an empty result without calling the API.
|
|
133
|
+
|
|
134
|
+
## Notes
|
|
135
|
+
|
|
136
|
+
- One request per item: every item is judged with its own minimal state, which
|
|
137
|
+
keeps large, irrelevant state from distracting the judge.
|
|
138
|
+
- Keep questions literal, in English, and free of math/counting/date logic.
|
|
139
|
+
|
|
140
|
+
## Development
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
npm install
|
|
144
|
+
npm run lint
|
|
145
|
+
npm run typecheck
|
|
146
|
+
npm run build
|
|
147
|
+
npm test
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## License
|
|
151
|
+
|
|
152
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type JevaisOptions, type ScoreAnswer } from './types.js';
|
|
2
|
+
interface JevErrorOptions {
|
|
3
|
+
status?: number;
|
|
4
|
+
body?: string;
|
|
5
|
+
cause?: unknown;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Error for every jevais failure: missing API key, HTTP error (401, 422, ...),
|
|
9
|
+
* network error, timeout, or malformed response. Public functions never
|
|
10
|
+
* convert a JevError into a false/empty result.
|
|
11
|
+
*/
|
|
12
|
+
export declare class JevError extends Error {
|
|
13
|
+
/** HTTP status, when the failure came from a response. */
|
|
14
|
+
readonly status?: number;
|
|
15
|
+
/** Raw response body snippet, when available. */
|
|
16
|
+
readonly body?: string;
|
|
17
|
+
constructor(message: string, options?: JevErrorOptions);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Set module-level defaults; later calls merge over earlier ones and
|
|
21
|
+
* per-call options still take precedence. When no apiKey is set anywhere,
|
|
22
|
+
* the TYPESAFE_API_KEY environment variable is used.
|
|
23
|
+
*/
|
|
24
|
+
export declare function configure(options?: JevaisOptions): void;
|
|
25
|
+
/**
|
|
26
|
+
* Ask one Noul question over `state` in a single request; resolves P(yes) in
|
|
27
|
+
* [0, 1]. The question id never reaches the model; only `instructions` does.
|
|
28
|
+
* Throws JevError on any failure (never resolves a failure as a probability).
|
|
29
|
+
*/
|
|
30
|
+
export declare function askNoul(instructions: string, state: unknown, options?: JevaisOptions): Promise<number>;
|
|
31
|
+
/**
|
|
32
|
+
* Ask one Score question over `state` in a single request using the given
|
|
33
|
+
* ordered level descriptions (2 to 10 levels). Throws JevError on any
|
|
34
|
+
* failure.
|
|
35
|
+
*/
|
|
36
|
+
export declare function askScore(instructions: string, criteria: readonly string[], state: unknown, options?: JevaisOptions): Promise<ScoreAnswer>;
|
|
37
|
+
export {};
|
|
38
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,aAAa,EAElB,KAAK,WAAW,EAEjB,MAAM,YAAY,CAAC;AAUpB,UAAU,eAAe;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,iDAAiD;IACjD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAM3D;AAKD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,GAAE,aAAkB,GAAG,IAAI,CAK3D;AA8ID;;;;GAIG;AACH,wBAAsB,OAAO,CAC3B,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,MAAM,CAAC,CASjB;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAC5B,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,SAAS,MAAM,EAAE,EAC3B,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,WAAW,CAAC,CAkBtB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { DEFAULT_MODEL, DEFAULT_RETRIES, DEFAULT_TIMEOUT_MS, JEV_ENDPOINT, } from './types.js';
|
|
2
|
+
/** HTTP statuses that are retried with backoff (rate limit / overloaded). */
|
|
3
|
+
const RETRYABLE_STATUSES = [429, 529];
|
|
4
|
+
/** First backoff delay; doubles per retry, capped at MAX_RETRY_DELAY_MS. */
|
|
5
|
+
const BASE_RETRY_DELAY_MS = 500;
|
|
6
|
+
const MAX_RETRY_DELAY_MS = 8000;
|
|
7
|
+
const BODY_SNIPPET_LIMIT = 500;
|
|
8
|
+
/**
|
|
9
|
+
* Error for every jevais failure: missing API key, HTTP error (401, 422, ...),
|
|
10
|
+
* network error, timeout, or malformed response. Public functions never
|
|
11
|
+
* convert a JevError into a false/empty result.
|
|
12
|
+
*/
|
|
13
|
+
export class JevError extends Error {
|
|
14
|
+
/** HTTP status, when the failure came from a response. */
|
|
15
|
+
status;
|
|
16
|
+
/** Raw response body snippet, when available. */
|
|
17
|
+
body;
|
|
18
|
+
constructor(message, options = {}) {
|
|
19
|
+
super(message, options.cause !== undefined ? { cause: options.cause } : undefined);
|
|
20
|
+
this.name = 'JevError';
|
|
21
|
+
this.status = options.status;
|
|
22
|
+
this.body = options.body;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Module-level defaults set through configure(). */
|
|
26
|
+
const moduleConfig = {};
|
|
27
|
+
/**
|
|
28
|
+
* Set module-level defaults; later calls merge over earlier ones and
|
|
29
|
+
* per-call options still take precedence. When no apiKey is set anywhere,
|
|
30
|
+
* the TYPESAFE_API_KEY environment variable is used.
|
|
31
|
+
*/
|
|
32
|
+
export function configure(options = {}) {
|
|
33
|
+
if (options.apiKey !== undefined)
|
|
34
|
+
moduleConfig.apiKey = options.apiKey;
|
|
35
|
+
if (options.model !== undefined)
|
|
36
|
+
moduleConfig.model = options.model;
|
|
37
|
+
if (options.timeoutMs !== undefined)
|
|
38
|
+
moduleConfig.timeoutMs = options.timeoutMs;
|
|
39
|
+
if (options.retries !== undefined)
|
|
40
|
+
moduleConfig.retries = options.retries;
|
|
41
|
+
}
|
|
42
|
+
/** Throws (before any fetch) when no API key is available. */
|
|
43
|
+
function resolveConfig(overrides) {
|
|
44
|
+
const apiKey = overrides?.apiKey ?? moduleConfig.apiKey ?? process.env.TYPESAFE_API_KEY;
|
|
45
|
+
if (apiKey === undefined || apiKey === '') {
|
|
46
|
+
throw new JevError('Missing TypeSafe API key: pass { apiKey }, configure({ apiKey }), or set TYPESAFE_API_KEY.');
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
apiKey,
|
|
50
|
+
model: overrides?.model ?? moduleConfig.model ?? DEFAULT_MODEL,
|
|
51
|
+
timeoutMs: overrides?.timeoutMs ?? moduleConfig.timeoutMs ?? DEFAULT_TIMEOUT_MS,
|
|
52
|
+
retries: overrides?.retries ?? moduleConfig.retries ?? DEFAULT_RETRIES,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* POST one question set over the shared `state` and return the validated
|
|
57
|
+
* response. Retries 429/529 (up to `retries` times, exponential backoff,
|
|
58
|
+
* honoring numeric Retry-After in seconds); every other failure throws a
|
|
59
|
+
* JevError carrying status and/or a raw body snippet.
|
|
60
|
+
*/
|
|
61
|
+
async function postJev(questions, state, config) {
|
|
62
|
+
const payload = JSON.stringify({ state, model: config.model, questions });
|
|
63
|
+
let retry = 0;
|
|
64
|
+
for (;;) {
|
|
65
|
+
let response;
|
|
66
|
+
try {
|
|
67
|
+
response = await fetch(JEV_ENDPOINT, {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
headers: {
|
|
70
|
+
Authorization: `Bearer ${config.apiKey}`,
|
|
71
|
+
'Content-Type': 'application/json',
|
|
72
|
+
},
|
|
73
|
+
body: payload,
|
|
74
|
+
signal: AbortSignal.timeout(config.timeoutMs),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (cause) {
|
|
78
|
+
throw new JevError(`Jev request failed: ${describe(cause)}`, { cause });
|
|
79
|
+
}
|
|
80
|
+
if (RETRYABLE_STATUSES.includes(response.status)) {
|
|
81
|
+
if (retry >= config.retries) {
|
|
82
|
+
const body = await bodySnippet(response);
|
|
83
|
+
throw new JevError(`Jev API returned HTTP ${response.status} after ${retry + 1} attempt${retry === 0 ? '' : 's'}`, {
|
|
84
|
+
status: response.status,
|
|
85
|
+
body,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
retry += 1;
|
|
89
|
+
await sleep(retryDelayMs(response, retry));
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (!response.ok) {
|
|
93
|
+
const body = await bodySnippet(response);
|
|
94
|
+
throw new JevError(`Jev API request failed with HTTP ${response.status}`, {
|
|
95
|
+
status: response.status,
|
|
96
|
+
body,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
let data;
|
|
100
|
+
try {
|
|
101
|
+
data = await response.json();
|
|
102
|
+
}
|
|
103
|
+
catch (cause) {
|
|
104
|
+
throw new JevError('Jev API returned a malformed (non-JSON) response body', { cause });
|
|
105
|
+
}
|
|
106
|
+
return validateResponse(data);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function retryDelayMs(response, retry) {
|
|
110
|
+
const raw = response.headers.get('retry-after');
|
|
111
|
+
if (raw !== null) {
|
|
112
|
+
const seconds = Number(raw);
|
|
113
|
+
if (Number.isFinite(seconds) && seconds >= 0)
|
|
114
|
+
return seconds * 1000;
|
|
115
|
+
}
|
|
116
|
+
return Math.min(BASE_RETRY_DELAY_MS * 2 ** (retry - 1), MAX_RETRY_DELAY_MS);
|
|
117
|
+
}
|
|
118
|
+
function sleep(ms) {
|
|
119
|
+
return new Promise((resolve) => {
|
|
120
|
+
setTimeout(resolve, ms);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
function describe(cause) {
|
|
124
|
+
return cause instanceof Error ? cause.message : String(cause);
|
|
125
|
+
}
|
|
126
|
+
async function bodySnippet(response) {
|
|
127
|
+
try {
|
|
128
|
+
const text = await response.text();
|
|
129
|
+
if (text === '')
|
|
130
|
+
return undefined;
|
|
131
|
+
return text.length > BODY_SNIPPET_LIMIT ? `${text.slice(0, BODY_SNIPPET_LIMIT)}...` : text;
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function isPlainObject(value) {
|
|
138
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
139
|
+
}
|
|
140
|
+
function validateResponse(data) {
|
|
141
|
+
if (!isPlainObject(data)) {
|
|
142
|
+
throw new JevError('Jev API returned a malformed response body');
|
|
143
|
+
}
|
|
144
|
+
if (!isPlainObject(data.answers)) {
|
|
145
|
+
throw new JevError('Jev API returned a malformed response body: missing "answers"');
|
|
146
|
+
}
|
|
147
|
+
if (typeof data.model !== 'string') {
|
|
148
|
+
throw new JevError('Jev API returned a malformed response body: "model" is not a string');
|
|
149
|
+
}
|
|
150
|
+
if (!isPlainObject(data.usage)) {
|
|
151
|
+
throw new JevError('Jev API returned a malformed response body: missing "usage"');
|
|
152
|
+
}
|
|
153
|
+
// Runtime validation above; the Record narrowing cannot express JevResponse.
|
|
154
|
+
return data;
|
|
155
|
+
}
|
|
156
|
+
function isUnitProbability(value) {
|
|
157
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 1;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Ask one Noul question over `state` in a single request; resolves P(yes) in
|
|
161
|
+
* [0, 1]. The question id never reaches the model; only `instructions` does.
|
|
162
|
+
* Throws JevError on any failure (never resolves a failure as a probability).
|
|
163
|
+
*/
|
|
164
|
+
export async function askNoul(instructions, state, options) {
|
|
165
|
+
const config = resolveConfig(options);
|
|
166
|
+
const questions = { noul: { type: 'noul', instructions } };
|
|
167
|
+
const response = await postJev(questions, state, config);
|
|
168
|
+
const answer = response.answers.noul;
|
|
169
|
+
if (answer === undefined || answer.type !== 'noul' || !isUnitProbability(answer.noul)) {
|
|
170
|
+
throw new JevError('Jev API returned a malformed Noul answer');
|
|
171
|
+
}
|
|
172
|
+
return answer.noul;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Ask one Score question over `state` in a single request using the given
|
|
176
|
+
* ordered level descriptions (2 to 10 levels). Throws JevError on any
|
|
177
|
+
* failure.
|
|
178
|
+
*/
|
|
179
|
+
export async function askScore(instructions, criteria, state, options) {
|
|
180
|
+
const config = resolveConfig(options);
|
|
181
|
+
const questions = {
|
|
182
|
+
score: { type: 'score', instructions, criteria: [...criteria] },
|
|
183
|
+
};
|
|
184
|
+
const response = await postJev(questions, state, config);
|
|
185
|
+
const answer = response.answers.score;
|
|
186
|
+
if (answer === undefined ||
|
|
187
|
+
answer.type !== 'score' ||
|
|
188
|
+
!Number.isFinite(answer.score) ||
|
|
189
|
+
typeof answer.confidence !== 'number' ||
|
|
190
|
+
!isPlainObject(answer.legend) ||
|
|
191
|
+
!isPlainObject(answer.probabilities)) {
|
|
192
|
+
throw new JevError('Jev API returned a malformed Score answer');
|
|
193
|
+
}
|
|
194
|
+
return answer;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,YAAY,GAMb,MAAM,YAAY,CAAC;AAEpB,6EAA6E;AAC7E,MAAM,kBAAkB,GAAsB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAEzD,4EAA4E;AAC5E,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAChC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAQ/B;;;;GAIG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC,0DAA0D;IACjD,MAAM,CAAU;IACzB,iDAAiD;IACxC,IAAI,CAAU;IAEvB,YAAY,OAAe,EAAE,UAA2B,EAAE;QACxD,KAAK,CAAC,OAAO,EAAE,OA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AK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC,EAAE;KAChE,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC;IACtC,IACE,MAAM,KAAK,SAAS;QACpB,MAAM,CAAC,IAAI,KAAK,OAAO;QACvB,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC;QAC9B,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ;QACrC,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC;QAC7B,CAAC,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,EACpC,CAAC;QACD,MAAM,IAAI,QAAQ,CAAC,2CAA2C,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { JevError, configure } from './client.js';
|
|
2
|
+
export { changedMeaning, findMeaning, ifjev, partitionMeaning, rankMeaning } from './meaning.js';
|
|
3
|
+
export type { PartitionResult } from './meaning.js';
|
|
4
|
+
export type { JevAnswer, JevQuestion, JevResponse, JevUsage, JevaisOptions, MeaningOptions, NoulAnswer, NoulQuestion, RankOptions, ScoreAnswer, ScoreQuestion, } from './types.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACjG,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EACV,SAAS,EACT,WAAW,EACX,WAAW,EACX,QAAQ,EACR,aAAa,EACb,cAAc,EACd,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,aAAa,GACd,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type JevaisOptions, type MeaningOptions, type RankOptions } from './types.js';
|
|
2
|
+
/** Partition result of partitionMeaning. */
|
|
3
|
+
export interface PartitionResult<T> {
|
|
4
|
+
yes: T[];
|
|
5
|
+
no: T[];
|
|
6
|
+
uncertain: T[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Ask whether `question` holds of `state`; resolves true when P(yes) >=
|
|
10
|
+
* threshold. One Noul question in one request.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ifjev(question: string, state: unknown, threshold?: number, options?: JevaisOptions): Promise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* Return the first item (original order) whose P(yes) >= threshold, or
|
|
15
|
+
* undefined when none match. One Noul request per item with bounded
|
|
16
|
+
* concurrency, so completion order never affects the result. Empty input
|
|
17
|
+
* resolves undefined without calling the API.
|
|
18
|
+
*/
|
|
19
|
+
export declare function findMeaning<T>(items: readonly T[], question: string, options?: MeaningOptions): Promise<T | undefined>;
|
|
20
|
+
/**
|
|
21
|
+
* Split items by P(yes): p >= threshold -> yes, p <= 1 - threshold -> no,
|
|
22
|
+
* everything else -> uncertain. Uncertain is explicit and never silently
|
|
23
|
+
* treated as no. One Noul request per item with bounded concurrency. Empty
|
|
24
|
+
* input returns three empty arrays without calling the API.
|
|
25
|
+
*/
|
|
26
|
+
export declare function partitionMeaning<T>(items: readonly T[], question: string, options?: MeaningOptions): Promise<PartitionResult<T>>;
|
|
27
|
+
/**
|
|
28
|
+
* Order items by a Score judgment using the identical 2-to-10-level rubric
|
|
29
|
+
* for every item; sorted by score descending, stable for ties. Returns the
|
|
30
|
+
* items only (no scores). One Score request per item with bounded
|
|
31
|
+
* concurrency. Invalid levels (empty, one, or > 10) throw before any fetch;
|
|
32
|
+
* empty input returns [] without calling the API.
|
|
33
|
+
*/
|
|
34
|
+
export declare function rankMeaning<T>(items: readonly T[], levels: readonly string[], options?: RankOptions): Promise<T[]>;
|
|
35
|
+
/**
|
|
36
|
+
* Ask whether `after` changed in the sense of `question`, judged over the
|
|
37
|
+
* structured state { before, after }; resolves true when P(yes) >= threshold.
|
|
38
|
+
*/
|
|
39
|
+
export declare function changedMeaning(before: unknown, after: unknown, question: string, options?: MeaningOptions): Promise<boolean>;
|
|
40
|
+
//# sourceMappingURL=meaning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meaning.d.ts","sourceRoot":"","sources":["../src/meaning.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,WAAW,EACjB,MAAM,YAAY,CAAC;AAQpB,4CAA4C;AAC5C,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,GAAG,EAAE,CAAC,EAAE,CAAC;IACT,EAAE,EAAE,CAAC,EAAE,CAAC;IACR,SAAS,EAAE,CAAC,EAAE,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAsB,KAAK,CACzB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,EACd,SAAS,GAAE,MAA0B,EACrC,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,CAAC,EACjC,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAMxB;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAa7B;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,CAAC,EACjC,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,CAAC,EAAE,CAAC,CAYd;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,OAAO,CAAC,CAGlB"}
|
package/dist/meaning.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { JevError, askNoul, askScore } from './client.js';
|
|
2
|
+
import { DEFAULT_CONCURRENCY, DEFAULT_THRESHOLD, } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Neutral instructions for ranking: the ordered `levels` carry the rubric, so
|
|
5
|
+
* the wording stays identical (and literal) for every item.
|
|
6
|
+
*/
|
|
7
|
+
const RANK_INSTRUCTIONS = 'Rate this item on the provided scale.';
|
|
8
|
+
/**
|
|
9
|
+
* Ask whether `question` holds of `state`; resolves true when P(yes) >=
|
|
10
|
+
* threshold. One Noul question in one request.
|
|
11
|
+
*/
|
|
12
|
+
export async function ifjev(question, state, threshold = DEFAULT_THRESHOLD, options) {
|
|
13
|
+
const p = await askNoul(question, state, options);
|
|
14
|
+
return p >= threshold;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Return the first item (original order) whose P(yes) >= threshold, or
|
|
18
|
+
* undefined when none match. One Noul request per item with bounded
|
|
19
|
+
* concurrency, so completion order never affects the result. Empty input
|
|
20
|
+
* resolves undefined without calling the API.
|
|
21
|
+
*/
|
|
22
|
+
export async function findMeaning(items, question, options) {
|
|
23
|
+
if (items.length === 0)
|
|
24
|
+
return undefined;
|
|
25
|
+
const threshold = options?.threshold ?? DEFAULT_THRESHOLD;
|
|
26
|
+
const probabilities = await judgeAll(items, question, options);
|
|
27
|
+
const index = probabilities.findIndex((p) => p >= threshold);
|
|
28
|
+
return index === -1 ? undefined : items[index];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Split items by P(yes): p >= threshold -> yes, p <= 1 - threshold -> no,
|
|
32
|
+
* everything else -> uncertain. Uncertain is explicit and never silently
|
|
33
|
+
* treated as no. One Noul request per item with bounded concurrency. Empty
|
|
34
|
+
* input returns three empty arrays without calling the API.
|
|
35
|
+
*/
|
|
36
|
+
export async function partitionMeaning(items, question, options) {
|
|
37
|
+
const result = { yes: [], no: [], uncertain: [] };
|
|
38
|
+
if (items.length === 0)
|
|
39
|
+
return result;
|
|
40
|
+
const threshold = options?.threshold ?? DEFAULT_THRESHOLD;
|
|
41
|
+
const noCutoff = 1 - threshold;
|
|
42
|
+
const probabilities = await judgeAll(items, question, options);
|
|
43
|
+
for (let i = 0; i < items.length; i += 1) {
|
|
44
|
+
const p = probabilities[i];
|
|
45
|
+
if (p >= threshold)
|
|
46
|
+
result.yes.push(items[i]);
|
|
47
|
+
else if (p <= noCutoff)
|
|
48
|
+
result.no.push(items[i]);
|
|
49
|
+
else
|
|
50
|
+
result.uncertain.push(items[i]);
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Order items by a Score judgment using the identical 2-to-10-level rubric
|
|
56
|
+
* for every item; sorted by score descending, stable for ties. Returns the
|
|
57
|
+
* items only (no scores). One Score request per item with bounded
|
|
58
|
+
* concurrency. Invalid levels (empty, one, or > 10) throw before any fetch;
|
|
59
|
+
* empty input returns [] without calling the API.
|
|
60
|
+
*/
|
|
61
|
+
export async function rankMeaning(items, levels, options) {
|
|
62
|
+
assertLevels(levels);
|
|
63
|
+
if (items.length === 0)
|
|
64
|
+
return [];
|
|
65
|
+
const scores = await mapWithConcurrency(items, concurrencyOf(options), async (item) => {
|
|
66
|
+
const answer = await askScore(RANK_INSTRUCTIONS, levels, item, options);
|
|
67
|
+
return answer.score;
|
|
68
|
+
});
|
|
69
|
+
const order = scores
|
|
70
|
+
.map((score, index) => ({ index, score }))
|
|
71
|
+
.sort((a, b) => b.score - a.score || a.index - b.index)
|
|
72
|
+
.map((entry) => entry.index);
|
|
73
|
+
return order.map((index) => items[index]);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Ask whether `after` changed in the sense of `question`, judged over the
|
|
77
|
+
* structured state { before, after }; resolves true when P(yes) >= threshold.
|
|
78
|
+
*/
|
|
79
|
+
export async function changedMeaning(before, after, question, options) {
|
|
80
|
+
const p = await askNoul(question, { before, after }, options);
|
|
81
|
+
return p >= (options?.threshold ?? DEFAULT_THRESHOLD);
|
|
82
|
+
}
|
|
83
|
+
/** One Noul request per item, bounded concurrency, results in input order. */
|
|
84
|
+
async function judgeAll(items, question, options) {
|
|
85
|
+
return mapWithConcurrency(items, concurrencyOf(options), (item) => askNoul(question, item, options));
|
|
86
|
+
}
|
|
87
|
+
function assertLevels(levels) {
|
|
88
|
+
if (!Array.isArray(levels) || levels.length < 2 || levels.length > 10) {
|
|
89
|
+
throw new JevError('levels must be an array of 2 to 10 ordered level descriptions');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function concurrencyOf(options) {
|
|
93
|
+
const concurrency = options?.concurrency ?? DEFAULT_CONCURRENCY;
|
|
94
|
+
if (!Number.isInteger(concurrency) || concurrency < 1) {
|
|
95
|
+
throw new JevError('concurrency must be a positive integer');
|
|
96
|
+
}
|
|
97
|
+
return concurrency;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Run `fn` over `items` with at most `limit` calls in flight; results keep
|
|
101
|
+
* input order. Any rejection rejects the whole operation (failures are never
|
|
102
|
+
* turned into missing/empty results).
|
|
103
|
+
*/
|
|
104
|
+
async function mapWithConcurrency(items, limit, fn) {
|
|
105
|
+
const results = new Array(items.length);
|
|
106
|
+
let next = 0;
|
|
107
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
108
|
+
while (next < items.length) {
|
|
109
|
+
const index = next;
|
|
110
|
+
next += 1;
|
|
111
|
+
results[index] = await fn(items[index], index);
|
|
112
|
+
}
|
|
113
|
+
}));
|
|
114
|
+
return results;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=meaning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meaning.js","sourceRoot":"","sources":["../src/meaning.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EACL,mBAAmB,EACnB,iBAAiB,GAIlB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,iBAAiB,GAAG,uCAAuC,CAAC;AASlE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,QAAgB,EAChB,KAAc,EACd,YAAoB,iBAAiB,EACrC,OAAuB;IAEvB,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAClD,OAAO,CAAC,IAAI,SAAS,CAAC;AACxB,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,KAAmB,EACnB,QAAgB,EAChB,OAAwB;IAExB,IAAI,KAAK,CAAC,MAAM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IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,IAAI,EAAE;QAC/D,OAAO,IAAI,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YAC3B,MAAM,KAAK,GAAG,IAAI,CAAC;YACnB,IAAI,IAAI,CAAC,CAAC;YACV,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC;IACH,CAAC,CAAC,CACH,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/** TypeSafe Jev systemone endpoint. */
|
|
2
|
+
export declare const JEV_ENDPOINT = "https://api.typesafe.ai/v1/systemone";
|
|
3
|
+
/** Default model id. */
|
|
4
|
+
export declare const DEFAULT_MODEL = "jev-latest";
|
|
5
|
+
/** Default per-attempt request timeout in milliseconds. */
|
|
6
|
+
export declare const DEFAULT_TIMEOUT_MS = 30000;
|
|
7
|
+
/** Default number of 429/529 retries after the first attempt. */
|
|
8
|
+
export declare const DEFAULT_RETRIES = 3;
|
|
9
|
+
/** Default yes threshold: p >= threshold counts as yes. */
|
|
10
|
+
export declare const DEFAULT_THRESHOLD = 0.85;
|
|
11
|
+
/** Default cap on in-flight per-item requests. */
|
|
12
|
+
export declare const DEFAULT_CONCURRENCY = 4;
|
|
13
|
+
/** Noul (yes/no) question; `instructions` carries the question wording. */
|
|
14
|
+
export interface NoulQuestion {
|
|
15
|
+
type: 'noul';
|
|
16
|
+
instructions: string | object | unknown[];
|
|
17
|
+
criteria?: {
|
|
18
|
+
true?: unknown;
|
|
19
|
+
false?: unknown;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** Score question; `criteria` is 2 to 10 ordered level descriptions. */
|
|
23
|
+
export interface ScoreQuestion {
|
|
24
|
+
type: 'score';
|
|
25
|
+
instructions: string | object | unknown[];
|
|
26
|
+
criteria: string[];
|
|
27
|
+
}
|
|
28
|
+
export type JevQuestion = NoulQuestion | ScoreQuestion;
|
|
29
|
+
/** Noul answer: `noul` is P(yes) in [0, 1]. There is no confidence field. */
|
|
30
|
+
export interface NoulAnswer {
|
|
31
|
+
type: 'noul';
|
|
32
|
+
noul: number;
|
|
33
|
+
}
|
|
34
|
+
/** Score answer. Level keys are stringified indices ("0", "1", ...). */
|
|
35
|
+
export interface ScoreAnswer {
|
|
36
|
+
type: 'score';
|
|
37
|
+
/** Fractional score; may land between levels. */
|
|
38
|
+
score: number;
|
|
39
|
+
legend: Record<string, unknown>;
|
|
40
|
+
probabilities: Record<string, number>;
|
|
41
|
+
confidence: number;
|
|
42
|
+
}
|
|
43
|
+
export type JevAnswer = NoulAnswer | ScoreAnswer;
|
|
44
|
+
export interface JevUsage {
|
|
45
|
+
input_tokens: number;
|
|
46
|
+
output_tokens: number;
|
|
47
|
+
}
|
|
48
|
+
/** Response body of POST /v1/systemone. */
|
|
49
|
+
export interface JevResponse {
|
|
50
|
+
model: string;
|
|
51
|
+
answers: Record<string, JevAnswer>;
|
|
52
|
+
usage: JevUsage;
|
|
53
|
+
}
|
|
54
|
+
/** Module-level and per-call options shared by every jevais function. */
|
|
55
|
+
export interface JevaisOptions {
|
|
56
|
+
/** TypeSafe API key; falls back to configure(), then TYPESAFE_API_KEY. */
|
|
57
|
+
apiKey?: string;
|
|
58
|
+
/** Model id. Default: "jev-latest". */
|
|
59
|
+
model?: string;
|
|
60
|
+
/** Per-attempt request timeout in ms. Default: 30000. */
|
|
61
|
+
timeoutMs?: number;
|
|
62
|
+
/** 429/529 retries after the first attempt. Default: 3. */
|
|
63
|
+
retries?: number;
|
|
64
|
+
}
|
|
65
|
+
/** Options for threshold-based judgments. */
|
|
66
|
+
export interface MeaningOptions extends JevaisOptions {
|
|
67
|
+
/** Yes threshold, expected in (0, 1). Default: 0.85. */
|
|
68
|
+
threshold?: number;
|
|
69
|
+
/** Max in-flight per-item requests. Default: 4. */
|
|
70
|
+
concurrency?: number;
|
|
71
|
+
}
|
|
72
|
+
/** Options for rankMeaning. */
|
|
73
|
+
export interface RankOptions extends JevaisOptions {
|
|
74
|
+
/** Max in-flight per-item requests. Default: 4. */
|
|
75
|
+
concurrency?: number;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,eAAO,MAAM,YAAY,yCAAyC,CAAC;AAEnE,wBAAwB;AACxB,eAAO,MAAM,aAAa,eAAe,CAAC;AAE1C,2DAA2D;AAC3D,eAAO,MAAM,kBAAkB,QAAS,CAAC;AAEzC,iEAAiE;AACjE,eAAO,MAAM,eAAe,IAAI,CAAC;AAEjC,2DAA2D;AAC3D,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAEtC,kDAAkD;AAClD,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,2EAA2E;AAC3E,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,CAAC;IAC1C,QAAQ,CAAC,EAAE;QACT,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,CAAC;CACH;AAED,wEAAwE;AACxE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,EAAE,CAAC;IAC1C,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,aAAa,CAAC;AAEvD,6EAA6E;AAC7E,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;C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one';
|
|
3
|
+
/** Default model id. */
|
|
4
|
+
export const DEFAULT_MODEL = 'jev-latest';
|
|
5
|
+
/** Default per-attempt request timeout in milliseconds. */
|
|
6
|
+
export const DEFAULT_TIMEOUT_MS = 30_000;
|
|
7
|
+
/** Default number of 429/529 retries after the first attempt. */
|
|
8
|
+
export const DEFAULT_RETRIES = 3;
|
|
9
|
+
/** Default yes threshold: p >= threshold counts as yes. */
|
|
10
|
+
export const DEFAULT_THRESHOLD = 0.85;
|
|
11
|
+
/** Default cap on in-flight per-item requests. */
|
|
12
|
+
export const DEFAULT_CONCURRENCY = 4;
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,MAAM,CAAC,MAAM,YAAY,GAAG,sCAAsC,CAAC;AAEnE,wBAAwB;AACxB,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAC;AAE1C,2DAA2D;AAC3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAEzC,iEAAiE;AACjE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AAEjC,2DAA2D;AAC3D,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAEtC,kDAAkD;AAClD,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jevais",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Small semantic functions on top of the TypeSafe Jev API: ifjev, findMeaning, partitionMeaning, rankMeaning, changedMeaning.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"jev",
|
|
7
|
+
"typesafe",
|
|
8
|
+
"noul",
|
|
9
|
+
"score",
|
|
10
|
+
"llm",
|
|
11
|
+
"semantic",
|
|
12
|
+
"classification",
|
|
13
|
+
"typescript"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "ivo-toby",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/ivo-toby/jevais.git"
|
|
20
|
+
},
|
|
21
|
+
"type": "module",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=20"
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"LICENSE",
|
|
36
|
+
"README.md"
|
|
37
|
+
],
|
|
38
|
+
"sideEffects": false,
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -p tsconfig.json",
|
|
44
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json",
|
|
45
|
+
"lint": "eslint .",
|
|
46
|
+
"format": "prettier --write .",
|
|
47
|
+
"format:check": "prettier --check .",
|
|
48
|
+
"test": "vitest run",
|
|
49
|
+
"prepublishOnly": "npm run build"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@eslint/js": "^9.17.0",
|
|
53
|
+
"@types/node": "^20.11.0",
|
|
54
|
+
"eslint": "^9.17.0",
|
|
55
|
+
"prettier": "^3.4.2",
|
|
56
|
+
"typescript": "^5.6.3",
|
|
57
|
+
"typescript-eslint": "^8.18.0",
|
|
58
|
+
"vitest": "^2.1.9"
|
|
59
|
+
}
|
|
60
|
+
}
|