scorecard-ai 0.3.0 → 0.5.2
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/Client.d.ts +2 -0
- package/api/resources/prompt/client/Client.d.ts +22 -40
- package/api/resources/prompt/client/Client.js +50 -205
- package/api/resources/prompt/client/requests/PromptCreateParams.d.ts +2 -2
- package/api/resources/prompt/client/requests/PromptUpdateParams.d.ts +1 -2
- package/api/resources/run/client/Client.d.ts +5 -13
- package/api/resources/run/client/Client.js +18 -25
- package/api/resources/run/client/requests/RunCreateParams.d.ts +1 -9
- package/api/resources/run/client/requests/UpdateStatusParams.d.ts +2 -4
- package/api/resources/runMetric/client/Client.d.ts +2 -0
- package/api/resources/runMetric/client/Client.js +5 -4
- package/api/resources/score/client/Client.d.ts +7 -5
- package/api/resources/score/client/Client.js +15 -13
- package/api/resources/score/client/requests/ScoreCreateParams.d.ts +1 -0
- package/api/resources/testcase/client/Client.d.ts +10 -10
- package/api/resources/testcase/client/Client.js +29 -22
- package/api/resources/testcase/client/requests/TestcaseCreateParams.d.ts +3 -4
- package/api/resources/testcase/types/TestcaseCreateParamsCustomInputsValue.d.ts +1 -1
- package/api/resources/testcase/types/TestcaseCreateParamsCustomLabelsValue.d.ts +1 -1
- package/api/resources/testrecord/client/Client.d.ts +3 -1
- package/api/resources/testrecord/client/Client.js +11 -9
- package/api/resources/testset/client/Client.d.ts +6 -4
- package/api/resources/testset/client/Client.js +29 -24
- package/api/resources/testset/client/requests/TestsetGetTestcasesRequest.d.ts +6 -0
- package/api/resources/traces/client/Client.d.ts +2 -0
- package/api/resources/traces/client/Client.js +5 -4
- package/api/types/Grade.d.ts +2 -0
- package/api/types/PaginatedTestcaseResponse.d.ts +1 -0
- package/api/types/TestCase.d.ts +2 -0
- package/api/types/TestCaseCustomInputsValue.d.ts +1 -1
- package/api/types/TestCaseCustomLabelsValue.d.ts +1 -1
- package/api/types/TestcaseDeletionResponse.d.ts +9 -0
- package/api/types/TestcaseDeletionResponse.js +5 -0
- package/api/types/Testrecord.d.ts +0 -1
- package/api/types/index.d.ts +1 -0
- package/api/types/index.js +1 -0
- package/core/fetcher/Fetcher.d.ts +1 -0
- package/core/fetcher/Fetcher.js +58 -7
- package/dist/Client.d.ts +2 -0
- package/dist/api/resources/prompt/client/Client.d.ts +22 -40
- package/dist/api/resources/prompt/client/Client.js +50 -205
- package/dist/api/resources/prompt/client/requests/PromptCreateParams.d.ts +2 -2
- package/dist/api/resources/prompt/client/requests/PromptUpdateParams.d.ts +1 -2
- package/dist/api/resources/run/client/Client.d.ts +5 -13
- package/dist/api/resources/run/client/Client.js +18 -25
- package/dist/api/resources/run/client/requests/RunCreateParams.d.ts +1 -9
- package/dist/api/resources/run/client/requests/UpdateStatusParams.d.ts +2 -4
- package/dist/api/resources/runMetric/client/Client.d.ts +2 -0
- package/dist/api/resources/runMetric/client/Client.js +5 -4
- package/dist/api/resources/score/client/Client.d.ts +7 -5
- package/dist/api/resources/score/client/Client.js +15 -13
- package/dist/api/resources/score/client/requests/ScoreCreateParams.d.ts +1 -0
- package/dist/api/resources/testcase/client/Client.d.ts +10 -10
- package/dist/api/resources/testcase/client/Client.js +29 -22
- package/dist/api/resources/testcase/client/requests/TestcaseCreateParams.d.ts +3 -4
- package/dist/api/resources/testcase/types/TestcaseCreateParamsCustomInputsValue.d.ts +1 -1
- package/dist/api/resources/testcase/types/TestcaseCreateParamsCustomLabelsValue.d.ts +1 -1
- package/dist/api/resources/testrecord/client/Client.d.ts +3 -1
- package/dist/api/resources/testrecord/client/Client.js +11 -9
- package/dist/api/resources/testset/client/Client.d.ts +6 -4
- package/dist/api/resources/testset/client/Client.js +29 -24
- package/dist/api/resources/testset/client/requests/TestsetGetTestcasesRequest.d.ts +6 -0
- package/dist/api/resources/traces/client/Client.d.ts +2 -0
- package/dist/api/resources/traces/client/Client.js +5 -4
- package/dist/api/types/Grade.d.ts +2 -0
- package/dist/api/types/PaginatedTestcaseResponse.d.ts +1 -0
- package/dist/api/types/TestCase.d.ts +2 -0
- package/dist/api/types/TestCaseCustomInputsValue.d.ts +1 -1
- package/dist/api/types/TestCaseCustomLabelsValue.d.ts +1 -1
- package/dist/api/types/TestcaseDeletionResponse.d.ts +9 -0
- package/dist/api/types/TestcaseDeletionResponse.js +5 -0
- package/dist/api/types/Testrecord.d.ts +0 -1
- package/dist/api/types/index.d.ts +1 -0
- package/dist/api/types/index.js +1 -0
- package/dist/core/fetcher/Fetcher.d.ts +1 -0
- package/dist/core/fetcher/Fetcher.js +58 -7
- package/dist/serialization/resources/prompt/client/index.d.ts +0 -3
- package/dist/serialization/resources/prompt/client/index.js +0 -16
- package/dist/serialization/resources/prompt/client/requests/PromptUpdateParams.d.ts +0 -1
- package/dist/serialization/resources/prompt/client/requests/PromptUpdateParams.js +0 -1
- package/dist/serialization/resources/run/client/requests/UpdateStatusParams.d.ts +1 -1
- package/dist/serialization/resources/run/client/requests/UpdateStatusParams.js +1 -1
- package/dist/serialization/resources/testcase/client/requests/TestcaseCreateParams.d.ts +1 -1
- package/dist/serialization/resources/testcase/client/requests/TestcaseCreateParams.js +1 -1
- package/dist/serialization/resources/testcase/types/TestcaseCreateParamsCustomInputsValue.d.ts +1 -1
- package/dist/serialization/resources/testcase/types/TestcaseCreateParamsCustomInputsValue.js +4 -1
- package/dist/serialization/resources/testcase/types/TestcaseCreateParamsCustomLabelsValue.d.ts +1 -1
- package/dist/serialization/resources/testcase/types/TestcaseCreateParamsCustomLabelsValue.js +4 -1
- package/dist/serialization/types/TestCaseCustomInputsValue.d.ts +1 -1
- package/dist/serialization/types/TestCaseCustomInputsValue.js +4 -1
- package/dist/serialization/types/TestCaseCustomLabelsValue.d.ts +1 -1
- package/dist/serialization/types/TestCaseCustomLabelsValue.js +4 -1
- package/dist/serialization/types/TestcaseDeletionResponse.d.ts +13 -0
- package/dist/serialization/{resources/prompt/client/getRoots.js → types/TestcaseDeletionResponse.js} +6 -4
- package/dist/serialization/types/Testrecord.d.ts +0 -1
- package/dist/serialization/types/Testrecord.js +0 -1
- package/dist/serialization/types/index.d.ts +1 -0
- package/dist/serialization/types/index.js +1 -0
- package/dist/telemetry.d.ts +6 -0
- package/dist/telemetry.js +65 -0
- package/dist/wrapper/ScorecardClient.d.ts +4 -0
- package/dist/wrapper/ScorecardClient.js +4 -6
- package/package.json +56 -2
- package/reference.md +38 -189
- package/serialization/resources/prompt/client/index.d.ts +0 -3
- package/serialization/resources/prompt/client/index.js +0 -16
- package/serialization/resources/prompt/client/requests/PromptUpdateParams.d.ts +0 -1
- package/serialization/resources/prompt/client/requests/PromptUpdateParams.js +0 -1
- package/serialization/resources/run/client/requests/UpdateStatusParams.d.ts +1 -1
- package/serialization/resources/run/client/requests/UpdateStatusParams.js +1 -1
- package/serialization/resources/testcase/client/requests/TestcaseCreateParams.d.ts +1 -1
- package/serialization/resources/testcase/client/requests/TestcaseCreateParams.js +1 -1
- package/serialization/resources/testcase/types/TestcaseCreateParamsCustomInputsValue.d.ts +1 -1
- package/serialization/resources/testcase/types/TestcaseCreateParamsCustomInputsValue.js +4 -1
- package/serialization/resources/testcase/types/TestcaseCreateParamsCustomLabelsValue.d.ts +1 -1
- package/serialization/resources/testcase/types/TestcaseCreateParamsCustomLabelsValue.js +4 -1
- package/serialization/types/TestCaseCustomInputsValue.d.ts +1 -1
- package/serialization/types/TestCaseCustomInputsValue.js +4 -1
- package/serialization/types/TestCaseCustomLabelsValue.d.ts +1 -1
- package/serialization/types/TestCaseCustomLabelsValue.js +4 -1
- package/serialization/types/TestcaseDeletionResponse.d.ts +13 -0
- package/{dist/serialization/resources/prompt/client/getGraph.js → serialization/types/TestcaseDeletionResponse.js} +6 -4
- package/serialization/types/Testrecord.d.ts +0 -1
- package/serialization/types/Testrecord.js +0 -1
- package/serialization/types/index.d.ts +1 -0
- package/serialization/types/index.js +1 -0
- package/telemetry.d.ts +6 -0
- package/telemetry.js +65 -0
- package/wrapper/ScorecardClient.d.ts +4 -0
- package/wrapper/ScorecardClient.js +4 -6
- package/dist/serialization/resources/prompt/client/getGraph.d.ts +0 -11
- package/dist/serialization/resources/prompt/client/getProds.d.ts +0 -11
- package/dist/serialization/resources/prompt/client/getProds.js +0 -32
- package/dist/serialization/resources/prompt/client/getRoots.d.ts +0 -11
- package/serialization/resources/prompt/client/getGraph.d.ts +0 -11
- package/serialization/resources/prompt/client/getGraph.js +0 -32
- package/serialization/resources/prompt/client/getProds.d.ts +0 -11
- package/serialization/resources/prompt/client/getProds.js +0 -32
- package/serialization/resources/prompt/client/getRoots.d.ts +0 -11
- package/serialization/resources/prompt/client/getRoots.js +0 -32
|
@@ -64,15 +64,16 @@ class Traces {
|
|
|
64
64
|
* await scorecard.traces.get("trace_id")
|
|
65
65
|
*/
|
|
66
66
|
get(traceId, requestOptions) {
|
|
67
|
-
var _a;
|
|
67
|
+
var _a, _b;
|
|
68
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
const _response = yield core.fetcher({
|
|
70
|
-
url: (0, url_join_1.default)((
|
|
69
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
70
|
+
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.ScorecardEnvironment.Default, `v1/traces/${encodeURIComponent(traceId)}/spans`),
|
|
71
71
|
method: "GET",
|
|
72
|
-
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "scorecard-ai", "X-Fern-SDK-Version": "0.
|
|
72
|
+
headers: Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "scorecard-ai", "X-Fern-SDK-Version": "0.5.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
73
73
|
contentType: "application/json",
|
|
74
74
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
75
75
|
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
76
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
76
77
|
});
|
|
77
78
|
if (_response.ok) {
|
|
78
79
|
return yield serializers.traces.get.Response.parseOrThrow(_response.body, {
|
|
@@ -12,7 +12,9 @@ export interface Grade {
|
|
|
12
12
|
binaryScore?: boolean;
|
|
13
13
|
intScore?: number;
|
|
14
14
|
reasoning?: string;
|
|
15
|
+
/** Indicates if a human should assign a grade. */
|
|
15
16
|
humanEval?: boolean;
|
|
17
|
+
/** The status of the grade. */
|
|
16
18
|
status?: Scorecard.ScoreStatus;
|
|
17
19
|
errorMessage?: string;
|
|
18
20
|
createdAt?: Date;
|
|
@@ -5,7 +5,9 @@ import * as Scorecard from "../index";
|
|
|
5
5
|
export interface TestCase {
|
|
6
6
|
id?: number;
|
|
7
7
|
createdAt?: Date;
|
|
8
|
+
/** The ID of the testset the testcase belongs to. */
|
|
8
9
|
testsetId: number;
|
|
10
|
+
/** The user query for the testcase. */
|
|
9
11
|
userQuery: string;
|
|
10
12
|
context?: string;
|
|
11
13
|
ideal?: string;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
*/
|
|
4
4
|
import * as Scorecard from "../index";
|
|
5
|
-
export declare type TestCaseCustomInputsValue =
|
|
5
|
+
export declare type TestCaseCustomInputsValue = Scorecard.FileUrl | Scorecard.JsonObject | string | number | number | boolean;
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
3
|
*/
|
|
4
4
|
import * as Scorecard from "../index";
|
|
5
|
-
export declare type TestCaseCustomLabelsValue =
|
|
5
|
+
export declare type TestCaseCustomLabelsValue = Scorecard.FileUrl | Scorecard.JsonObject | string | number | number | boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
export interface TestcaseDeletionResponse {
|
|
5
|
+
/** The ID of the testcase that was deleted. */
|
|
6
|
+
id: number;
|
|
7
|
+
/** The message indicating the testcase was deleted. */
|
|
8
|
+
detail: string;
|
|
9
|
+
}
|
|
@@ -12,7 +12,6 @@ export interface Testrecord {
|
|
|
12
12
|
context?: string;
|
|
13
13
|
modelResponse?: string;
|
|
14
14
|
ideal?: string;
|
|
15
|
-
fullPrompt?: string;
|
|
16
15
|
customInputs?: Record<string, Scorecard.TestrecordCustomInputsValue | undefined>;
|
|
17
16
|
customLabels?: Record<string, Scorecard.TestrecordCustomLabelsValue | undefined>;
|
|
18
17
|
customOutputs?: Record<string, Scorecard.TestrecordCustomOutputsValue | undefined>;
|
|
@@ -24,6 +24,7 @@ export * from "./TestCase";
|
|
|
24
24
|
export * from "./TestCaseCreate";
|
|
25
25
|
export * from "./TestRecordCreate";
|
|
26
26
|
export * from "./TestSetCreate";
|
|
27
|
+
export * from "./TestcaseDeletionResponse";
|
|
27
28
|
export * from "./TestrecordCustomInputsValue";
|
|
28
29
|
export * from "./TestrecordCustomLabelsValue";
|
|
29
30
|
export * from "./TestrecordCustomOutputsValue";
|
package/dist/api/types/index.js
CHANGED
|
@@ -40,6 +40,7 @@ __exportStar(require("./TestCase"), exports);
|
|
|
40
40
|
__exportStar(require("./TestCaseCreate"), exports);
|
|
41
41
|
__exportStar(require("./TestRecordCreate"), exports);
|
|
42
42
|
__exportStar(require("./TestSetCreate"), exports);
|
|
43
|
+
__exportStar(require("./TestcaseDeletionResponse"), exports);
|
|
43
44
|
__exportStar(require("./TestrecordCustomInputsValue"), exports);
|
|
44
45
|
__exportStar(require("./TestrecordCustomLabelsValue"), exports);
|
|
45
46
|
__exportStar(require("./TestrecordCustomOutputsValue"), exports);
|
|
@@ -11,6 +11,7 @@ export declare namespace Fetcher {
|
|
|
11
11
|
timeoutMs?: number;
|
|
12
12
|
maxRetries?: number;
|
|
13
13
|
withCredentials?: boolean;
|
|
14
|
+
abortSignal?: AbortSignal;
|
|
14
15
|
responseType?: "json" | "blob" | "streaming" | "text";
|
|
15
16
|
}
|
|
16
17
|
type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError;
|
|
@@ -63,6 +63,9 @@ function fetcherImpl(args) {
|
|
|
63
63
|
if (body instanceof Uint8Array) {
|
|
64
64
|
return body;
|
|
65
65
|
}
|
|
66
|
+
else if (args.contentType === "application/x-www-form-urlencoded" && typeof args.body === "string") {
|
|
67
|
+
return args.body;
|
|
68
|
+
}
|
|
66
69
|
else {
|
|
67
70
|
return JSON.stringify(body);
|
|
68
71
|
}
|
|
@@ -96,20 +99,27 @@ function fetcherImpl(args) {
|
|
|
96
99
|
? fetch
|
|
97
100
|
: (yield Promise.resolve().then(() => __importStar(require("node-fetch")))).default;
|
|
98
101
|
const makeRequest = () => __awaiter(this, void 0, void 0, function* () {
|
|
99
|
-
const
|
|
100
|
-
|
|
102
|
+
const signals = [];
|
|
103
|
+
// Add timeout signal
|
|
104
|
+
let timeoutAbortId = undefined;
|
|
101
105
|
if (args.timeoutMs != null) {
|
|
102
|
-
abortId =
|
|
106
|
+
const { signal, abortId } = getTimeoutSignal(args.timeoutMs);
|
|
107
|
+
timeoutAbortId = abortId;
|
|
108
|
+
signals.push(signal);
|
|
109
|
+
}
|
|
110
|
+
// Add arbitrary signal
|
|
111
|
+
if (args.abortSignal != null) {
|
|
112
|
+
signals.push(args.abortSignal);
|
|
103
113
|
}
|
|
104
114
|
const response = yield fetchFn(url, {
|
|
105
115
|
method: args.method,
|
|
106
116
|
headers,
|
|
107
117
|
body,
|
|
108
|
-
signal:
|
|
118
|
+
signal: anySignal(signals),
|
|
109
119
|
credentials: args.withCredentials ? "include" : undefined,
|
|
110
120
|
});
|
|
111
|
-
if (
|
|
112
|
-
clearTimeout(
|
|
121
|
+
if (timeoutAbortId != null) {
|
|
122
|
+
clearTimeout(timeoutAbortId);
|
|
113
123
|
}
|
|
114
124
|
return response;
|
|
115
125
|
});
|
|
@@ -175,7 +185,16 @@ function fetcherImpl(args) {
|
|
|
175
185
|
}
|
|
176
186
|
}
|
|
177
187
|
catch (error) {
|
|
178
|
-
if (
|
|
188
|
+
if (args.abortSignal != null && args.abortSignal.aborted) {
|
|
189
|
+
return {
|
|
190
|
+
ok: false,
|
|
191
|
+
error: {
|
|
192
|
+
reason: "unknown",
|
|
193
|
+
errorMessage: "The user aborted a request",
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
else if (error instanceof Error && error.name === "AbortError") {
|
|
179
198
|
return {
|
|
180
199
|
ok: false,
|
|
181
200
|
error: {
|
|
@@ -202,4 +221,36 @@ function fetcherImpl(args) {
|
|
|
202
221
|
}
|
|
203
222
|
});
|
|
204
223
|
}
|
|
224
|
+
const TIMEOUT = "timeout";
|
|
225
|
+
function getTimeoutSignal(timeoutMs) {
|
|
226
|
+
const controller = new AbortController();
|
|
227
|
+
const abortId = setTimeout(() => controller.abort(TIMEOUT), timeoutMs);
|
|
228
|
+
return { signal: controller.signal, abortId };
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Returns an abort signal that is getting aborted when
|
|
232
|
+
* at least one of the specified abort signals is aborted.
|
|
233
|
+
*
|
|
234
|
+
* Requires at least node.js 18.
|
|
235
|
+
*/
|
|
236
|
+
function anySignal(...args) {
|
|
237
|
+
// Allowing signals to be passed either as array
|
|
238
|
+
// of signals or as multiple arguments.
|
|
239
|
+
const signals = (args.length === 1 && Array.isArray(args[0]) ? args[0] : args);
|
|
240
|
+
const controller = new AbortController();
|
|
241
|
+
for (const signal of signals) {
|
|
242
|
+
if (signal.aborted) {
|
|
243
|
+
// Exiting early if one of the signals
|
|
244
|
+
// is already aborted.
|
|
245
|
+
controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason);
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
// Listening for signals and removing the listeners
|
|
249
|
+
// when at least one symbol is aborted.
|
|
250
|
+
signal.addEventListener("abort", () => controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason), {
|
|
251
|
+
signal: controller.signal,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
return controller.signal;
|
|
255
|
+
}
|
|
205
256
|
exports.fetcher = fetcherImpl;
|
|
@@ -10,24 +10,8 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
26
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
15
|
};
|
|
28
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getGraph = exports.getProds = exports.getRoots = void 0;
|
|
30
|
-
exports.getRoots = __importStar(require("./getRoots"));
|
|
31
|
-
exports.getProds = __importStar(require("./getProds"));
|
|
32
|
-
exports.getGraph = __importStar(require("./getGraph"));
|
|
33
17
|
__exportStar(require("./requests"), exports);
|
|
@@ -7,7 +7,6 @@ import * as core from "../../../../../core";
|
|
|
7
7
|
export declare const PromptUpdateParams: core.serialization.Schema<serializers.PromptUpdateParams.Raw, Scorecard.PromptUpdateParams>;
|
|
8
8
|
export declare namespace PromptUpdateParams {
|
|
9
9
|
interface Raw {
|
|
10
|
-
is_archived?: boolean | null;
|
|
11
10
|
is_prod?: boolean | null;
|
|
12
11
|
}
|
|
13
12
|
}
|
|
@@ -29,6 +29,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.PromptUpdateParams = void 0;
|
|
30
30
|
const core = __importStar(require("../../../../../core"));
|
|
31
31
|
exports.PromptUpdateParams = core.serialization.object({
|
|
32
|
-
isArchived: core.serialization.property("is_archived", core.serialization.boolean().optional()),
|
|
33
32
|
isProd: core.serialization.property("is_prod", core.serialization.boolean().optional()),
|
|
34
33
|
});
|
|
@@ -8,6 +8,6 @@ import { RunStatus } from "../../../../types/RunStatus";
|
|
|
8
8
|
export declare const UpdateStatusParams: core.serialization.Schema<serializers.UpdateStatusParams.Raw, Scorecard.UpdateStatusParams>;
|
|
9
9
|
export declare namespace UpdateStatusParams {
|
|
10
10
|
interface Raw {
|
|
11
|
-
status
|
|
11
|
+
status?: RunStatus.Raw | null;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -30,5 +30,5 @@ exports.UpdateStatusParams = void 0;
|
|
|
30
30
|
const core = __importStar(require("../../../../../core"));
|
|
31
31
|
const RunStatus_1 = require("../../../../types/RunStatus");
|
|
32
32
|
exports.UpdateStatusParams = core.serialization.object({
|
|
33
|
-
status: RunStatus_1.RunStatus,
|
|
33
|
+
status: RunStatus_1.RunStatus.optional(),
|
|
34
34
|
});
|
|
@@ -9,7 +9,7 @@ import { TestcaseCreateParamsCustomLabelsValue } from "../../types/TestcaseCreat
|
|
|
9
9
|
export declare const TestcaseCreateParams: core.serialization.Schema<serializers.TestcaseCreateParams.Raw, Scorecard.TestcaseCreateParams>;
|
|
10
10
|
export declare namespace TestcaseCreateParams {
|
|
11
11
|
interface Raw {
|
|
12
|
-
user_query
|
|
12
|
+
user_query?: string | null;
|
|
13
13
|
context?: string | null;
|
|
14
14
|
ideal?: string | null;
|
|
15
15
|
custom_inputs?: Record<string, TestcaseCreateParamsCustomInputsValue.Raw | null | undefined> | null;
|
|
@@ -31,7 +31,7 @@ const core = __importStar(require("../../../../../core"));
|
|
|
31
31
|
const TestcaseCreateParamsCustomInputsValue_1 = require("../../types/TestcaseCreateParamsCustomInputsValue");
|
|
32
32
|
const TestcaseCreateParamsCustomLabelsValue_1 = require("../../types/TestcaseCreateParamsCustomLabelsValue");
|
|
33
33
|
exports.TestcaseCreateParams = core.serialization.object({
|
|
34
|
-
userQuery: core.serialization.property("user_query", core.serialization.string()),
|
|
34
|
+
userQuery: core.serialization.property("user_query", core.serialization.string().optional()),
|
|
35
35
|
context: core.serialization.string().optional(),
|
|
36
36
|
ideal: core.serialization.string().optional(),
|
|
37
37
|
customInputs: core.serialization.property("custom_inputs", core.serialization
|
package/dist/serialization/resources/testcase/types/TestcaseCreateParamsCustomInputsValue.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ import * as core from "../../../../core";
|
|
|
7
7
|
import { FileUrl } from "../../../types/FileUrl";
|
|
8
8
|
export declare const TestcaseCreateParamsCustomInputsValue: core.serialization.Schema<serializers.TestcaseCreateParamsCustomInputsValue.Raw, Scorecard.TestcaseCreateParamsCustomInputsValue>;
|
|
9
9
|
export declare namespace TestcaseCreateParamsCustomInputsValue {
|
|
10
|
-
type Raw =
|
|
10
|
+
type Raw = FileUrl.Raw | serializers.JsonObject.Raw | string | number | number | boolean;
|
|
11
11
|
}
|
package/dist/serialization/resources/testcase/types/TestcaseCreateParamsCustomInputsValue.js
CHANGED
|
@@ -39,7 +39,10 @@ exports.TestcaseCreateParamsCustomInputsValue = void 0;
|
|
|
39
39
|
const core = __importStar(require("../../../../core"));
|
|
40
40
|
const FileUrl_1 = require("../../../types/FileUrl");
|
|
41
41
|
exports.TestcaseCreateParamsCustomInputsValue = core.serialization.undiscriminatedUnion([
|
|
42
|
-
core.serialization.string(),
|
|
43
42
|
FileUrl_1.FileUrl,
|
|
44
43
|
core.serialization.lazyObject(() => __awaiter(void 0, void 0, void 0, function* () { return (yield Promise.resolve().then(() => __importStar(require("../../..")))).JsonObject; })),
|
|
44
|
+
core.serialization.string(),
|
|
45
|
+
core.serialization.number(),
|
|
46
|
+
core.serialization.number(),
|
|
47
|
+
core.serialization.boolean(),
|
|
45
48
|
]);
|
package/dist/serialization/resources/testcase/types/TestcaseCreateParamsCustomLabelsValue.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ import * as core from "../../../../core";
|
|
|
7
7
|
import { FileUrl } from "../../../types/FileUrl";
|
|
8
8
|
export declare const TestcaseCreateParamsCustomLabelsValue: core.serialization.Schema<serializers.TestcaseCreateParamsCustomLabelsValue.Raw, Scorecard.TestcaseCreateParamsCustomLabelsValue>;
|
|
9
9
|
export declare namespace TestcaseCreateParamsCustomLabelsValue {
|
|
10
|
-
type Raw =
|
|
10
|
+
type Raw = FileUrl.Raw | serializers.JsonObject.Raw | string | number | number | boolean;
|
|
11
11
|
}
|
package/dist/serialization/resources/testcase/types/TestcaseCreateParamsCustomLabelsValue.js
CHANGED
|
@@ -39,7 +39,10 @@ exports.TestcaseCreateParamsCustomLabelsValue = void 0;
|
|
|
39
39
|
const core = __importStar(require("../../../../core"));
|
|
40
40
|
const FileUrl_1 = require("../../../types/FileUrl");
|
|
41
41
|
exports.TestcaseCreateParamsCustomLabelsValue = core.serialization.undiscriminatedUnion([
|
|
42
|
-
core.serialization.string(),
|
|
43
42
|
FileUrl_1.FileUrl,
|
|
44
43
|
core.serialization.lazyObject(() => __awaiter(void 0, void 0, void 0, function* () { return (yield Promise.resolve().then(() => __importStar(require("../../..")))).JsonObject; })),
|
|
44
|
+
core.serialization.string(),
|
|
45
|
+
core.serialization.number(),
|
|
46
|
+
core.serialization.number(),
|
|
47
|
+
core.serialization.boolean(),
|
|
45
48
|
]);
|
|
@@ -7,5 +7,5 @@ import * as core from "../../core";
|
|
|
7
7
|
import { FileUrl } from "./FileUrl";
|
|
8
8
|
export declare const TestCaseCustomInputsValue: core.serialization.Schema<serializers.TestCaseCustomInputsValue.Raw, Scorecard.TestCaseCustomInputsValue>;
|
|
9
9
|
export declare namespace TestCaseCustomInputsValue {
|
|
10
|
-
type Raw =
|
|
10
|
+
type Raw = FileUrl.Raw | serializers.JsonObject.Raw | string | number | number | boolean;
|
|
11
11
|
}
|
|
@@ -39,7 +39,10 @@ exports.TestCaseCustomInputsValue = void 0;
|
|
|
39
39
|
const core = __importStar(require("../../core"));
|
|
40
40
|
const FileUrl_1 = require("./FileUrl");
|
|
41
41
|
exports.TestCaseCustomInputsValue = core.serialization.undiscriminatedUnion([
|
|
42
|
-
core.serialization.string(),
|
|
43
42
|
FileUrl_1.FileUrl,
|
|
44
43
|
core.serialization.lazyObject(() => __awaiter(void 0, void 0, void 0, function* () { return (yield Promise.resolve().then(() => __importStar(require("..")))).JsonObject; })),
|
|
44
|
+
core.serialization.string(),
|
|
45
|
+
core.serialization.number(),
|
|
46
|
+
core.serialization.number(),
|
|
47
|
+
core.serialization.boolean(),
|
|
45
48
|
]);
|
|
@@ -7,5 +7,5 @@ import * as core from "../../core";
|
|
|
7
7
|
import { FileUrl } from "./FileUrl";
|
|
8
8
|
export declare const TestCaseCustomLabelsValue: core.serialization.Schema<serializers.TestCaseCustomLabelsValue.Raw, Scorecard.TestCaseCustomLabelsValue>;
|
|
9
9
|
export declare namespace TestCaseCustomLabelsValue {
|
|
10
|
-
type Raw =
|
|
10
|
+
type Raw = FileUrl.Raw | serializers.JsonObject.Raw | string | number | number | boolean;
|
|
11
11
|
}
|
|
@@ -39,7 +39,10 @@ exports.TestCaseCustomLabelsValue = void 0;
|
|
|
39
39
|
const core = __importStar(require("../../core"));
|
|
40
40
|
const FileUrl_1 = require("./FileUrl");
|
|
41
41
|
exports.TestCaseCustomLabelsValue = core.serialization.undiscriminatedUnion([
|
|
42
|
-
core.serialization.string(),
|
|
43
42
|
FileUrl_1.FileUrl,
|
|
44
43
|
core.serialization.lazyObject(() => __awaiter(void 0, void 0, void 0, function* () { return (yield Promise.resolve().then(() => __importStar(require("..")))).JsonObject; })),
|
|
44
|
+
core.serialization.string(),
|
|
45
|
+
core.serialization.number(),
|
|
46
|
+
core.serialization.number(),
|
|
47
|
+
core.serialization.boolean(),
|
|
45
48
|
]);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as serializers from "../index";
|
|
5
|
+
import * as Scorecard from "../../api/index";
|
|
6
|
+
import * as core from "../../core";
|
|
7
|
+
export declare const TestcaseDeletionResponse: core.serialization.ObjectSchema<serializers.TestcaseDeletionResponse.Raw, Scorecard.TestcaseDeletionResponse>;
|
|
8
|
+
export declare namespace TestcaseDeletionResponse {
|
|
9
|
+
interface Raw {
|
|
10
|
+
id: number;
|
|
11
|
+
detail: string;
|
|
12
|
+
}
|
|
13
|
+
}
|
package/dist/serialization/{resources/prompt/client/getRoots.js → types/TestcaseDeletionResponse.js}
RENAMED
|
@@ -26,7 +26,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
26
26
|
return result;
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
30
|
-
const core = __importStar(require("
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
exports.TestcaseDeletionResponse = void 0;
|
|
30
|
+
const core = __importStar(require("../../core"));
|
|
31
|
+
exports.TestcaseDeletionResponse = core.serialization.object({
|
|
32
|
+
id: core.serialization.number(),
|
|
33
|
+
detail: core.serialization.string(),
|
|
34
|
+
});
|
|
@@ -21,7 +21,6 @@ export declare namespace Testrecord {
|
|
|
21
21
|
context?: string | null;
|
|
22
22
|
model_response?: string | null;
|
|
23
23
|
ideal?: string | null;
|
|
24
|
-
full_prompt?: string | null;
|
|
25
24
|
custom_inputs?: Record<string, TestrecordCustomInputsValue.Raw | null | undefined> | null;
|
|
26
25
|
custom_labels?: Record<string, TestrecordCustomLabelsValue.Raw | null | undefined> | null;
|
|
27
26
|
custom_outputs?: Record<string, TestrecordCustomOutputsValue.Raw | null | undefined> | null;
|
|
@@ -43,7 +43,6 @@ exports.Testrecord = core.serialization.object({
|
|
|
43
43
|
context: core.serialization.string().optional(),
|
|
44
44
|
modelResponse: core.serialization.property("model_response", core.serialization.string().optional()),
|
|
45
45
|
ideal: core.serialization.string().optional(),
|
|
46
|
-
fullPrompt: core.serialization.property("full_prompt", core.serialization.string().optional()),
|
|
47
46
|
customInputs: core.serialization.property("custom_inputs", core.serialization.record(core.serialization.string(), TestrecordCustomInputsValue_1.TestrecordCustomInputsValue.optional()).optional()),
|
|
48
47
|
customLabels: core.serialization.property("custom_labels", core.serialization.record(core.serialization.string(), TestrecordCustomLabelsValue_1.TestrecordCustomLabelsValue.optional()).optional()),
|
|
49
48
|
customOutputs: core.serialization.property("custom_outputs", core.serialization.record(core.serialization.string(), TestrecordCustomOutputsValue_1.TestrecordCustomOutputsValue.optional()).optional()),
|
|
@@ -24,6 +24,7 @@ export * from "./TestCase";
|
|
|
24
24
|
export * from "./TestCaseCreate";
|
|
25
25
|
export * from "./TestRecordCreate";
|
|
26
26
|
export * from "./TestSetCreate";
|
|
27
|
+
export * from "./TestcaseDeletionResponse";
|
|
27
28
|
export * from "./TestrecordCustomInputsValue";
|
|
28
29
|
export * from "./TestrecordCustomLabelsValue";
|
|
29
30
|
export * from "./TestrecordCustomOutputsValue";
|
|
@@ -40,6 +40,7 @@ __exportStar(require("./TestCase"), exports);
|
|
|
40
40
|
__exportStar(require("./TestCaseCreate"), exports);
|
|
41
41
|
__exportStar(require("./TestRecordCreate"), exports);
|
|
42
42
|
__exportStar(require("./TestSetCreate"), exports);
|
|
43
|
+
__exportStar(require("./TestcaseDeletionResponse"), exports);
|
|
43
44
|
__exportStar(require("./TestrecordCustomInputsValue"), exports);
|
|
44
45
|
__exportStar(require("./TestrecordCustomLabelsValue"), exports);
|
|
45
46
|
__exportStar(require("./TestrecordCustomOutputsValue"), exports);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const trace: any;
|
|
2
|
+
declare const OTLPTraceExporter: any;
|
|
3
|
+
declare const Resource: any;
|
|
4
|
+
declare const BatchSpanProcessor: any, ConsoleSpanExporter: any, NodeTracerProvider: any;
|
|
5
|
+
declare const SEMRESATTRS_SERVICE_NAME: any;
|
|
6
|
+
declare function checkInstalled(...modules: string[]): boolean;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
const { trace } = require('@opentelemetry/api');
|
|
12
|
+
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
|
|
13
|
+
const { Resource } = require('@opentelemetry/resources');
|
|
14
|
+
const { BatchSpanProcessor, ConsoleSpanExporter, NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
|
|
15
|
+
const { SEMRESATTRS_SERVICE_NAME } = require('@opentelemetry/semantic-conventions');
|
|
16
|
+
function checkInstalled(...modules) {
|
|
17
|
+
for (let i = 0; i < modules.length; i++) {
|
|
18
|
+
let module = modules[i];
|
|
19
|
+
try {
|
|
20
|
+
require.resolve(module);
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
module.exports = {
|
|
29
|
+
setup(name, scorecardConfig, debug = false) {
|
|
30
|
+
const resource = Resource.default().merge(new Resource({
|
|
31
|
+
[SEMRESATTRS_SERVICE_NAME]: name,
|
|
32
|
+
}));
|
|
33
|
+
const provider = new NodeTracerProvider({
|
|
34
|
+
resource,
|
|
35
|
+
});
|
|
36
|
+
if (debug) {
|
|
37
|
+
const consoleExporter = new ConsoleSpanExporter();
|
|
38
|
+
const processor = new BatchSpanProcessor(consoleExporter);
|
|
39
|
+
provider.addSpanProcessor(processor);
|
|
40
|
+
}
|
|
41
|
+
const url = scorecardConfig.telemetryUrl ? scorecardConfig.telemetryUrl : 'https://telemetry.getscorecard.ai';
|
|
42
|
+
const otlpExporter = new OTLPTraceExporter({
|
|
43
|
+
url: `${url}/v1/traces`,
|
|
44
|
+
headers: {
|
|
45
|
+
'Authorization': `Bearer ${scorecardConfig.telemetryKey}`
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
const processor = new BatchSpanProcessor(otlpExporter);
|
|
49
|
+
provider.addSpanProcessor(processor);
|
|
50
|
+
provider.register();
|
|
51
|
+
if (checkInstalled('@langchain/core')) {
|
|
52
|
+
const { LangChainInstrumentation } = require('@arizeai/openinference-instrumentation-langchain');
|
|
53
|
+
new LangChainInstrumentation().manuallyInstrument(require('@langchain/core/callbacks/manager'));
|
|
54
|
+
}
|
|
55
|
+
if (checkInstalled('openai')) {
|
|
56
|
+
const { OpenAIInstrumentation } = require('@arizeai/openinference-instrumentation-openai');
|
|
57
|
+
new OpenAIInstrumentation().manuallyInstrument(require('openai'));
|
|
58
|
+
}
|
|
59
|
+
const tracer = trace.getTracer();
|
|
60
|
+
process.on('beforeExit', () => __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
yield provider.shutdown();
|
|
62
|
+
}));
|
|
63
|
+
return tracer;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ScorecardClient as FernClient } from "../Client";
|
|
2
|
+
import { ScorecardEnvironment } from "../environments";
|
|
2
3
|
import * as core from "../core";
|
|
3
4
|
export declare namespace ScorecardClient {
|
|
4
5
|
interface Options {
|
|
@@ -7,6 +8,9 @@ export declare namespace ScorecardClient {
|
|
|
7
8
|
* variable SCORECARD_API_KEY.
|
|
8
9
|
*/
|
|
9
10
|
apiKey?: core.Supplier<string>;
|
|
11
|
+
environment?: core.Supplier<ScorecardEnvironment | string>;
|
|
12
|
+
}
|
|
13
|
+
interface RequestOptions extends FernClient.RequestOptions {
|
|
10
14
|
}
|
|
11
15
|
interface RunTestArgs {
|
|
12
16
|
/**
|
|
@@ -39,13 +39,11 @@ class ScorecardClient extends Client_1.ScorecardClient {
|
|
|
39
39
|
constructor(options = {}) {
|
|
40
40
|
var _a;
|
|
41
41
|
const apiKey = (_a = options.apiKey) !== null && _a !== void 0 ? _a : process.env["SCORECARD_API_KEY"];
|
|
42
|
-
if (apiKey
|
|
43
|
-
|
|
44
|
-
message: "Please pass in your Scorecard API Key or export SCORECARD_API_KEY in your environment.",
|
|
45
|
-
});
|
|
42
|
+
if (apiKey !== undefined) {
|
|
43
|
+
super(Object.assign(Object.assign({}, options), { apiKey }));
|
|
46
44
|
}
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
throw new errors.ScorecardError({
|
|
46
|
+
message: "Please pass in your Scorecard API Key or export SCORECARD_API_KEY in your environment.",
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
49
|
/**
|