@anvia/jev 0.2.1 → 0.3.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/dist/index.d.ts +26 -36
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +252 -336
- package/dist/index.js.map +1 -1
- package/dist/rolldown-runtime-D8jQpDG7.js +12 -0
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,45 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
declare const
|
|
6
|
-
type KnownJevDecisionModelId = typeof JEV_LATEST;
|
|
1
|
+
import { ModelId, ModelList, ModelListingClient } from "@anvia/core/model-listing";
|
|
2
|
+
import { TypeSafeClient } from "@typesafe-ai/sdk";
|
|
3
|
+
import { DecisionModel } from "@anvia/core/decision";
|
|
4
|
+
export declare const JEV_LATEST = "jev-latest";
|
|
5
|
+
export declare const JEV_PREVIEW = "jev-preview";
|
|
6
|
+
type KnownJevDecisionModelId = typeof JEV_LATEST | typeof JEV_PREVIEW;
|
|
7
7
|
type JevDecisionModelId = ModelId<KnownJevDecisionModelId>;
|
|
8
|
-
|
|
9
8
|
type JevClientOptions = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
apiKey?: string | undefined;
|
|
10
|
+
baseUrl?: string | undefined;
|
|
11
|
+
headers?: Record<string, string> | undefined;
|
|
12
|
+
client?: never;
|
|
14
13
|
} | {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
client: TypeSafeClient;
|
|
15
|
+
apiKey?: never;
|
|
16
|
+
baseUrl?: never;
|
|
17
|
+
headers?: never;
|
|
19
18
|
};
|
|
20
19
|
type JevDecisionModelOptions = {
|
|
21
|
-
|
|
20
|
+
modelId: JevDecisionModelId;
|
|
22
21
|
};
|
|
23
22
|
type JevDecisionModelHandle = DecisionModel<unknown>;
|
|
24
|
-
declare class JevClient implements ModelListingClient {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
export declare class JevClient implements ModelListingClient {
|
|
24
|
+
private readonly sdk;
|
|
25
|
+
constructor(options: JevClientOptions);
|
|
26
|
+
decisionModel(options: JevDecisionModelOptions): JevDecisionModelHandle;
|
|
27
|
+
listModels(options?: {
|
|
28
|
+
abortSignal?: AbortSignal | undefined;
|
|
29
|
+
}): Promise<ModelList>;
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
type index_JevClient = JevClient;
|
|
35
|
-
declare const index_JevClient: typeof JevClient;
|
|
36
|
-
type index_JevClientOptions = JevClientOptions;
|
|
37
|
-
type index_JevDecisionModelHandle = JevDecisionModelHandle;
|
|
38
|
-
type index_JevDecisionModelId = JevDecisionModelId;
|
|
39
|
-
type index_JevDecisionModelOptions = JevDecisionModelOptions;
|
|
40
|
-
type index_KnownJevDecisionModelId = KnownJevDecisionModelId;
|
|
41
|
-
declare namespace index {
|
|
42
|
-
export { index_JEV_LATEST as JEV_LATEST, index_JevClient as JevClient, type index_JevClientOptions as JevClientOptions, type index_JevDecisionModelHandle as JevDecisionModelHandle, type index_JevDecisionModelId as JevDecisionModelId, type index_JevDecisionModelOptions as JevDecisionModelOptions, type index_KnownJevDecisionModelId as KnownJevDecisionModelId };
|
|
31
|
+
declare namespace index_d_exports {
|
|
32
|
+
export { JEV_LATEST, JEV_PREVIEW, JevClient, JevClientOptions, JevDecisionModelHandle, JevDecisionModelId, JevDecisionModelOptions, KnownJevDecisionModelId };
|
|
43
33
|
}
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
export { type JevClientOptions, type JevDecisionModelHandle, type JevDecisionModelId, type JevDecisionModelOptions, type KnownJevDecisionModelId, index_d_exports as jev };
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/jev/models.ts","../src/jev/client.ts","../src/jev/index.ts"],"mappings":";;;qBAEa;qBACA;KACD,iCAAiC,oBAAoB;KACrD,qBAAqB,QAAQ;KCM7B;EAEN;EACA;EACA,UAAU;EACV;;EAGA,QAAQ;EACR;EACA;EACA;;KAGM;EAA4B,SAAS;;KACrC,yBAAyB;qBAExB,qBAAqB;mBACf;EAEL,YAAA,SAAS;EA8BrB,cAAc,SAAS,0BAA0B;EAO3C,WAAW;IAAY,cAAc;MAA4B,QAAQ"}
|
package/dist/index.js
CHANGED
|
@@ -1,363 +1,279 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
// src/jev/index.ts
|
|
8
|
-
var jev_exports = {};
|
|
9
|
-
__export(jev_exports, {
|
|
10
|
-
JEV_LATEST: () => JEV_LATEST,
|
|
11
|
-
JevClient: () => JevClient
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// src/jev/client.ts
|
|
15
|
-
import {
|
|
16
|
-
ModelListingError
|
|
17
|
-
} from "@anvia/core/model-listing";
|
|
18
|
-
import { TypeSafeClient } from "@typesafe-ai/sdk";
|
|
19
|
-
|
|
20
|
-
// src/jev/decision.ts
|
|
21
|
-
import {
|
|
22
|
-
DecisionProviderOutputError
|
|
23
|
-
} from "@anvia/core/decision";
|
|
24
|
-
import { isJsonValue, Usage } from "@anvia/core/completion";
|
|
25
|
-
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
|
|
2
|
+
import { ModelListingError } from "@anvia/core/model-listing";
|
|
3
|
+
import { APITimeoutError, TypeSafeClient } from "@typesafe-ai/sdk";
|
|
4
|
+
import { DecisionProviderOutputError } from "@anvia/core/decision";
|
|
5
|
+
import { Usage, isJsonValue } from "@anvia/core/completion";
|
|
26
6
|
// src/jev/errors.ts
|
|
27
|
-
|
|
7
|
+
/** Distinguish SDK timeout cancellation from cancellation requested by the caller. */
|
|
28
8
|
function normalizeJevError(error, abortSignal) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
9
|
+
if (abortSignal?.aborted) {
|
|
10
|
+
const aborted = new Error("The Jev request was aborted.", { cause: error });
|
|
11
|
+
aborted.name = "AbortError";
|
|
12
|
+
return aborted;
|
|
13
|
+
}
|
|
14
|
+
if (error instanceof APITimeoutError) return Object.assign(new Error(error.message), {
|
|
15
|
+
name: "TimeoutError",
|
|
16
|
+
providerError: error
|
|
17
|
+
});
|
|
18
|
+
return error;
|
|
38
19
|
}
|
|
39
|
-
|
|
40
20
|
// src/jev/decision.ts
|
|
41
21
|
var JevDecisionModel = class {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
const scoreProbabilities = answer.probabilities;
|
|
187
|
-
validateDistribution(
|
|
188
|
-
scoreProbabilities,
|
|
189
|
-
levelKeys,
|
|
190
|
-
() => fail("Jev returned invalid score probabilities.", name)
|
|
191
|
-
);
|
|
192
|
-
if (typeof answer.score !== "number" || !Number.isFinite(answer.score) || answer.score < 0 || answer.score > question.rubric.length - 1) {
|
|
193
|
-
return fail("Jev returned a score outside the requested rubric.", name);
|
|
194
|
-
}
|
|
195
|
-
return [
|
|
196
|
-
name,
|
|
197
|
-
{
|
|
198
|
-
type: "score",
|
|
199
|
-
score: answer.score,
|
|
200
|
-
rubric: question.rubric,
|
|
201
|
-
probabilities: levelKeys.map((key) => scoreProbabilities[key]),
|
|
202
|
-
confidence: answer.confidence
|
|
203
|
-
}
|
|
204
|
-
];
|
|
205
|
-
})
|
|
206
|
-
);
|
|
207
|
-
const usage = rawResponse.usage;
|
|
208
|
-
if (!isDataObject(usage) || !isTokenCount(usage.input_tokens) || !isTokenCount(usage.output_tokens)) {
|
|
209
|
-
return fail("Jev returned invalid token usage.");
|
|
210
|
-
}
|
|
211
|
-
return {
|
|
212
|
-
answers,
|
|
213
|
-
usage: {
|
|
214
|
-
...Usage.empty(),
|
|
215
|
-
inputTokens: usage.input_tokens,
|
|
216
|
-
outputTokens: usage.output_tokens,
|
|
217
|
-
totalTokens: usage.input_tokens + usage.output_tokens
|
|
218
|
-
},
|
|
219
|
-
rawResponse
|
|
220
|
-
};
|
|
221
|
-
}
|
|
22
|
+
sdk;
|
|
23
|
+
modelId;
|
|
24
|
+
provider = "jev";
|
|
25
|
+
capabilities = Object.freeze({
|
|
26
|
+
questionSupport: Object.freeze({
|
|
27
|
+
choice: "native",
|
|
28
|
+
"multi-label": "composed",
|
|
29
|
+
score: "native",
|
|
30
|
+
check: "native"
|
|
31
|
+
}),
|
|
32
|
+
mixedQuestions: true,
|
|
33
|
+
limits: Object.freeze({
|
|
34
|
+
maxChoiceOptions: 255,
|
|
35
|
+
maxRubricLevels: 10
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
constructor(sdk, modelId) {
|
|
39
|
+
this.sdk = sdk;
|
|
40
|
+
this.modelId = modelId;
|
|
41
|
+
}
|
|
42
|
+
async decision(request, options) {
|
|
43
|
+
const compiled = [];
|
|
44
|
+
const questions = [];
|
|
45
|
+
for (const [index, [name, question]] of Object.entries(request.questions).entries()) {
|
|
46
|
+
const key = `q${index}`;
|
|
47
|
+
if (question.type === "multi-label") {
|
|
48
|
+
const keys = Object.entries(question.options).map(([label, description], labelIndex) => {
|
|
49
|
+
const labelKey = `${key}_${labelIndex}`;
|
|
50
|
+
questions.push([labelKey, {
|
|
51
|
+
type: "noul",
|
|
52
|
+
instructions: {
|
|
53
|
+
instructions: question.instructions,
|
|
54
|
+
label,
|
|
55
|
+
task: "Does this label apply to the state? Evaluate it independently of other labels."
|
|
56
|
+
},
|
|
57
|
+
criteria: { true: toEntry(description) }
|
|
58
|
+
}]);
|
|
59
|
+
return labelKey;
|
|
60
|
+
});
|
|
61
|
+
compiled.push({
|
|
62
|
+
name,
|
|
63
|
+
question,
|
|
64
|
+
keys
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
const native = nativeQuestion(question);
|
|
68
|
+
questions.push([key, native]);
|
|
69
|
+
compiled.push({
|
|
70
|
+
name,
|
|
71
|
+
question,
|
|
72
|
+
keys: [key]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
let rawResponse;
|
|
77
|
+
try {
|
|
78
|
+
const body = {
|
|
79
|
+
...request.providerOptions,
|
|
80
|
+
state: toEntry(request.state) ?? { value: null },
|
|
81
|
+
model: this.modelId,
|
|
82
|
+
questions: Object.fromEntries(questions)
|
|
83
|
+
};
|
|
84
|
+
const requestOptions = { retry: { maxRetries: 0 } };
|
|
85
|
+
if (options?.abortSignal !== void 0) requestOptions.signal = options.abortSignal;
|
|
86
|
+
rawResponse = await this.sdk.systemOne(body, requestOptions);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
throw normalizeJevError(error, options?.abortSignal);
|
|
89
|
+
}
|
|
90
|
+
const fail = (message, questionName) => {
|
|
91
|
+
throw new DecisionProviderOutputError(message, {
|
|
92
|
+
provider: this.provider,
|
|
93
|
+
modelId: this.modelId,
|
|
94
|
+
questionName
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
if (!isDataObject(rawResponse) || !isDataObject(rawResponse.answers)) return fail("Jev returned an invalid answer envelope.");
|
|
98
|
+
const rawAnswers = rawResponse.answers;
|
|
99
|
+
const expectedKeys = questions.map(([key]) => key);
|
|
100
|
+
if (Object.keys(rawAnswers).length !== expectedKeys.length || expectedKeys.some((key) => !Object.hasOwn(rawAnswers, key))) return fail("Jev answers do not match the requested questions.");
|
|
101
|
+
const answers = Object.fromEntries(compiled.map(({ name, question, keys }) => {
|
|
102
|
+
const getAnswer = (key) => {
|
|
103
|
+
const answer = key === void 0 ? void 0 : rawAnswers[key];
|
|
104
|
+
if (!isDataObject(answer)) return fail("Jev returned an invalid answer.", name);
|
|
105
|
+
return answer;
|
|
106
|
+
};
|
|
107
|
+
if (question.type === "multi-label") {
|
|
108
|
+
const labels = Object.keys(question.options);
|
|
109
|
+
const probabilities = Object.fromEntries(labels.map((label, index) => {
|
|
110
|
+
const answer = getAnswer(keys[index]);
|
|
111
|
+
if (answer.type !== "noul" || !isProbability(answer.noul)) return fail("Jev returned an invalid label probability.", name);
|
|
112
|
+
return [label, answer.noul];
|
|
113
|
+
}));
|
|
114
|
+
return [name, {
|
|
115
|
+
type: "multi-label",
|
|
116
|
+
labels: labels.filter((label) => probabilities[label] >= (question.threshold ?? .5)),
|
|
117
|
+
probabilities
|
|
118
|
+
}];
|
|
119
|
+
}
|
|
120
|
+
const answer = getAnswer(keys[0]);
|
|
121
|
+
if (question.type === "check") {
|
|
122
|
+
if (answer.type !== "noul" || !isProbability(answer.noul)) return fail("Jev returned an invalid boolean probability.", name);
|
|
123
|
+
return [name, {
|
|
124
|
+
type: "check",
|
|
125
|
+
probability: answer.noul
|
|
126
|
+
}];
|
|
127
|
+
}
|
|
128
|
+
if (answer.type !== question.type || !isProbability(answer.confidence) || !isDataObject(answer.probabilities)) return fail("Jev returned an invalid choice or score answer.", name);
|
|
129
|
+
if (question.type === "choice") {
|
|
130
|
+
if (typeof answer.choice !== "string" || !Object.hasOwn(question.options, answer.choice)) return fail("Jev selected an unknown option.", name);
|
|
131
|
+
validateDistribution(answer.probabilities, Object.keys(question.options), () => fail("Jev returned invalid choice probabilities.", name));
|
|
132
|
+
return [name, {
|
|
133
|
+
type: "choice",
|
|
134
|
+
choice: answer.choice,
|
|
135
|
+
probabilities: answer.probabilities,
|
|
136
|
+
confidence: answer.confidence
|
|
137
|
+
}];
|
|
138
|
+
}
|
|
139
|
+
const levelKeys = question.rubric.map((_, index) => String(index));
|
|
140
|
+
const expectedLegend = Object.fromEntries(question.rubric.map((level, index) => [String(index), toEntry(level)]));
|
|
141
|
+
if (!isDataObject(answer.legend) || !jsonEqual(answer.legend, expectedLegend)) return fail("Jev returned a legend that does not match the requested rubric.", name);
|
|
142
|
+
const scoreProbabilities = answer.probabilities;
|
|
143
|
+
validateDistribution(scoreProbabilities, levelKeys, () => fail("Jev returned invalid score probabilities.", name));
|
|
144
|
+
if (typeof answer.score !== "number" || !Number.isFinite(answer.score) || answer.score < 0 || answer.score > question.rubric.length - 1) return fail("Jev returned a score outside the requested rubric.", name);
|
|
145
|
+
return [name, {
|
|
146
|
+
type: "score",
|
|
147
|
+
score: answer.score,
|
|
148
|
+
rubric: question.rubric,
|
|
149
|
+
probabilities: levelKeys.map((key) => scoreProbabilities[key]),
|
|
150
|
+
confidence: answer.confidence
|
|
151
|
+
}];
|
|
152
|
+
}));
|
|
153
|
+
const usage = rawResponse.usage;
|
|
154
|
+
if (!isDataObject(usage) || !isTokenCount(usage.input_tokens) || !isTokenCount(usage.output_tokens)) return fail("Jev returned invalid token usage.");
|
|
155
|
+
return {
|
|
156
|
+
answers,
|
|
157
|
+
usage: {
|
|
158
|
+
...Usage.empty(),
|
|
159
|
+
inputTokens: usage.input_tokens,
|
|
160
|
+
outputTokens: usage.output_tokens,
|
|
161
|
+
totalTokens: usage.input_tokens + usage.output_tokens
|
|
162
|
+
},
|
|
163
|
+
rawResponse
|
|
164
|
+
};
|
|
165
|
+
}
|
|
222
166
|
};
|
|
223
167
|
function nativeQuestion(question) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
criteria: question.rubric.map(toEntry)
|
|
241
|
-
};
|
|
242
|
-
case "check":
|
|
243
|
-
return { type: "noul", instructions: question.instructions };
|
|
244
|
-
}
|
|
168
|
+
switch (question.type) {
|
|
169
|
+
case "choice": return {
|
|
170
|
+
type: "choice",
|
|
171
|
+
instructions: question.instructions,
|
|
172
|
+
criteria: Object.fromEntries(Object.entries(question.options).map(([label, description]) => [label, toEntry(description)]))
|
|
173
|
+
};
|
|
174
|
+
case "score": return {
|
|
175
|
+
type: "score",
|
|
176
|
+
instructions: question.instructions,
|
|
177
|
+
criteria: question.rubric.map(toEntry)
|
|
178
|
+
};
|
|
179
|
+
case "check": return {
|
|
180
|
+
type: "noul",
|
|
181
|
+
instructions: question.instructions
|
|
182
|
+
};
|
|
183
|
+
}
|
|
245
184
|
}
|
|
185
|
+
/** The SDK accepts text, objects, arrays, and null; preserve scalar JSON inside an object. */
|
|
246
186
|
function toEntry(value) {
|
|
247
|
-
|
|
248
|
-
|
|
187
|
+
const normalized = sdkJson(value);
|
|
188
|
+
return typeof normalized === "number" || typeof normalized === "boolean" ? { value: normalized } : normalized;
|
|
249
189
|
}
|
|
250
190
|
function sdkJson(value) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
return value;
|
|
191
|
+
if (Array.isArray(value)) return value.map(sdkJson);
|
|
192
|
+
if (value !== null && typeof value === "object") return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, sdkJson(entry)]));
|
|
193
|
+
return value;
|
|
256
194
|
}
|
|
257
195
|
function isDataObject(value) {
|
|
258
|
-
|
|
196
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) && isJsonValue(value);
|
|
259
197
|
}
|
|
198
|
+
/** Compare validated JSON without depending on object property order. */
|
|
260
199
|
function jsonEqual(left, right) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
const rightObject = right;
|
|
269
|
-
const keys = Object.keys(leftObject);
|
|
270
|
-
return Object.keys(rightObject).length === keys.length && keys.every(
|
|
271
|
-
(key) => Object.hasOwn(rightObject, key) && jsonEqual(leftObject[key], rightObject[key])
|
|
272
|
-
);
|
|
200
|
+
if (left === right) return true;
|
|
201
|
+
if (Array.isArray(left) || Array.isArray(right)) return Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((value, index) => jsonEqual(value, right[index]));
|
|
202
|
+
if (left === null || right === null || typeof left !== "object" || typeof right !== "object") return false;
|
|
203
|
+
const leftObject = left;
|
|
204
|
+
const rightObject = right;
|
|
205
|
+
const keys = Object.keys(leftObject);
|
|
206
|
+
return Object.keys(rightObject).length === keys.length && keys.every((key) => Object.hasOwn(rightObject, key) && jsonEqual(leftObject[key], rightObject[key]));
|
|
273
207
|
}
|
|
274
208
|
function isProbability(value) {
|
|
275
|
-
|
|
209
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
|
|
276
210
|
}
|
|
277
211
|
function isTokenCount(value) {
|
|
278
|
-
|
|
212
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
279
213
|
}
|
|
280
214
|
function validateDistribution(value, keys, fail) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
fail();
|
|
284
|
-
}
|
|
215
|
+
const values = Object.values(value);
|
|
216
|
+
if (values.length !== keys.length || keys.some((key) => !Object.hasOwn(value, key)) || !values.every(isProbability) || Math.abs(values.reduce((sum, probability) => sum + probability, 0) - 1) > 1e-5) fail();
|
|
285
217
|
}
|
|
286
|
-
|
|
287
218
|
// src/jev/client.ts
|
|
288
219
|
var JevClient = class {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
data: models.map((model) => ({
|
|
337
|
-
id: model.name,
|
|
338
|
-
name: model.name,
|
|
339
|
-
description: model.description,
|
|
340
|
-
type: "decision"
|
|
341
|
-
}))
|
|
342
|
-
};
|
|
343
|
-
} catch (error) {
|
|
344
|
-
const normalized = normalizeJevError(error, options?.abortSignal);
|
|
345
|
-
if (options?.abortSignal?.aborted) {
|
|
346
|
-
throw normalized;
|
|
347
|
-
}
|
|
348
|
-
throw new ModelListingError("Failed to list Jev models.", {
|
|
349
|
-
provider: "jev",
|
|
350
|
-
cause: normalized
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
}
|
|
220
|
+
sdk;
|
|
221
|
+
constructor(options) {
|
|
222
|
+
if (options.client !== void 0) {
|
|
223
|
+
if ([
|
|
224
|
+
"apiKey",
|
|
225
|
+
"baseUrl",
|
|
226
|
+
"headers"
|
|
227
|
+
].some((key) => key in options)) throw new TypeError("JevClient cannot combine an injected client with managed options.");
|
|
228
|
+
this.sdk = options.client;
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const apiKey = options.apiKey ?? process.env.TYPESAFE_API_KEY;
|
|
232
|
+
if (typeof apiKey !== "string" || apiKey.trim().length === 0) throw new TypeError("JevClient requires apiKey or TYPESAFE_API_KEY.");
|
|
233
|
+
const clientOptions = {
|
|
234
|
+
apiKey,
|
|
235
|
+
retry: { maxRetries: 0 },
|
|
236
|
+
logLevel: "off"
|
|
237
|
+
};
|
|
238
|
+
if (options.baseUrl !== void 0) clientOptions.baseURL = options.baseUrl;
|
|
239
|
+
if (options.headers !== void 0) clientOptions.defaultHeaders = options.headers;
|
|
240
|
+
this.sdk = new TypeSafeClient(clientOptions);
|
|
241
|
+
}
|
|
242
|
+
decisionModel(options) {
|
|
243
|
+
if (typeof options.modelId !== "string" || options.modelId.trim().length === 0) throw new TypeError("Jev modelId must be a non-empty string.");
|
|
244
|
+
return new JevDecisionModel(this.sdk, options.modelId);
|
|
245
|
+
}
|
|
246
|
+
async listModels(options) {
|
|
247
|
+
try {
|
|
248
|
+
const requestOptions = { retry: { maxRetries: 0 } };
|
|
249
|
+
if (options?.abortSignal !== void 0) requestOptions.signal = options.abortSignal;
|
|
250
|
+
const models = await this.sdk.models.list(requestOptions);
|
|
251
|
+
if (!Array.isArray(models) || models.some((model) => typeof model?.name !== "string" || typeof model.description !== "string" || typeof model.release_date !== "string")) throw new TypeError("Jev returned invalid model metadata.");
|
|
252
|
+
return { data: models.map((model) => ({
|
|
253
|
+
id: model.name,
|
|
254
|
+
name: model.name,
|
|
255
|
+
description: model.description,
|
|
256
|
+
type: "decision"
|
|
257
|
+
})) };
|
|
258
|
+
} catch (error) {
|
|
259
|
+
const normalized = normalizeJevError(error, options?.abortSignal);
|
|
260
|
+
if (options?.abortSignal?.aborted) throw normalized;
|
|
261
|
+
throw new ModelListingError("Failed to list Jev models.", {
|
|
262
|
+
provider: "jev",
|
|
263
|
+
cause: normalized
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
354
267
|
};
|
|
355
|
-
|
|
356
268
|
// src/jev/models.ts
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
269
|
+
const JEV_LATEST = "jev-latest";
|
|
270
|
+
const JEV_PREVIEW = "jev-preview";
|
|
271
|
+
// src/jev/index.ts
|
|
272
|
+
var jev_exports = /* @__PURE__ */ __exportAll({
|
|
273
|
+
JEV_LATEST: () => JEV_LATEST,
|
|
274
|
+
JEV_PREVIEW: () => JEV_PREVIEW,
|
|
275
|
+
JevClient: () => JevClient
|
|
276
|
+
});
|
|
277
|
+
export { JEV_LATEST, JEV_PREVIEW, JevClient, jev_exports as jev };
|
|
278
|
+
|
|
363
279
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/jev/index.ts","../src/jev/client.ts","../src/jev/decision.ts","../src/jev/errors.ts","../src/jev/models.ts"],"sourcesContent":["export {\n JevClient,\n type JevClientOptions,\n type JevDecisionModelOptions,\n type JevDecisionModelHandle,\n} from \"./client\";\nexport { JEV_LATEST, type KnownJevDecisionModelId, type JevDecisionModelId } from \"./models\";\n","import type { DecisionModel } from \"@anvia/core/decision\";\nimport {\n ModelListingError,\n type ModelList,\n type ModelListingClient,\n} from \"@anvia/core/model-listing\";\nimport { TypeSafeClient } from \"@typesafe-ai/sdk\";\nimport { JevDecisionModel } from \"./decision\";\nimport type { JevDecisionModelId } from \"./models\";\nimport { normalizeJevError } from \"./errors\";\n\nexport type JevClientOptions =\n | {\n apiKey?: string | undefined;\n baseUrl?: string | undefined;\n headers?: Record<string, string> | undefined;\n client?: never;\n }\n | {\n client: TypeSafeClient;\n apiKey?: never;\n baseUrl?: never;\n headers?: never;\n };\n\nexport type JevDecisionModelOptions = { modelId: JevDecisionModelId };\nexport type JevDecisionModelHandle = DecisionModel<unknown>;\n\nexport class JevClient implements ModelListingClient {\n private readonly sdk: TypeSafeClient;\n\n constructor(options: JevClientOptions) {\n if (options.client !== undefined) {\n if ([\"apiKey\", \"baseUrl\", \"headers\"].some((key) => key in options)) {\n throw new TypeError(\"JevClient cannot combine an injected client with managed options.\");\n }\n this.sdk = options.client;\n return;\n }\n const apiKey = options.apiKey ?? process.env.TYPESAFE_API_KEY;\n if (typeof apiKey !== \"string\" || apiKey.trim().length === 0) {\n throw new TypeError(\"JevClient requires apiKey or TYPESAFE_API_KEY.\");\n }\n\n const clientOptions: ConstructorParameters<typeof TypeSafeClient>[0] = {\n apiKey,\n retry: { maxRetries: 0 },\n logLevel: \"off\",\n };\n\n if (options.baseUrl !== undefined) {\n clientOptions.baseURL = options.baseUrl;\n }\n\n if (options.headers !== undefined) {\n clientOptions.defaultHeaders = options.headers;\n }\n\n this.sdk = new TypeSafeClient(clientOptions);\n }\n\n decisionModel(options: JevDecisionModelOptions): JevDecisionModelHandle {\n if (typeof options.modelId !== \"string\" || options.modelId.trim().length === 0) {\n throw new TypeError(\"Jev modelId must be a non-empty string.\");\n }\n return new JevDecisionModel(this.sdk, options.modelId);\n }\n\n async listModels(options?: { abortSignal?: AbortSignal | undefined }): Promise<ModelList> {\n try {\n const requestOptions: NonNullable<Parameters<TypeSafeClient[\"models\"][\"list\"]>[0]> = {\n retry: { maxRetries: 0 },\n };\n\n if (options?.abortSignal !== undefined) {\n requestOptions.signal = options.abortSignal;\n }\n\n const models = await this.sdk.models.list(requestOptions);\n if (\n !Array.isArray(models) ||\n models.some(\n (model) =>\n typeof model?.name !== \"string\" ||\n typeof model.description !== \"string\" ||\n typeof model.release_date !== \"string\",\n )\n ) {\n throw new TypeError(\"Jev returned invalid model metadata.\");\n }\n return {\n data: models.map((model) => ({\n id: model.name,\n name: model.name,\n description: model.description,\n type: \"decision\",\n })),\n };\n } catch (error) {\n const normalized = normalizeJevError(error, options?.abortSignal);\n if (options?.abortSignal?.aborted) {\n throw normalized;\n }\n throw new ModelListingError(\"Failed to list Jev models.\", {\n provider: \"jev\",\n cause: normalized,\n });\n }\n }\n}\n","import {\n DecisionProviderOutputError,\n type DecisionAnswers,\n type DecisionCapabilities,\n type DecisionModel,\n type DecisionQuestion,\n type DecisionQuestions,\n type DecisionRequest,\n type DecisionResult,\n type JsonValue,\n type ModelCallOptions,\n} from \"@anvia/core/decision\";\nimport { isJsonValue, Usage } from \"@anvia/core/completion\";\nimport type {\n EntryType,\n JsonValue as SdkJsonValue,\n Question,\n TypeSafeClient,\n} from \"@typesafe-ai/sdk\";\nimport type { JevDecisionModelId } from \"./models\";\nimport { normalizeJevError } from \"./errors\";\n\ntype CompiledQuestion = {\n name: string;\n question: DecisionQuestion;\n keys: string[];\n};\n\nexport class JevDecisionModel implements DecisionModel<unknown> {\n readonly provider = \"jev\";\n readonly capabilities: DecisionCapabilities = Object.freeze({\n questionSupport: Object.freeze({\n choice: \"native\",\n \"multi-label\": \"composed\",\n score: \"native\",\n check: \"native\",\n }),\n mixedQuestions: true,\n limits: Object.freeze({ maxChoiceOptions: 255, maxRubricLevels: 10 }),\n });\n\n constructor(\n private readonly sdk: TypeSafeClient,\n readonly modelId: JevDecisionModelId,\n ) {}\n\n async decision<const Questions extends DecisionQuestions>(\n request: DecisionRequest<Questions>,\n options?: ModelCallOptions,\n ): Promise<DecisionResult<Questions, unknown>> {\n const compiled: CompiledQuestion[] = [];\n const questions: [string, Question][] = [];\n for (const [index, [name, question]] of Object.entries(request.questions).entries()) {\n const key = `q${index}`;\n if (question.type === \"multi-label\") {\n const keys = Object.entries(question.options).map(([label, description], labelIndex) => {\n const labelKey = `${key}_${labelIndex}`;\n questions.push([\n labelKey,\n {\n type: \"noul\",\n instructions: {\n instructions: question.instructions,\n label,\n task: \"Does this label apply to the state? Evaluate it independently of other labels.\",\n },\n criteria: { true: toEntry(description) },\n },\n ]);\n return labelKey;\n });\n compiled.push({ name, question, keys });\n } else {\n const native = nativeQuestion(question);\n questions.push([key, native]);\n compiled.push({ name, question, keys: [key] });\n }\n }\n\n let rawResponse: unknown;\n try {\n const body = {\n ...request.providerOptions,\n state: toEntry(request.state) ?? { value: null },\n model: this.modelId,\n questions: Object.fromEntries(questions),\n };\n const requestOptions: NonNullable<Parameters<TypeSafeClient[\"systemOne\"]>[1]> = {\n retry: { maxRetries: 0 },\n };\n\n if (options?.abortSignal !== undefined) {\n requestOptions.signal = options.abortSignal;\n }\n\n rawResponse = await this.sdk.systemOne(body, requestOptions);\n } catch (error) {\n throw normalizeJevError(error, options?.abortSignal);\n }\n\n const fail = (message: string, questionName?: string): never => {\n throw new DecisionProviderOutputError(message, {\n provider: this.provider,\n modelId: this.modelId,\n questionName,\n });\n };\n if (!isDataObject(rawResponse) || !isDataObject(rawResponse.answers)) {\n return fail(\"Jev returned an invalid answer envelope.\");\n }\n const rawAnswers = rawResponse.answers;\n const expectedKeys = questions.map(([key]) => key);\n if (\n Object.keys(rawAnswers).length !== expectedKeys.length ||\n expectedKeys.some((key) => !Object.hasOwn(rawAnswers, key))\n ) {\n return fail(\"Jev answers do not match the requested questions.\");\n }\n const answers = Object.fromEntries(\n compiled.map(({ name, question, keys }) => {\n const getAnswer = (key: string | undefined): Record<string, JsonValue> => {\n const answer = key === undefined ? undefined : rawAnswers[key];\n if (!isDataObject(answer)) return fail(\"Jev returned an invalid answer.\", name);\n return answer;\n };\n if (question.type === \"multi-label\") {\n const labels = Object.keys(question.options);\n const probabilities = Object.fromEntries(\n labels.map((label, index) => {\n const answer = getAnswer(keys[index]);\n if (answer.type !== \"noul\" || !isProbability(answer.noul)) {\n return fail(\"Jev returned an invalid label probability.\", name);\n }\n return [label, answer.noul];\n }),\n );\n return [\n name,\n {\n type: \"multi-label\",\n labels: labels.filter(\n (label) => probabilities[label]! >= (question.threshold ?? 0.5),\n ),\n probabilities,\n },\n ];\n }\n const answer = getAnswer(keys[0]);\n if (question.type === \"check\") {\n if (answer.type !== \"noul\" || !isProbability(answer.noul)) {\n return fail(\"Jev returned an invalid boolean probability.\", name);\n }\n return [name, { type: \"check\", probability: answer.noul }];\n }\n if (\n answer.type !== question.type ||\n !isProbability(answer.confidence) ||\n !isDataObject(answer.probabilities)\n ) {\n return fail(\"Jev returned an invalid choice or score answer.\", name);\n }\n if (question.type === \"choice\") {\n if (\n typeof answer.choice !== \"string\" ||\n !Object.hasOwn(question.options, answer.choice)\n ) {\n return fail(\"Jev selected an unknown option.\", name);\n }\n validateDistribution(answer.probabilities, Object.keys(question.options), () =>\n fail(\"Jev returned invalid choice probabilities.\", name),\n );\n return [\n name,\n {\n type: \"choice\",\n choice: answer.choice,\n probabilities: answer.probabilities,\n confidence: answer.confidence,\n },\n ];\n }\n const levelKeys = question.rubric.map((_, index) => String(index));\n const expectedLegend = Object.fromEntries(\n question.rubric.map((level, index) => [String(index), toEntry(level)]),\n ) as Record<string, JsonValue>;\n if (!isDataObject(answer.legend) || !jsonEqual(answer.legend, expectedLegend)) {\n return fail(\"Jev returned a legend that does not match the requested rubric.\", name);\n }\n const scoreProbabilities = answer.probabilities;\n validateDistribution(scoreProbabilities, levelKeys, () =>\n fail(\"Jev returned invalid score probabilities.\", name),\n );\n if (\n typeof answer.score !== \"number\" ||\n !Number.isFinite(answer.score) ||\n answer.score < 0 ||\n answer.score > question.rubric.length - 1\n ) {\n return fail(\"Jev returned a score outside the requested rubric.\", name);\n }\n return [\n name,\n {\n type: \"score\",\n score: answer.score,\n rubric: question.rubric,\n probabilities: levelKeys.map((key) => scoreProbabilities[key]),\n confidence: answer.confidence,\n },\n ];\n }),\n ) as DecisionAnswers<Questions>;\n\n const usage = rawResponse.usage;\n if (\n !isDataObject(usage) ||\n !isTokenCount(usage.input_tokens) ||\n !isTokenCount(usage.output_tokens)\n ) {\n return fail(\"Jev returned invalid token usage.\");\n }\n return {\n answers,\n usage: {\n ...Usage.empty(),\n inputTokens: usage.input_tokens,\n outputTokens: usage.output_tokens,\n totalTokens: usage.input_tokens + usage.output_tokens,\n },\n rawResponse,\n };\n }\n}\n\nfunction nativeQuestion(question: Exclude<DecisionQuestion, { type: \"multi-label\" }>): Question {\n switch (question.type) {\n case \"choice\":\n return {\n type: \"choice\",\n instructions: question.instructions,\n criteria: Object.fromEntries(\n Object.entries(question.options).map(([label, description]) => [\n label,\n toEntry(description),\n ]),\n ),\n };\n case \"score\":\n return {\n type: \"score\",\n instructions: question.instructions,\n criteria: question.rubric.map(toEntry) as [EntryType, EntryType, ...EntryType[]],\n };\n case \"check\":\n return { type: \"noul\", instructions: question.instructions };\n }\n}\n\n/** The SDK accepts text, objects, arrays, and null; preserve scalar JSON inside an object. */\nfunction toEntry(value: JsonValue): EntryType {\n const normalized = sdkJson(value);\n return typeof normalized === \"number\" || typeof normalized === \"boolean\"\n ? { value: normalized }\n : normalized;\n}\n\nfunction sdkJson(value: JsonValue): SdkJsonValue {\n if (Array.isArray(value)) return value.map(sdkJson);\n if (value !== null && typeof value === \"object\") {\n return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, sdkJson(entry)]));\n }\n return value as string | number | boolean | null;\n}\n\nfunction isDataObject(value: unknown): value is Record<string, JsonValue> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value) && isJsonValue(value);\n}\n\n/** Compare validated JSON without depending on object property order. */\nfunction jsonEqual(left: JsonValue, right: JsonValue): boolean {\n if (left === right) return true;\n if (Array.isArray(left) || Array.isArray(right)) {\n return (\n Array.isArray(left) &&\n Array.isArray(right) &&\n left.length === right.length &&\n left.every((value, index) => jsonEqual(value, right[index]!))\n );\n }\n if (left === null || right === null || typeof left !== \"object\" || typeof right !== \"object\")\n return false;\n // Array.isArray does not narrow readonly JSON arrays out of the object union.\n const leftObject = left as Record<string, JsonValue>;\n const rightObject = right as Record<string, JsonValue>;\n const keys = Object.keys(leftObject);\n return (\n Object.keys(rightObject).length === keys.length &&\n keys.every(\n (key) => Object.hasOwn(rightObject, key) && jsonEqual(leftObject[key]!, rightObject[key]!),\n )\n );\n}\n\nfunction isProbability(value: unknown): value is number {\n return typeof value === \"number\" && Number.isFinite(value) && value >= 0 && value <= 1;\n}\n\nfunction isTokenCount(value: unknown): value is number {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0;\n}\n\nfunction validateDistribution(\n value: Record<string, JsonValue>,\n keys: string[],\n fail: () => never,\n): void {\n const values = Object.values(value);\n if (\n values.length !== keys.length ||\n keys.some((key) => !Object.hasOwn(value, key)) ||\n !values.every(isProbability) ||\n Math.abs(values.reduce((sum, probability) => sum + probability, 0) - 1) > 1e-5\n ) {\n fail();\n }\n}\n","import { APITimeoutError } from \"@typesafe-ai/sdk\";\n\n/** Distinguish SDK timeout cancellation from cancellation requested by the caller. */\nexport function normalizeJevError(error: unknown, abortSignal?: AbortSignal): unknown {\n if (abortSignal?.aborted) {\n const aborted = new Error(\"The Jev request was aborted.\", { cause: error });\n aborted.name = \"AbortError\";\n return aborted;\n }\n if (error instanceof APITimeoutError) {\n // The SDK timeout cause is AbortError. Keep it outside the cause chain so core\n // retries recognize a timeout without mistaking it for caller cancellation.\n return Object.assign(new Error(error.message), { name: \"TimeoutError\", providerError: error });\n }\n return error;\n}\n","import type { ModelId } from \"@anvia/core/model-listing\";\n\nexport const JEV_LATEST = \"jev-latest\";\nexport type KnownJevDecisionModelId = typeof JEV_LATEST;\nexport type JevDecisionModelId = ModelId<KnownJevDecisionModelId>;\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA;AAAA,EACE;AAAA,OAGK;AACP,SAAS,sBAAsB;;;ACN/B;AAAA,EACE;AAAA,OAUK;AACP,SAAS,aAAa,aAAa;;;ACZnC,SAAS,uBAAuB;AAGzB,SAAS,kBAAkB,OAAgB,aAAoC;AACpF,MAAI,aAAa,SAAS;AACxB,UAAM,UAAU,IAAI,MAAM,gCAAgC,EAAE,OAAO,MAAM,CAAC;AAC1E,YAAQ,OAAO;AACf,WAAO;AAAA,EACT;AACA,MAAI,iBAAiB,iBAAiB;AAGpC,WAAO,OAAO,OAAO,IAAI,MAAM,MAAM,OAAO,GAAG,EAAE,MAAM,gBAAgB,eAAe,MAAM,CAAC;AAAA,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AAAA,QACL,MAAM,OAAO,IAAI,CAAC,WAAW;AAAA,UAC3B,IAAI,MAAM;AAAA,UACV,MAAM,MAAM;AAAA,UACZ,aAAa,MAAM;AAAA,UACnB,MAAM;AAAA,QACR,EAAE;AAAA,MACJ;AAAA,IACF,SAAS,OAAO;AACd,YAAM,aAAa,kBAAkB,OAAO,SAAS,WAAW;AAChE,UAAI,SAAS,aAAa,SAAS;AACjC,cAAM;AAAA,MACR;AACA,YAAM,IAAI,kBAAkB,8BAA8B;AAAA,QACxD,UAAU;AAAA,QACV,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF;AACF;;;AG3GO,IAAM,aAAa;","names":["answer"]}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/jev/errors.ts","../src/jev/decision.ts","../src/jev/client.ts","../src/jev/models.ts","../src/jev/index.ts"],"sourcesContent":["import { APITimeoutError } from \"@typesafe-ai/sdk\";\n\n/** Distinguish SDK timeout cancellation from cancellation requested by the caller. */\nexport function normalizeJevError(error: unknown, abortSignal?: AbortSignal): unknown {\n if (abortSignal?.aborted) {\n const aborted = new Error(\"The Jev request was aborted.\", { cause: error });\n aborted.name = \"AbortError\";\n return aborted;\n }\n if (error instanceof APITimeoutError) {\n // The SDK timeout cause is AbortError. Keep it outside the cause chain so core\n // retries recognize a timeout without mistaking it for caller cancellation.\n return Object.assign(new Error(error.message), { name: \"TimeoutError\", providerError: error });\n }\n return error;\n}\n","import {\n DecisionProviderOutputError,\n type DecisionAnswers,\n type DecisionCapabilities,\n type DecisionModel,\n type DecisionQuestion,\n type DecisionQuestions,\n type DecisionRequest,\n type DecisionResult,\n type JsonValue,\n type ModelCallOptions,\n} from \"@anvia/core/decision\";\nimport { isJsonValue, Usage } from \"@anvia/core/completion\";\nimport type {\n EntryType,\n JsonValue as SdkJsonValue,\n Question,\n TypeSafeClient,\n} from \"@typesafe-ai/sdk\";\nimport type { JevDecisionModelId } from \"./models\";\nimport { normalizeJevError } from \"./errors\";\n\ntype CompiledQuestion = {\n name: string;\n question: DecisionQuestion;\n keys: string[];\n};\n\nexport class JevDecisionModel implements DecisionModel<unknown> {\n readonly provider = \"jev\";\n readonly capabilities: DecisionCapabilities = Object.freeze({\n questionSupport: Object.freeze({\n choice: \"native\",\n \"multi-label\": \"composed\",\n score: \"native\",\n check: \"native\",\n }),\n mixedQuestions: true,\n limits: Object.freeze({ maxChoiceOptions: 255, maxRubricLevels: 10 }),\n });\n\n constructor(\n private readonly sdk: TypeSafeClient,\n readonly modelId: JevDecisionModelId,\n ) {}\n\n async decision<const Questions extends DecisionQuestions>(\n request: DecisionRequest<Questions>,\n options?: ModelCallOptions,\n ): Promise<DecisionResult<Questions, unknown>> {\n const compiled: CompiledQuestion[] = [];\n const questions: [string, Question][] = [];\n for (const [index, [name, question]] of Object.entries(request.questions).entries()) {\n const key = `q${index}`;\n if (question.type === \"multi-label\") {\n const keys = Object.entries(question.options).map(([label, description], labelIndex) => {\n const labelKey = `${key}_${labelIndex}`;\n questions.push([\n labelKey,\n {\n type: \"noul\",\n instructions: {\n instructions: question.instructions,\n label,\n task: \"Does this label apply to the state? Evaluate it independently of other labels.\",\n },\n criteria: { true: toEntry(description) },\n },\n ]);\n return labelKey;\n });\n compiled.push({ name, question, keys });\n } else {\n const native = nativeQuestion(question);\n questions.push([key, native]);\n compiled.push({ name, question, keys: [key] });\n }\n }\n\n let rawResponse: unknown;\n try {\n const body = {\n ...request.providerOptions,\n state: toEntry(request.state) ?? { value: null },\n model: this.modelId,\n questions: Object.fromEntries(questions),\n };\n const requestOptions: NonNullable<Parameters<TypeSafeClient[\"systemOne\"]>[1]> = {\n retry: { maxRetries: 0 },\n };\n\n if (options?.abortSignal !== undefined) {\n requestOptions.signal = options.abortSignal;\n }\n\n rawResponse = await this.sdk.systemOne(body, requestOptions);\n } catch (error) {\n throw normalizeJevError(error, options?.abortSignal);\n }\n\n const fail = (message: string, questionName?: string): never => {\n throw new DecisionProviderOutputError(message, {\n provider: this.provider,\n modelId: this.modelId,\n questionName,\n });\n };\n if (!isDataObject(rawResponse) || !isDataObject(rawResponse.answers)) {\n return fail(\"Jev returned an invalid answer envelope.\");\n }\n const rawAnswers = rawResponse.answers;\n const expectedKeys = questions.map(([key]) => key);\n if (\n Object.keys(rawAnswers).length !== expectedKeys.length ||\n expectedKeys.some((key) => !Object.hasOwn(rawAnswers, key))\n ) {\n return fail(\"Jev answers do not match the requested questions.\");\n }\n const answers = Object.fromEntries(\n compiled.map(({ name, question, keys }) => {\n const getAnswer = (key: string | undefined): Record<string, JsonValue> => {\n const answer = key === undefined ? undefined : rawAnswers[key];\n if (!isDataObject(answer)) return fail(\"Jev returned an invalid answer.\", name);\n return answer;\n };\n if (question.type === \"multi-label\") {\n const labels = Object.keys(question.options);\n const probabilities = Object.fromEntries(\n labels.map((label, index) => {\n const answer = getAnswer(keys[index]);\n if (answer.type !== \"noul\" || !isProbability(answer.noul)) {\n return fail(\"Jev returned an invalid label probability.\", name);\n }\n return [label, answer.noul];\n }),\n );\n return [\n name,\n {\n type: \"multi-label\",\n labels: labels.filter(\n (label) => probabilities[label]! >= (question.threshold ?? 0.5),\n ),\n probabilities,\n },\n ];\n }\n const answer = getAnswer(keys[0]);\n if (question.type === \"check\") {\n if (answer.type !== \"noul\" || !isProbability(answer.noul)) {\n return fail(\"Jev returned an invalid boolean probability.\", name);\n }\n return [name, { type: \"check\", probability: answer.noul }];\n }\n if (\n answer.type !== question.type ||\n !isProbability(answer.confidence) ||\n !isDataObject(answer.probabilities)\n ) {\n return fail(\"Jev returned an invalid choice or score answer.\", name);\n }\n if (question.type === \"choice\") {\n if (\n typeof answer.choice !== \"string\" ||\n !Object.hasOwn(question.options, answer.choice)\n ) {\n return fail(\"Jev selected an unknown option.\", name);\n }\n validateDistribution(answer.probabilities, Object.keys(question.options), () =>\n fail(\"Jev returned invalid choice probabilities.\", name),\n );\n return [\n name,\n {\n type: \"choice\",\n choice: answer.choice,\n probabilities: answer.probabilities,\n confidence: answer.confidence,\n },\n ];\n }\n const levelKeys = question.rubric.map((_, index) => String(index));\n const expectedLegend = Object.fromEntries(\n question.rubric.map((level, index) => [String(index), toEntry(level)]),\n ) as Record<string, JsonValue>;\n if (!isDataObject(answer.legend) || !jsonEqual(answer.legend, expectedLegend)) {\n return fail(\"Jev returned a legend that does not match the requested rubric.\", name);\n }\n const scoreProbabilities = answer.probabilities;\n validateDistribution(scoreProbabilities, levelKeys, () =>\n fail(\"Jev returned invalid score probabilities.\", name),\n );\n if (\n typeof answer.score !== \"number\" ||\n !Number.isFinite(answer.score) ||\n answer.score < 0 ||\n answer.score > question.rubric.length - 1\n ) {\n return fail(\"Jev returned a score outside the requested rubric.\", name);\n }\n return [\n name,\n {\n type: \"score\",\n score: answer.score,\n rubric: question.rubric,\n probabilities: levelKeys.map((key) => scoreProbabilities[key]),\n confidence: answer.confidence,\n },\n ];\n }),\n ) as DecisionAnswers<Questions>;\n\n const usage = rawResponse.usage;\n if (\n !isDataObject(usage) ||\n !isTokenCount(usage.input_tokens) ||\n !isTokenCount(usage.output_tokens)\n ) {\n return fail(\"Jev returned invalid token usage.\");\n }\n return {\n answers,\n usage: {\n ...Usage.empty(),\n inputTokens: usage.input_tokens,\n outputTokens: usage.output_tokens,\n totalTokens: usage.input_tokens + usage.output_tokens,\n },\n rawResponse,\n };\n }\n}\n\nfunction nativeQuestion(question: Exclude<DecisionQuestion, { type: \"multi-label\" }>): Question {\n switch (question.type) {\n case \"choice\":\n return {\n type: \"choice\",\n instructions: question.instructions,\n criteria: Object.fromEntries(\n Object.entries(question.options).map(([label, description]) => [\n label,\n toEntry(description),\n ]),\n ),\n };\n case \"score\":\n return {\n type: \"score\",\n instructions: question.instructions,\n criteria: question.rubric.map(toEntry) as [EntryType, EntryType, ...EntryType[]],\n };\n case \"check\":\n return { type: \"noul\", instructions: question.instructions };\n }\n}\n\n/** The SDK accepts text, objects, arrays, and null; preserve scalar JSON inside an object. */\nfunction toEntry(value: JsonValue): EntryType {\n const normalized = sdkJson(value);\n return typeof normalized === \"number\" || typeof normalized === \"boolean\"\n ? { value: normalized }\n : normalized;\n}\n\nfunction sdkJson(value: JsonValue): SdkJsonValue {\n if (Array.isArray(value)) return value.map(sdkJson);\n if (value !== null && typeof value === \"object\") {\n return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, sdkJson(entry)]));\n }\n return value as string | number | boolean | null;\n}\n\nfunction isDataObject(value: unknown): value is Record<string, JsonValue> {\n return value !== null && typeof value === \"object\" && !Array.isArray(value) && isJsonValue(value);\n}\n\n/** Compare validated JSON without depending on object property order. */\nfunction jsonEqual(left: JsonValue, right: JsonValue): boolean {\n if (left === right) return true;\n if (Array.isArray(left) || Array.isArray(right)) {\n return (\n Array.isArray(left) &&\n Array.isArray(right) &&\n left.length === right.length &&\n left.every((value, index) => jsonEqual(value, right[index]!))\n );\n }\n if (left === null || right === null || typeof left !== \"object\" || typeof right !== \"object\")\n return false;\n // Array.isArray does not narrow readonly JSON arrays out of the object union.\n const leftObject = left as Record<string, JsonValue>;\n const rightObject = right as Record<string, JsonValue>;\n const keys = Object.keys(leftObject);\n return (\n Object.keys(rightObject).length === keys.length &&\n keys.every(\n (key) => Object.hasOwn(rightObject, key) && jsonEqual(leftObject[key]!, rightObject[key]!),\n )\n );\n}\n\nfunction isProbability(value: unknown): value is number {\n return typeof value === \"number\" && Number.isFinite(value) && value >= 0 && value <= 1;\n}\n\nfunction isTokenCount(value: unknown): value is number {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0;\n}\n\nfunction validateDistribution(\n value: Record<string, JsonValue>,\n keys: string[],\n fail: () => never,\n): void {\n const values = Object.values(value);\n if (\n values.length !== keys.length ||\n keys.some((key) => !Object.hasOwn(value, key)) ||\n !values.every(isProbability) ||\n Math.abs(values.reduce((sum, probability) => sum + probability, 0) - 1) > 1e-5\n ) {\n fail();\n }\n}\n","import type { DecisionModel } from \"@anvia/core/decision\";\nimport {\n ModelListingError,\n type ModelList,\n type ModelListingClient,\n} from \"@anvia/core/model-listing\";\nimport { TypeSafeClient } from \"@typesafe-ai/sdk\";\nimport { JevDecisionModel } from \"./decision\";\nimport type { JevDecisionModelId } from \"./models\";\nimport { normalizeJevError } from \"./errors\";\n\nexport type JevClientOptions =\n | {\n apiKey?: string | undefined;\n baseUrl?: string | undefined;\n headers?: Record<string, string> | undefined;\n client?: never;\n }\n | {\n client: TypeSafeClient;\n apiKey?: never;\n baseUrl?: never;\n headers?: never;\n };\n\nexport type JevDecisionModelOptions = { modelId: JevDecisionModelId };\nexport type JevDecisionModelHandle = DecisionModel<unknown>;\n\nexport class JevClient implements ModelListingClient {\n private readonly sdk: TypeSafeClient;\n\n constructor(options: JevClientOptions) {\n if (options.client !== undefined) {\n if ([\"apiKey\", \"baseUrl\", \"headers\"].some((key) => key in options)) {\n throw new TypeError(\"JevClient cannot combine an injected client with managed options.\");\n }\n this.sdk = options.client;\n return;\n }\n const apiKey = options.apiKey ?? process.env.TYPESAFE_API_KEY;\n if (typeof apiKey !== \"string\" || apiKey.trim().length === 0) {\n throw new TypeError(\"JevClient requires apiKey or TYPESAFE_API_KEY.\");\n }\n\n const clientOptions: ConstructorParameters<typeof TypeSafeClient>[0] = {\n apiKey,\n retry: { maxRetries: 0 },\n logLevel: \"off\",\n };\n\n if (options.baseUrl !== undefined) {\n clientOptions.baseURL = options.baseUrl;\n }\n\n if (options.headers !== undefined) {\n clientOptions.defaultHeaders = options.headers;\n }\n\n this.sdk = new TypeSafeClient(clientOptions);\n }\n\n decisionModel(options: JevDecisionModelOptions): JevDecisionModelHandle {\n if (typeof options.modelId !== \"string\" || options.modelId.trim().length === 0) {\n throw new TypeError(\"Jev modelId must be a non-empty string.\");\n }\n return new JevDecisionModel(this.sdk, options.modelId);\n }\n\n async listModels(options?: { abortSignal?: AbortSignal | undefined }): Promise<ModelList> {\n try {\n const requestOptions: NonNullable<Parameters<TypeSafeClient[\"models\"][\"list\"]>[0]> = {\n retry: { maxRetries: 0 },\n };\n\n if (options?.abortSignal !== undefined) {\n requestOptions.signal = options.abortSignal;\n }\n\n const models = await this.sdk.models.list(requestOptions);\n if (\n !Array.isArray(models) ||\n models.some(\n (model) =>\n typeof model?.name !== \"string\" ||\n typeof model.description !== \"string\" ||\n typeof model.release_date !== \"string\",\n )\n ) {\n throw new TypeError(\"Jev returned invalid model metadata.\");\n }\n return {\n data: models.map((model) => ({\n id: model.name,\n name: model.name,\n description: model.description,\n type: \"decision\",\n })),\n };\n } catch (error) {\n const normalized = normalizeJevError(error, options?.abortSignal);\n if (options?.abortSignal?.aborted) {\n throw normalized;\n }\n throw new ModelListingError(\"Failed to list Jev models.\", {\n provider: \"jev\",\n cause: normalized,\n });\n }\n }\n}\n","import type { ModelId } from \"@anvia/core/model-listing\";\n\nexport const JEV_LATEST = \"jev-latest\";\nexport const JEV_PREVIEW = \"jev-preview\";\nexport type KnownJevDecisionModelId = typeof JEV_LATEST | typeof JEV_PREVIEW;\nexport type JevDecisionModelId = ModelId<KnownJevDecisionModelId>;\n","export {\n JevClient,\n type JevClientOptions,\n type JevDecisionModelOptions,\n type JevDecisionModelHandle,\n} from \"./client\";\nexport {\n JEV_LATEST,\n JEV_PREVIEW,\n type KnownJevDecisionModelId,\n type JevDecisionModelId,\n} from \"./models\";\n"],"mappings":";;;;;;;AAGA,SAAgB,kBAAkB,OAAgB,aAAoC;CACpF,IAAI,aAAa,SAAS;EACxB,MAAM,UAAU,IAAI,MAAM,gCAAgC,EAAE,OAAO,MAAM,CAAC;EAC1E,QAAQ,OAAO;EACf,OAAO;CACT;CACA,IAAI,iBAAiB,iBAGnB,OAAO,OAAO,OAAO,IAAI,MAAM,MAAM,OAAO,GAAG;EAAE,MAAM;EAAgB,eAAe;CAAM,CAAC;CAE/F,OAAO;AACT;;ACaA,IAAa,mBAAb,MAAgE;CAc3C;CACR;CAdX,WAAoB;CACpB,eAA8C,OAAO,OAAO;EAC1D,iBAAiB,OAAO,OAAO;GAC7B,QAAQ;GACR,eAAe;GACf,OAAO;GACP,OAAO;EACT,CA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AI,kBAAkB,8BAA8B;IACxD,UAAU;IACV,OAAO;GACT,CAAC;EACH;CACF;AACF;;AC3GA,MAAa,aAAa;AAC1B,MAAa,cAAc"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
export { __exportAll as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anvia/jev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Jev decision model adapter for Anvia.",
|
|
5
5
|
"author": "anvia",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^24.9.1",
|
|
32
|
-
"
|
|
32
|
+
"tsdown": "^0.23.4",
|
|
33
33
|
"typescript": "^5.9.3",
|
|
34
34
|
"vitest": "^4.1.11",
|
|
35
|
-
"@anvia/core": "1.
|
|
35
|
+
"@anvia/core": "1.21.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@anvia/core": "^1.
|
|
38
|
+
"@anvia/core": "^1.21.0"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"prebuild": "test -f ../core/dist/index.d.ts || pnpm --filter @anvia/core build",
|
|
42
|
-
"build": "
|
|
42
|
+
"build": "tsdown src/index.ts --format esm --dts --sourcemap --clean --no-fixed-extension",
|
|
43
43
|
"test": "vitest run",
|
|
44
44
|
"pretypecheck": "test -f ../core/dist/index.d.ts || pnpm --filter @anvia/core build",
|
|
45
45
|
"typecheck": "tsc --noEmit"
|