@zils/sdk 0.3.0 → 0.4.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 +4 -0
- package/dist/fit.d.ts +7 -0
- package/dist/fit.js +30 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,6 +59,10 @@ apply; one HTTP request does not mean one model evaluation. See the
|
|
|
59
59
|
[ranking contract](https://github.com/ooo-hq/zils-sdk/blob/main/docs/developer-tools.md#ranking)
|
|
60
60
|
for numerical limits, failure behavior, and examples.
|
|
61
61
|
|
|
62
|
+
**New in 0.4.0:** `record(question, fn)` logs a decision function's inputs and
|
|
63
|
+
answers for `zils fit run`, which measures how much of that traffic Zils can take.
|
|
64
|
+
See [zils fit](https://github.com/ooo-hq/zils-sdk/blob/main/docs/fit.md).
|
|
65
|
+
|
|
62
66
|
**New in 0.3.0:** add `groupSize: 4` to the rank request to compare
|
|
63
67
|
overlapping groups instead. Group sizes must be integers from 2 to 10 and are
|
|
64
68
|
capped to the list length. This sends `n` Choice judgments, fits relative Luce
|
package/dist/fit.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shadow-log a decision function for `zils fit run`. Behaviour is unchanged: each call's
|
|
3
|
+
* input and answer are appended to fit-log.jsonl (or ZILS_FIT_LOG). The log holds real
|
|
4
|
+
* inputs, so it is created owner-only. Failed calls are not logged, and a logging error
|
|
5
|
+
* never reaches the caller.
|
|
6
|
+
*/
|
|
7
|
+
export declare function record<A extends unknown[], R>(question: string, fn: (...args: A) => R): (...args: A) => R;
|
package/dist/fit.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.record = record;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
/**
|
|
6
|
+
* Shadow-log a decision function for `zils fit run`. Behaviour is unchanged: each call's
|
|
7
|
+
* input and answer are appended to fit-log.jsonl (or ZILS_FIT_LOG). The log holds real
|
|
8
|
+
* inputs, so it is created owner-only. Failed calls are not logged, and a logging error
|
|
9
|
+
* never reaches the caller.
|
|
10
|
+
*/
|
|
11
|
+
function record(question, fn) {
|
|
12
|
+
return (...args) => {
|
|
13
|
+
const answer = fn(...args);
|
|
14
|
+
const state = args.length === 1 ? args[0] : { args };
|
|
15
|
+
if (answer instanceof Promise) {
|
|
16
|
+
return answer.then(value => { write(question, state, value); return value; });
|
|
17
|
+
}
|
|
18
|
+
write(question, state, answer);
|
|
19
|
+
return answer;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function write(question, state, answer) {
|
|
23
|
+
try {
|
|
24
|
+
const line = JSON.stringify({ question, state, answer, ts: Date.now() / 1000 });
|
|
25
|
+
(0, node_fs_1.appendFileSync)(process.env.ZILS_FIT_LOG || 'fit-log.jsonl', line + '\n', { mode: 0o600 });
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.error(`zils fit: call not recorded (${error.name})`);
|
|
29
|
+
}
|
|
30
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TypeSafeClient, type TypeSafeClientConfig, type APIPromise, type Questions, type SystemOneRequest, type SystemOneResult as BaseResult, type RequestOptions, type Usage as BaseUsage } from '@typesafe-ai/sdk';
|
|
2
2
|
import { type RankRequest, type RankResult } from './ranking.js';
|
|
3
3
|
export type { RankRequest, RankResult, RankedItem } from './ranking.js';
|
|
4
|
+
export { record } from './fit.js';
|
|
4
5
|
export { noul, choice, score, APIError, APIConnectionError, APITimeoutError, APIUserAbortError, AuthenticationError, RateLimitError, TypeSafeError as ZilsError, } from '@typesafe-ai/sdk';
|
|
5
6
|
export type { Question, Questions, SystemOneRequest, RequestOptions, RetryPolicy, ModelCard, NoulQuestion, ChoiceQuestion, ScoreQuestion, NoulResponse, ChoiceResponse, ScoreResponse, JsonValue, EntryType, } from '@typesafe-ai/sdk';
|
|
6
7
|
export interface Usage extends BaseUsage {
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZilsClient = exports.ZilsError = exports.RateLimitError = exports.AuthenticationError = exports.APIUserAbortError = exports.APITimeoutError = exports.APIConnectionError = exports.APIError = exports.score = exports.choice = exports.noul = void 0;
|
|
3
|
+
exports.ZilsClient = exports.ZilsError = exports.RateLimitError = exports.AuthenticationError = exports.APIUserAbortError = exports.APITimeoutError = exports.APIConnectionError = exports.APIError = exports.score = exports.choice = exports.noul = exports.record = void 0;
|
|
4
4
|
const sdk_1 = require("@typesafe-ai/sdk");
|
|
5
5
|
const ranking_js_1 = require("./ranking.js");
|
|
6
|
+
var fit_js_1 = require("./fit.js");
|
|
7
|
+
Object.defineProperty(exports, "record", { enumerable: true, get: function () { return fit_js_1.record; } });
|
|
6
8
|
var sdk_2 = require("@typesafe-ai/sdk");
|
|
7
9
|
Object.defineProperty(exports, "noul", { enumerable: true, get: function () { return sdk_2.noul; } });
|
|
8
10
|
Object.defineProperty(exports, "choice", { enumerable: true, get: function () { return sdk_2.choice; } });
|