langsmith 0.1.43 → 0.1.45
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/client.cjs +160 -99
- package/dist/client.d.ts +32 -3
- package/dist/client.js +160 -99
- package/dist/evaluation/_runner.cjs +29 -5
- package/dist/evaluation/_runner.d.ts +2 -1
- package/dist/evaluation/_runner.js +28 -5
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/schemas.d.ts +2 -0
- package/dist/utils/error.cjs +65 -1
- package/dist/utils/error.d.ts +43 -0
- package/dist/utils/error.js +62 -0
- package/package.json +1 -1
package/dist/schemas.d.ts
CHANGED
|
@@ -189,6 +189,8 @@ export interface BaseDataset {
|
|
|
189
189
|
description: string;
|
|
190
190
|
tenant_id: string;
|
|
191
191
|
data_type?: DataType;
|
|
192
|
+
inputs_schema_definition?: KVMap;
|
|
193
|
+
outputs_schema_definition?: KVMap;
|
|
192
194
|
}
|
|
193
195
|
export interface Dataset extends BaseDataset {
|
|
194
196
|
id: string;
|
package/dist/utils/error.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.printErrorStackTrace = void 0;
|
|
3
|
+
exports.raiseForStatus = exports.LangSmithConflictError = exports.printErrorStackTrace = void 0;
|
|
4
4
|
function getErrorStackTrace(e) {
|
|
5
5
|
if (typeof e !== "object" || e == null)
|
|
6
6
|
return undefined;
|
|
@@ -23,3 +23,67 @@ function printErrorStackTrace(e) {
|
|
|
23
23
|
console.error(stack);
|
|
24
24
|
}
|
|
25
25
|
exports.printErrorStackTrace = printErrorStackTrace;
|
|
26
|
+
/**
|
|
27
|
+
* LangSmithConflictError
|
|
28
|
+
*
|
|
29
|
+
* Represents an error that occurs when there's a conflict during an operation,
|
|
30
|
+
* typically corresponding to HTTP 409 status code responses.
|
|
31
|
+
*
|
|
32
|
+
* This error is thrown when an attempt to create or modify a resource conflicts
|
|
33
|
+
* with the current state of the resource on the server. Common scenarios include:
|
|
34
|
+
* - Attempting to create a resource that already exists
|
|
35
|
+
* - Trying to update a resource that has been modified by another process
|
|
36
|
+
* - Violating a uniqueness constraint in the data
|
|
37
|
+
*
|
|
38
|
+
* @extends Error
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* try {
|
|
42
|
+
* await createProject("existingProject");
|
|
43
|
+
* } catch (error) {
|
|
44
|
+
* if (error instanceof ConflictError) {
|
|
45
|
+
* console.log("A conflict occurred:", error.message);
|
|
46
|
+
* // Handle the conflict, e.g., by suggesting a different project name
|
|
47
|
+
* } else {
|
|
48
|
+
* // Handle other types of errors
|
|
49
|
+
* }
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* @property {string} name - Always set to 'ConflictError' for easy identification
|
|
53
|
+
* @property {string} message - Detailed error message including server response
|
|
54
|
+
*
|
|
55
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409
|
|
56
|
+
*/
|
|
57
|
+
class LangSmithConflictError extends Error {
|
|
58
|
+
constructor(message) {
|
|
59
|
+
super(message);
|
|
60
|
+
this.name = "LangSmithConflictError";
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.LangSmithConflictError = LangSmithConflictError;
|
|
64
|
+
/**
|
|
65
|
+
* Throws an appropriate error based on the response status and body.
|
|
66
|
+
*
|
|
67
|
+
* @param response - The fetch Response object
|
|
68
|
+
* @param context - Additional context to include in the error message (e.g., operation being performed)
|
|
69
|
+
* @throws {LangSmithConflictError} When the response status is 409
|
|
70
|
+
* @throws {Error} For all other non-ok responses
|
|
71
|
+
*/
|
|
72
|
+
async function raiseForStatus(response, context, consume) {
|
|
73
|
+
// consume the response body to release the connection
|
|
74
|
+
// https://undici.nodejs.org/#/?id=garbage-collection
|
|
75
|
+
let errorBody;
|
|
76
|
+
if (response.ok) {
|
|
77
|
+
if (consume) {
|
|
78
|
+
errorBody = await response.text();
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
errorBody = await response.text();
|
|
83
|
+
const fullMessage = `Failed to ${context}. Received status [${response.status}]: ${response.statusText}. Server response: ${errorBody}`;
|
|
84
|
+
if (response.status === 409) {
|
|
85
|
+
throw new LangSmithConflictError(fullMessage);
|
|
86
|
+
}
|
|
87
|
+
throw new Error(fullMessage);
|
|
88
|
+
}
|
|
89
|
+
exports.raiseForStatus = raiseForStatus;
|
package/dist/utils/error.d.ts
CHANGED
|
@@ -1 +1,44 @@
|
|
|
1
1
|
export declare function printErrorStackTrace(e: unknown): void;
|
|
2
|
+
/**
|
|
3
|
+
* LangSmithConflictError
|
|
4
|
+
*
|
|
5
|
+
* Represents an error that occurs when there's a conflict during an operation,
|
|
6
|
+
* typically corresponding to HTTP 409 status code responses.
|
|
7
|
+
*
|
|
8
|
+
* This error is thrown when an attempt to create or modify a resource conflicts
|
|
9
|
+
* with the current state of the resource on the server. Common scenarios include:
|
|
10
|
+
* - Attempting to create a resource that already exists
|
|
11
|
+
* - Trying to update a resource that has been modified by another process
|
|
12
|
+
* - Violating a uniqueness constraint in the data
|
|
13
|
+
*
|
|
14
|
+
* @extends Error
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* try {
|
|
18
|
+
* await createProject("existingProject");
|
|
19
|
+
* } catch (error) {
|
|
20
|
+
* if (error instanceof ConflictError) {
|
|
21
|
+
* console.log("A conflict occurred:", error.message);
|
|
22
|
+
* // Handle the conflict, e.g., by suggesting a different project name
|
|
23
|
+
* } else {
|
|
24
|
+
* // Handle other types of errors
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* @property {string} name - Always set to 'ConflictError' for easy identification
|
|
29
|
+
* @property {string} message - Detailed error message including server response
|
|
30
|
+
*
|
|
31
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409
|
|
32
|
+
*/
|
|
33
|
+
export declare class LangSmithConflictError extends Error {
|
|
34
|
+
constructor(message: string);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Throws an appropriate error based on the response status and body.
|
|
38
|
+
*
|
|
39
|
+
* @param response - The fetch Response object
|
|
40
|
+
* @param context - Additional context to include in the error message (e.g., operation being performed)
|
|
41
|
+
* @throws {LangSmithConflictError} When the response status is 409
|
|
42
|
+
* @throws {Error} For all other non-ok responses
|
|
43
|
+
*/
|
|
44
|
+
export declare function raiseForStatus(response: Response, context: string, consume?: boolean): Promise<void>;
|
package/dist/utils/error.js
CHANGED
|
@@ -19,3 +19,65 @@ export function printErrorStackTrace(e) {
|
|
|
19
19
|
return;
|
|
20
20
|
console.error(stack);
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* LangSmithConflictError
|
|
24
|
+
*
|
|
25
|
+
* Represents an error that occurs when there's a conflict during an operation,
|
|
26
|
+
* typically corresponding to HTTP 409 status code responses.
|
|
27
|
+
*
|
|
28
|
+
* This error is thrown when an attempt to create or modify a resource conflicts
|
|
29
|
+
* with the current state of the resource on the server. Common scenarios include:
|
|
30
|
+
* - Attempting to create a resource that already exists
|
|
31
|
+
* - Trying to update a resource that has been modified by another process
|
|
32
|
+
* - Violating a uniqueness constraint in the data
|
|
33
|
+
*
|
|
34
|
+
* @extends Error
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* try {
|
|
38
|
+
* await createProject("existingProject");
|
|
39
|
+
* } catch (error) {
|
|
40
|
+
* if (error instanceof ConflictError) {
|
|
41
|
+
* console.log("A conflict occurred:", error.message);
|
|
42
|
+
* // Handle the conflict, e.g., by suggesting a different project name
|
|
43
|
+
* } else {
|
|
44
|
+
* // Handle other types of errors
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
* @property {string} name - Always set to 'ConflictError' for easy identification
|
|
49
|
+
* @property {string} message - Detailed error message including server response
|
|
50
|
+
*
|
|
51
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409
|
|
52
|
+
*/
|
|
53
|
+
export class LangSmithConflictError extends Error {
|
|
54
|
+
constructor(message) {
|
|
55
|
+
super(message);
|
|
56
|
+
this.name = "LangSmithConflictError";
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Throws an appropriate error based on the response status and body.
|
|
61
|
+
*
|
|
62
|
+
* @param response - The fetch Response object
|
|
63
|
+
* @param context - Additional context to include in the error message (e.g., operation being performed)
|
|
64
|
+
* @throws {LangSmithConflictError} When the response status is 409
|
|
65
|
+
* @throws {Error} For all other non-ok responses
|
|
66
|
+
*/
|
|
67
|
+
export async function raiseForStatus(response, context, consume) {
|
|
68
|
+
// consume the response body to release the connection
|
|
69
|
+
// https://undici.nodejs.org/#/?id=garbage-collection
|
|
70
|
+
let errorBody;
|
|
71
|
+
if (response.ok) {
|
|
72
|
+
if (consume) {
|
|
73
|
+
errorBody = await response.text();
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
errorBody = await response.text();
|
|
78
|
+
const fullMessage = `Failed to ${context}. Received status [${response.status}]: ${response.statusText}. Server response: ${errorBody}`;
|
|
79
|
+
if (response.status === 409) {
|
|
80
|
+
throw new LangSmithConflictError(fullMessage);
|
|
81
|
+
}
|
|
82
|
+
throw new Error(fullMessage);
|
|
83
|
+
}
|