langsmith 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/client.cjs +8 -0
- package/dist/client.js +8 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/jest/reporter.cjs +10 -1
- package/dist/jest/reporter.js +10 -1
- package/dist/utils/jestlike/reporter.cjs +16 -8
- package/dist/utils/jestlike/reporter.d.ts +3 -3
- package/dist/utils/jestlike/reporter.js +16 -8
- package/dist/vitest/reporter.cjs +14 -9
- package/dist/vitest/reporter.js +14 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ yarn add langchain
|
|
|
50
50
|
Tracing can be activated by setting the following environment variables or by manually specifying the LangChainTracer.
|
|
51
51
|
|
|
52
52
|
```typescript
|
|
53
|
-
process.env.
|
|
53
|
+
process.env.LANGSMITH_TRACING = "true";
|
|
54
54
|
process.env.LANGSMITH_ENDPOINT = "https://api.smith.langchain.com";
|
|
55
55
|
// process.env.LANGSMITH_ENDPOINT = "https://eu.api.smith.langchain.com"; // If signed up in the EU region
|
|
56
56
|
process.env.LANGSMITH_API_KEY = "<YOUR-LANGSMITH-API-KEY>";
|
|
@@ -82,7 +82,7 @@ or by directly specifying the connection information in the RunTree.
|
|
|
82
82
|
1. **Copy the environment variables from the Settings Page and add them to your application.**
|
|
83
83
|
|
|
84
84
|
```shell
|
|
85
|
-
export
|
|
85
|
+
export LANGSMITH_TRACING="true";
|
|
86
86
|
export LANGSMITH_API_KEY=<YOUR-LANGSMITH-API-KEY>
|
|
87
87
|
# export LANGSMITH_PROJECT="My Project Name" # Optional: "default" is used if not set
|
|
88
88
|
# export LANGSMITH_ENDPOINT=https://api.smith.langchain.com # or your own server
|
|
@@ -102,7 +102,7 @@ is using the `wrapOpenAI` wrapper function available in LangSmith 0.1.3 and up.
|
|
|
102
102
|
In order to use, you first need to set your LangSmith API key:
|
|
103
103
|
|
|
104
104
|
```shell
|
|
105
|
-
export
|
|
105
|
+
export LANGSMITH_TRACING="true";
|
|
106
106
|
export LANGSMITH_API_KEY=<your-api-key>
|
|
107
107
|
```
|
|
108
108
|
|
package/dist/client.cjs
CHANGED
|
@@ -371,6 +371,10 @@ class Client {
|
|
|
371
371
|
this.webUrl = "http://localhost:3000";
|
|
372
372
|
return this.webUrl;
|
|
373
373
|
}
|
|
374
|
+
else if (this.apiUrl.endsWith("/api/v1")) {
|
|
375
|
+
this.webUrl = this.apiUrl.replace("/api/v1", "");
|
|
376
|
+
return this.webUrl;
|
|
377
|
+
}
|
|
374
378
|
else if (this.apiUrl.includes("/api") &&
|
|
375
379
|
!this.apiUrl.split(".", 1)[0].endsWith("api")) {
|
|
376
380
|
this.webUrl = this.apiUrl.replace("/api", "");
|
|
@@ -384,6 +388,10 @@ class Client {
|
|
|
384
388
|
this.webUrl = "https://eu.smith.langchain.com";
|
|
385
389
|
return this.webUrl;
|
|
386
390
|
}
|
|
391
|
+
else if (this.apiUrl.split(".", 1)[0].includes("beta")) {
|
|
392
|
+
this.webUrl = "https://beta.smith.langchain.com";
|
|
393
|
+
return this.webUrl;
|
|
394
|
+
}
|
|
387
395
|
else {
|
|
388
396
|
this.webUrl = "https://smith.langchain.com";
|
|
389
397
|
return this.webUrl;
|
package/dist/client.js
CHANGED
|
@@ -343,6 +343,10 @@ export class Client {
|
|
|
343
343
|
this.webUrl = "http://localhost:3000";
|
|
344
344
|
return this.webUrl;
|
|
345
345
|
}
|
|
346
|
+
else if (this.apiUrl.endsWith("/api/v1")) {
|
|
347
|
+
this.webUrl = this.apiUrl.replace("/api/v1", "");
|
|
348
|
+
return this.webUrl;
|
|
349
|
+
}
|
|
346
350
|
else if (this.apiUrl.includes("/api") &&
|
|
347
351
|
!this.apiUrl.split(".", 1)[0].endsWith("api")) {
|
|
348
352
|
this.webUrl = this.apiUrl.replace("/api", "");
|
|
@@ -356,6 +360,10 @@ export class Client {
|
|
|
356
360
|
this.webUrl = "https://eu.smith.langchain.com";
|
|
357
361
|
return this.webUrl;
|
|
358
362
|
}
|
|
363
|
+
else if (this.apiUrl.split(".", 1)[0].includes("beta")) {
|
|
364
|
+
this.webUrl = "https://beta.smith.langchain.com";
|
|
365
|
+
return this.webUrl;
|
|
366
|
+
}
|
|
359
367
|
else {
|
|
360
368
|
this.webUrl = "https://smith.langchain.com";
|
|
361
369
|
return this.webUrl;
|
package/dist/index.cjs
CHANGED
|
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "RunTree", { enumerable: true, get: function () {
|
|
|
8
8
|
var fetch_js_1 = require("./singletons/fetch.cjs");
|
|
9
9
|
Object.defineProperty(exports, "overrideFetchImplementation", { enumerable: true, get: function () { return fetch_js_1.overrideFetchImplementation; } });
|
|
10
10
|
// Update using yarn bump-version
|
|
11
|
-
exports.__version__ = "0.3.
|
|
11
|
+
exports.__version__ = "0.3.4";
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { Client, type ClientConfig, type LangSmithTracingClientInterface, } from
|
|
|
2
2
|
export type { Dataset, Example, TracerSession, Run, Feedback, RetrieverOutput, } from "./schemas.js";
|
|
3
3
|
export { RunTree, type RunTreeConfig } from "./run_trees.js";
|
|
4
4
|
export { overrideFetchImplementation } from "./singletons/fetch.js";
|
|
5
|
-
export declare const __version__ = "0.3.
|
|
5
|
+
export declare const __version__ = "0.3.4";
|
package/dist/index.js
CHANGED
package/dist/jest/reporter.cjs
CHANGED
|
@@ -5,6 +5,9 @@ const reporters_1 = require("@jest/reporters");
|
|
|
5
5
|
const reporter_js_1 = require("../utils/jestlike/reporter.cjs");
|
|
6
6
|
class LangSmithEvalReporter extends reporters_1.DefaultReporter {
|
|
7
7
|
async onTestResult(test, testResult, aggregatedResults) {
|
|
8
|
+
if (testResult.failureMessage) {
|
|
9
|
+
console.log(testResult.failureMessage);
|
|
10
|
+
}
|
|
8
11
|
const groupedTestResults = testResult.testResults.reduce((groups, testResult) => {
|
|
9
12
|
const ancestorTitle = testResult.ancestorTitles.join(" > ");
|
|
10
13
|
if (groups[ancestorTitle] === undefined) {
|
|
@@ -16,7 +19,13 @@ class LangSmithEvalReporter extends reporters_1.DefaultReporter {
|
|
|
16
19
|
try {
|
|
17
20
|
for (const testGroupName of Object.keys(groupedTestResults)) {
|
|
18
21
|
const resultGroup = groupedTestResults[testGroupName];
|
|
19
|
-
|
|
22
|
+
const unskippedTests = resultGroup.filter((result) => result.status !== "pending");
|
|
23
|
+
const overallResult = unskippedTests.length === 0
|
|
24
|
+
? "skip"
|
|
25
|
+
: unskippedTests.every((result) => result.status === "passed")
|
|
26
|
+
? "pass"
|
|
27
|
+
: "fail";
|
|
28
|
+
await (0, reporter_js_1.printReporterTable)(testGroupName, resultGroup, overallResult);
|
|
20
29
|
}
|
|
21
30
|
}
|
|
22
31
|
catch (e) {
|
package/dist/jest/reporter.js
CHANGED
|
@@ -3,6 +3,9 @@ import { DefaultReporter } from "@jest/reporters";
|
|
|
3
3
|
import { printReporterTable } from "../utils/jestlike/reporter.js";
|
|
4
4
|
class LangSmithEvalReporter extends DefaultReporter {
|
|
5
5
|
async onTestResult(test, testResult, aggregatedResults) {
|
|
6
|
+
if (testResult.failureMessage) {
|
|
7
|
+
console.log(testResult.failureMessage);
|
|
8
|
+
}
|
|
6
9
|
const groupedTestResults = testResult.testResults.reduce((groups, testResult) => {
|
|
7
10
|
const ancestorTitle = testResult.ancestorTitles.join(" > ");
|
|
8
11
|
if (groups[ancestorTitle] === undefined) {
|
|
@@ -14,7 +17,13 @@ class LangSmithEvalReporter extends DefaultReporter {
|
|
|
14
17
|
try {
|
|
15
18
|
for (const testGroupName of Object.keys(groupedTestResults)) {
|
|
16
19
|
const resultGroup = groupedTestResults[testGroupName];
|
|
17
|
-
|
|
20
|
+
const unskippedTests = resultGroup.filter((result) => result.status !== "pending");
|
|
21
|
+
const overallResult = unskippedTests.length === 0
|
|
22
|
+
? "skip"
|
|
23
|
+
: unskippedTests.every((result) => result.status === "passed")
|
|
24
|
+
? "pass"
|
|
25
|
+
: "fail";
|
|
26
|
+
await printReporterTable(testGroupName, resultGroup, overallResult);
|
|
18
27
|
}
|
|
19
28
|
}
|
|
20
29
|
catch (e) {
|
|
@@ -53,13 +53,13 @@ function formatTestName(name, duration) {
|
|
|
53
53
|
}
|
|
54
54
|
function getFormattedStatus(status) {
|
|
55
55
|
const s = status.toLowerCase();
|
|
56
|
-
if (s === "pending") {
|
|
56
|
+
if (s === "pending" || s === "skipped") {
|
|
57
57
|
return chalk_1.default.yellow("○ Skipped");
|
|
58
58
|
}
|
|
59
|
-
else if (s
|
|
59
|
+
else if (s.includes("pass")) {
|
|
60
60
|
return chalk_1.default.green("✓ Passed");
|
|
61
61
|
}
|
|
62
|
-
else if (s
|
|
62
|
+
else if (s.includes("fail")) {
|
|
63
63
|
return chalk_1.default.red("✕ Failed");
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
@@ -68,13 +68,13 @@ function getFormattedStatus(status) {
|
|
|
68
68
|
}
|
|
69
69
|
function getColorParam(status) {
|
|
70
70
|
const s = status.toLowerCase();
|
|
71
|
-
if (s === "pending") {
|
|
71
|
+
if (s === "pending" || s === "skipped") {
|
|
72
72
|
return { color: "yellow" };
|
|
73
73
|
}
|
|
74
|
-
else if (s
|
|
74
|
+
else if (s.includes("pass")) {
|
|
75
75
|
return { color: "grey" };
|
|
76
76
|
}
|
|
77
|
-
else if (s
|
|
77
|
+
else if (s.includes("fail")) {
|
|
78
78
|
return { color: "red" };
|
|
79
79
|
}
|
|
80
80
|
else {
|
|
@@ -99,7 +99,7 @@ function formatValue(value) {
|
|
|
99
99
|
}
|
|
100
100
|
return String(value);
|
|
101
101
|
}
|
|
102
|
-
async function printReporterTable(results, failureMessage) {
|
|
102
|
+
async function printReporterTable(testSuiteName, results, testStatus, failureMessage) {
|
|
103
103
|
const rows = [];
|
|
104
104
|
const feedbackKeys = new Set();
|
|
105
105
|
let experimentUrl;
|
|
@@ -122,7 +122,7 @@ async function printReporterTable(results, failureMessage) {
|
|
|
122
122
|
getColorParam(status),
|
|
123
123
|
]);
|
|
124
124
|
}
|
|
125
|
-
else if (status === "pending") {
|
|
125
|
+
else if (status === "pending" || status === "skipped") {
|
|
126
126
|
// Skipped
|
|
127
127
|
rows.push([
|
|
128
128
|
{
|
|
@@ -265,6 +265,14 @@ async function printReporterTable(results, failureMessage) {
|
|
|
265
265
|
for (const row of rows) {
|
|
266
266
|
table.addRow(row[0], row[1]);
|
|
267
267
|
}
|
|
268
|
+
const testStatusColor = testStatus.includes("pass")
|
|
269
|
+
? chalk_1.default.green
|
|
270
|
+
: testStatus.includes("fail")
|
|
271
|
+
? chalk_1.default.red
|
|
272
|
+
: chalk_1.default.yellow;
|
|
273
|
+
if (testSuiteName) {
|
|
274
|
+
console.log(testStatusColor(`› ${testSuiteName}`));
|
|
275
|
+
}
|
|
268
276
|
if (failureMessage) {
|
|
269
277
|
console.log(failureMessage);
|
|
270
278
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare function printReporterTable(results: {
|
|
1
|
+
export declare function printReporterTable(testSuiteName: string, results: {
|
|
2
2
|
title: string;
|
|
3
3
|
duration: number;
|
|
4
|
-
status:
|
|
5
|
-
}[], failureMessage?: string): Promise<void>;
|
|
4
|
+
status: "pass" | "passed" | "fail" | "failed" | "pending" | "skipped";
|
|
5
|
+
}[], testStatus: "pass" | "skip" | "fail", failureMessage?: string): Promise<void>;
|
|
@@ -24,13 +24,13 @@ function formatTestName(name, duration) {
|
|
|
24
24
|
}
|
|
25
25
|
function getFormattedStatus(status) {
|
|
26
26
|
const s = status.toLowerCase();
|
|
27
|
-
if (s === "pending") {
|
|
27
|
+
if (s === "pending" || s === "skipped") {
|
|
28
28
|
return chalk.yellow("○ Skipped");
|
|
29
29
|
}
|
|
30
|
-
else if (s
|
|
30
|
+
else if (s.includes("pass")) {
|
|
31
31
|
return chalk.green("✓ Passed");
|
|
32
32
|
}
|
|
33
|
-
else if (s
|
|
33
|
+
else if (s.includes("fail")) {
|
|
34
34
|
return chalk.red("✕ Failed");
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
@@ -39,13 +39,13 @@ function getFormattedStatus(status) {
|
|
|
39
39
|
}
|
|
40
40
|
function getColorParam(status) {
|
|
41
41
|
const s = status.toLowerCase();
|
|
42
|
-
if (s === "pending") {
|
|
42
|
+
if (s === "pending" || s === "skipped") {
|
|
43
43
|
return { color: "yellow" };
|
|
44
44
|
}
|
|
45
|
-
else if (s
|
|
45
|
+
else if (s.includes("pass")) {
|
|
46
46
|
return { color: "grey" };
|
|
47
47
|
}
|
|
48
|
-
else if (s
|
|
48
|
+
else if (s.includes("fail")) {
|
|
49
49
|
return { color: "red" };
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
@@ -70,7 +70,7 @@ function formatValue(value) {
|
|
|
70
70
|
}
|
|
71
71
|
return String(value);
|
|
72
72
|
}
|
|
73
|
-
export async function printReporterTable(results, failureMessage) {
|
|
73
|
+
export async function printReporterTable(testSuiteName, results, testStatus, failureMessage) {
|
|
74
74
|
const rows = [];
|
|
75
75
|
const feedbackKeys = new Set();
|
|
76
76
|
let experimentUrl;
|
|
@@ -93,7 +93,7 @@ export async function printReporterTable(results, failureMessage) {
|
|
|
93
93
|
getColorParam(status),
|
|
94
94
|
]);
|
|
95
95
|
}
|
|
96
|
-
else if (status === "pending") {
|
|
96
|
+
else if (status === "pending" || status === "skipped") {
|
|
97
97
|
// Skipped
|
|
98
98
|
rows.push([
|
|
99
99
|
{
|
|
@@ -236,6 +236,14 @@ export async function printReporterTable(results, failureMessage) {
|
|
|
236
236
|
for (const row of rows) {
|
|
237
237
|
table.addRow(row[0], row[1]);
|
|
238
238
|
}
|
|
239
|
+
const testStatusColor = testStatus.includes("pass")
|
|
240
|
+
? chalk.green
|
|
241
|
+
: testStatus.includes("fail")
|
|
242
|
+
? chalk.red
|
|
243
|
+
: chalk.yellow;
|
|
244
|
+
if (testSuiteName) {
|
|
245
|
+
console.log(testStatusColor(`› ${testSuiteName}`));
|
|
246
|
+
}
|
|
239
247
|
if (failureMessage) {
|
|
240
248
|
console.log(failureMessage);
|
|
241
249
|
}
|
package/dist/vitest/reporter.cjs
CHANGED
|
@@ -9,15 +9,20 @@ class LangSmithEvalReporter extends reporters_1.DefaultReporter {
|
|
|
9
9
|
async onFinished(files, errors) {
|
|
10
10
|
super.onFinished(files, errors);
|
|
11
11
|
for (const file of files) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
for (const task of file.tasks) {
|
|
13
|
+
const testModule = this.ctx.state.getReportedEntity(task);
|
|
14
|
+
const tests = [...testModule.children.allTests()].map((test) => {
|
|
15
|
+
return {
|
|
16
|
+
title: test.name,
|
|
17
|
+
status: test.result()?.state ?? "skipped",
|
|
18
|
+
duration: Math.round(test.diagnostic()?.duration ?? 0),
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
const result = ["pass", "fail", "skip"].includes(task.result?.state ?? "")
|
|
22
|
+
? task.result?.state
|
|
23
|
+
: "skip";
|
|
24
|
+
await (0, reporter_js_1.printReporterTable)(task.name, tests, result);
|
|
25
|
+
}
|
|
21
26
|
}
|
|
22
27
|
}
|
|
23
28
|
}
|
package/dist/vitest/reporter.js
CHANGED
|
@@ -7,15 +7,20 @@ class LangSmithEvalReporter extends DefaultReporter {
|
|
|
7
7
|
async onFinished(files, errors) {
|
|
8
8
|
super.onFinished(files, errors);
|
|
9
9
|
for (const file of files) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
for (const task of file.tasks) {
|
|
11
|
+
const testModule = this.ctx.state.getReportedEntity(task);
|
|
12
|
+
const tests = [...testModule.children.allTests()].map((test) => {
|
|
13
|
+
return {
|
|
14
|
+
title: test.name,
|
|
15
|
+
status: test.result()?.state ?? "skipped",
|
|
16
|
+
duration: Math.round(test.diagnostic()?.duration ?? 0),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
const result = ["pass", "fail", "skip"].includes(task.result?.state ?? "")
|
|
20
|
+
? task.result?.state
|
|
21
|
+
: "skip";
|
|
22
|
+
await printReporterTable(task.name, tests, result);
|
|
23
|
+
}
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
}
|