langsmith 0.0.24 → 0.0.26
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 +16 -1
- package/dist/cli/docker-compose.beta.yaml +18 -0
- package/dist/cli/docker-compose.dev.yaml +12 -2
- package/dist/cli/docker-compose.yaml +11 -1
- package/dist/cli/main.cjs +62 -31
- package/dist/cli/main.js +62 -31
- package/dist/cli/main.ts +69 -32
- package/dist/client.cjs +6 -1
- package/dist/client.d.ts +2 -1
- package/dist/client.js +6 -1
- package/dist/run_trees.cjs +14 -1
- package/dist/run_trees.js +14 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -112,6 +112,8 @@ const parentRunConfig: RunTreeConfig = {
|
|
|
112
112
|
|
|
113
113
|
const parentRun = new RunTree(parentRunConfig);
|
|
114
114
|
|
|
115
|
+
await parentRun.postRun();
|
|
116
|
+
|
|
115
117
|
const childLlmRun = await parentRun.createChild({
|
|
116
118
|
name: "My Proprietary LLM",
|
|
117
119
|
run_type: "llm",
|
|
@@ -123,6 +125,8 @@ const childLlmRun = await parentRun.createChild({
|
|
|
123
125
|
},
|
|
124
126
|
});
|
|
125
127
|
|
|
128
|
+
await childLlmRun.postRun();
|
|
129
|
+
|
|
126
130
|
await childLlmRun.end({
|
|
127
131
|
outputs: {
|
|
128
132
|
generations: [
|
|
@@ -132,6 +136,8 @@ await childLlmRun.end({
|
|
|
132
136
|
},
|
|
133
137
|
});
|
|
134
138
|
|
|
139
|
+
await childLlmRun.patchRun();
|
|
140
|
+
|
|
135
141
|
const childToolRun = await parentRun.createChild({
|
|
136
142
|
name: "transcript_loader",
|
|
137
143
|
run_type: "tool",
|
|
@@ -140,6 +146,7 @@ const childToolRun = await parentRun.createChild({
|
|
|
140
146
|
content_type: "meeting_transcripts",
|
|
141
147
|
},
|
|
142
148
|
});
|
|
149
|
+
await childToolRun.postRun();
|
|
143
150
|
|
|
144
151
|
await childToolRun.end({
|
|
145
152
|
outputs: {
|
|
@@ -147,6 +154,8 @@ await childToolRun.end({
|
|
|
147
154
|
},
|
|
148
155
|
});
|
|
149
156
|
|
|
157
|
+
await childToolRun.patchRun();
|
|
158
|
+
|
|
150
159
|
const childChainRun = await parentRun.createChild({
|
|
151
160
|
name: "Unreliable Component",
|
|
152
161
|
run_type: "tool",
|
|
@@ -155,6 +164,8 @@ const childChainRun = await parentRun.createChild({
|
|
|
155
164
|
},
|
|
156
165
|
});
|
|
157
166
|
|
|
167
|
+
await childChainRun.postRun();
|
|
168
|
+
|
|
158
169
|
try {
|
|
159
170
|
// .... the component does work
|
|
160
171
|
throw new Error("Something went wrong");
|
|
@@ -162,8 +173,12 @@ try {
|
|
|
162
173
|
await childChainRun.end({
|
|
163
174
|
error: `I errored again ${e.message}`,
|
|
164
175
|
});
|
|
176
|
+
await childChainRun.patchRun();
|
|
177
|
+
throw e;
|
|
165
178
|
}
|
|
166
179
|
|
|
180
|
+
await childChainRun.patchRun();
|
|
181
|
+
|
|
167
182
|
await parentRun.end({
|
|
168
183
|
outputs: {
|
|
169
184
|
output: ["The meeting notes are as follows:..."],
|
|
@@ -171,7 +186,7 @@ await parentRun.end({
|
|
|
171
186
|
});
|
|
172
187
|
|
|
173
188
|
// False directs to not exclude child runs
|
|
174
|
-
await parentRun.
|
|
189
|
+
await parentRun.patchRun();
|
|
175
190
|
```
|
|
176
191
|
|
|
177
192
|
### Create a Dataset from Existing Runs
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
version: '3'
|
|
2
|
+
services:
|
|
3
|
+
# TODO: Move to the regular docker-compose.yaml once deployed
|
|
4
|
+
langchain-hub:
|
|
5
|
+
image: langchain/${_LANGSMITH_IMAGE_PREFIX-}langchainhub-backend:latest
|
|
6
|
+
environment:
|
|
7
|
+
- PORT=1985
|
|
8
|
+
- LANGCHAIN_ENV=local_docker
|
|
9
|
+
- LOG_LEVEL=warning
|
|
10
|
+
ports:
|
|
11
|
+
- 1985:1985
|
|
12
|
+
depends_on:
|
|
13
|
+
- langchain-db
|
|
14
|
+
langchain-db:
|
|
15
|
+
volumes:
|
|
16
|
+
- rc-langchain-db-data:/var/lib/postgresql/data
|
|
17
|
+
volumes:
|
|
18
|
+
rc-langchain-db-data:
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
version: '3'
|
|
2
2
|
services:
|
|
3
|
+
langchain-hub:
|
|
4
|
+
image: langchain/${_LANGSMITH_IMAGE_PREFIX-}langchainhub-backend:latest
|
|
5
|
+
environment:
|
|
6
|
+
- PORT=1985
|
|
7
|
+
- LANGCHAIN_ENV=local_docker
|
|
8
|
+
- LOG_LEVEL=warning
|
|
9
|
+
ports:
|
|
10
|
+
- 1985:1985
|
|
11
|
+
depends_on:
|
|
12
|
+
- langchain-db
|
|
3
13
|
langchain-db:
|
|
4
14
|
volumes:
|
|
5
|
-
-
|
|
15
|
+
- dev-langchain-db-data:/var/lib/postgresql/data
|
|
6
16
|
volumes:
|
|
7
|
-
|
|
17
|
+
dev-langchain-db-data:
|
|
@@ -26,7 +26,17 @@ services:
|
|
|
26
26
|
environment:
|
|
27
27
|
- LANGCHAIN_ENV=local_docker
|
|
28
28
|
- LOG_LEVEL=warning
|
|
29
|
-
entrypoint: "rq worker --with-scheduler -u redis://langchain-redis:6379 --serializer lc_database.queue.serializer.ORJSONSerializer --worker-class lc_database.queue.worker.Worker"
|
|
29
|
+
entrypoint: "rq worker --with-scheduler -u redis://langchain-redis:6379 --serializer lc_database.queue.serializer.ORJSONSerializer --worker-class lc_database.queue.worker.Worker --connection-class lc_database.queue.connection.RedisRetry"
|
|
30
|
+
langchain-hub:
|
|
31
|
+
image: langchain/${_LANGSMITH_IMAGE_PREFIX-}langchainhub-backend:latest
|
|
32
|
+
environment:
|
|
33
|
+
- PORT=1985
|
|
34
|
+
- LANGCHAIN_ENV=local_docker
|
|
35
|
+
- LOG_LEVEL=warning
|
|
36
|
+
ports:
|
|
37
|
+
- 1985:1985
|
|
38
|
+
depends_on:
|
|
39
|
+
- langchain-db
|
|
30
40
|
langchain-db:
|
|
31
41
|
image: postgres:14.7
|
|
32
42
|
command:
|
package/dist/cli/main.cjs
CHANGED
|
@@ -149,6 +149,12 @@ class SmithCommand {
|
|
|
149
149
|
writable: true,
|
|
150
150
|
value: ""
|
|
151
151
|
});
|
|
152
|
+
Object.defineProperty(this, "dockerComposeBetaFile", {
|
|
153
|
+
enumerable: true,
|
|
154
|
+
configurable: true,
|
|
155
|
+
writable: true,
|
|
156
|
+
value: ""
|
|
157
|
+
});
|
|
152
158
|
Object.defineProperty(this, "ngrokPath", {
|
|
153
159
|
enumerable: true,
|
|
154
160
|
configurable: true,
|
|
@@ -158,6 +164,7 @@ class SmithCommand {
|
|
|
158
164
|
this.dockerComposeCommand = dockerComposeCommand;
|
|
159
165
|
this.dockerComposeFile = path.join(path.dirname(currentFileName), "docker-compose.yaml");
|
|
160
166
|
this.dockerComposeDevFile = path.join(path.dirname(currentFileName), "docker-compose.dev.yaml");
|
|
167
|
+
this.dockerComposeBetaFile = path.join(path.dirname(currentFileName), "docker-compose.beta.yaml");
|
|
161
168
|
this.ngrokPath = path.join(path.dirname(currentFileName), "docker-compose.ngrok.yaml");
|
|
162
169
|
}
|
|
163
170
|
async executeCommand(command) {
|
|
@@ -178,28 +185,16 @@ class SmithCommand {
|
|
|
178
185
|
});
|
|
179
186
|
}
|
|
180
187
|
static async create() {
|
|
188
|
+
console.info("BY USING THIS SOFTWARE YOU AGREE TO THE TERMS OF SERVICE AT:");
|
|
189
|
+
console.info("https://smith.langchain.com/terms-of-service.pdf");
|
|
181
190
|
const dockerComposeCommand = await getDockerComposeCommand();
|
|
182
191
|
return new SmithCommand({ dockerComposeCommand });
|
|
183
192
|
}
|
|
184
|
-
async
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
if (args.dev) {
|
|
188
|
-
(0, env_js_1.setEnvironmentVariable)("_LANGSMITH_IMAGE_PREFIX", "rc-");
|
|
189
|
-
}
|
|
190
|
-
if (args.openaiApiKey) {
|
|
191
|
-
(0, env_js_1.setEnvironmentVariable)("OPENAI_API_KEY", args.openaiApiKey);
|
|
192
|
-
}
|
|
193
|
-
await this.pull(args);
|
|
194
|
-
if (args.expose) {
|
|
195
|
-
await this.startAndExpose(args.ngrokAuthtoken, args.dev);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
await this.startLocal(args.dev);
|
|
193
|
+
async pull({ stage = "prod" }) {
|
|
194
|
+
if (stage === "dev") {
|
|
195
|
+
(0, env_js_1.setEnvironmentVariable)("_LANGSMITH_IMAGE_PREFIX", "dev-");
|
|
199
196
|
}
|
|
200
|
-
|
|
201
|
-
async pull(args) {
|
|
202
|
-
if (args.dev) {
|
|
197
|
+
else if (stage === "beta") {
|
|
203
198
|
(0, env_js_1.setEnvironmentVariable)("_LANGSMITH_IMAGE_PREFIX", "rc-");
|
|
204
199
|
}
|
|
205
200
|
const command = [
|
|
@@ -210,15 +205,18 @@ class SmithCommand {
|
|
|
210
205
|
];
|
|
211
206
|
await this.executeCommand(command);
|
|
212
207
|
}
|
|
213
|
-
async startLocal(
|
|
208
|
+
async startLocal(stage = "prod") {
|
|
214
209
|
const command = [
|
|
215
210
|
...this.dockerComposeCommand,
|
|
216
211
|
"-f",
|
|
217
212
|
this.dockerComposeFile,
|
|
218
213
|
];
|
|
219
|
-
if (dev) {
|
|
214
|
+
if (stage === "dev") {
|
|
220
215
|
command.push("-f", this.dockerComposeDevFile);
|
|
221
216
|
}
|
|
217
|
+
else if (stage === "beta") {
|
|
218
|
+
command.push("-f", this.dockerComposeBetaFile);
|
|
219
|
+
}
|
|
222
220
|
command.push("up", "--quiet-pull", "--wait");
|
|
223
221
|
await this.executeCommand(command);
|
|
224
222
|
console.info("LangSmith server is running at http://localhost:1984.\n" +
|
|
@@ -228,7 +226,7 @@ class SmithCommand {
|
|
|
228
226
|
" when running your LangChain application.");
|
|
229
227
|
console.info("\tLANGCHAIN_TRACING_V2=true");
|
|
230
228
|
}
|
|
231
|
-
async startAndExpose(ngrokAuthToken,
|
|
229
|
+
async startAndExpose(ngrokAuthToken, stage = "prod") {
|
|
232
230
|
const configPath = await createNgrokConfig(ngrokAuthToken);
|
|
233
231
|
const command = [
|
|
234
232
|
...this.dockerComposeCommand,
|
|
@@ -237,9 +235,12 @@ class SmithCommand {
|
|
|
237
235
|
"-f",
|
|
238
236
|
this.ngrokPath,
|
|
239
237
|
];
|
|
240
|
-
if (dev) {
|
|
238
|
+
if (stage === "dev") {
|
|
241
239
|
command.push("-f", this.dockerComposeDevFile);
|
|
242
240
|
}
|
|
241
|
+
else if (stage === "beta") {
|
|
242
|
+
command.push("-f", this.dockerComposeBetaFile);
|
|
243
|
+
}
|
|
243
244
|
command.push("up", "--quiet-pull", "--wait");
|
|
244
245
|
await this.executeCommand(command);
|
|
245
246
|
console.info("ngrok is running. You can view the dashboard at http://0.0.0.0:4040");
|
|
@@ -289,24 +290,54 @@ const startCommand = new commander_1.Command("start")
|
|
|
289
290
|
.description("Start the LangSmith server")
|
|
290
291
|
.option("--expose", "Expose the server to the internet via ngrok (requires ngrok to be installed)")
|
|
291
292
|
.option("--ngrok-authtoken <ngrokAuthtoken>", "Your ngrok auth token. If this is set, --expose is implied.")
|
|
292
|
-
.option("--
|
|
293
|
+
.option("--stage <stage>", "Which version of LangSmith to run. Options: prod, dev, beta (default: prod)")
|
|
293
294
|
.option("--openai-api-key <openaiApiKey>", "Your OpenAI API key. If not provided, the OpenAI API Key will be read" +
|
|
294
295
|
" from the OPENAI_API_KEY environment variable. If neither are provided," +
|
|
295
296
|
" some features of LangSmith will not be available.")
|
|
296
|
-
.action(async (args) =>
|
|
297
|
+
.action(async (args) => {
|
|
298
|
+
const smith = await SmithCommand.create();
|
|
299
|
+
if (args.stage === "dev") {
|
|
300
|
+
(0, env_js_1.setEnvironmentVariable)("_LANGSMITH_IMAGE_PREFIX", "dev-");
|
|
301
|
+
}
|
|
302
|
+
else if (args.stage === "beta") {
|
|
303
|
+
(0, env_js_1.setEnvironmentVariable)("_LANGSMITH_IMAGE_PREFIX", "rc-");
|
|
304
|
+
}
|
|
305
|
+
if (args.openaiApiKey) {
|
|
306
|
+
(0, env_js_1.setEnvironmentVariable)("OPENAI_API_KEY", args.openaiApiKey);
|
|
307
|
+
}
|
|
308
|
+
await smith.pull({ stage: args.stage });
|
|
309
|
+
if (args.expose) {
|
|
310
|
+
await smith.startAndExpose(args.ngrokAuthtoken, args.stage);
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
await smith.startLocal(args.stage);
|
|
314
|
+
}
|
|
315
|
+
});
|
|
297
316
|
const stopCommand = new commander_1.Command("stop")
|
|
298
|
-
.command("stop")
|
|
299
317
|
.description("Stop the LangSmith server")
|
|
300
|
-
.action(async () =>
|
|
318
|
+
.action(async () => {
|
|
319
|
+
const smith = await SmithCommand.create();
|
|
320
|
+
await smith.stop();
|
|
321
|
+
});
|
|
301
322
|
const pullCommand = new commander_1.Command("pull")
|
|
302
|
-
.command("pull")
|
|
303
323
|
.description("Pull the latest version of the LangSmith server")
|
|
304
|
-
.option("--
|
|
305
|
-
.action(async (args) =>
|
|
324
|
+
.option("--stage <stage>", "Which version of LangSmith to pull. Options: prod, dev, beta (default: prod)")
|
|
325
|
+
.action(async (args) => {
|
|
326
|
+
const smith = await SmithCommand.create();
|
|
327
|
+
if (args.stage === "dev") {
|
|
328
|
+
(0, env_js_1.setEnvironmentVariable)("_LANGSMITH_IMAGE_PREFIX", "dev-");
|
|
329
|
+
}
|
|
330
|
+
else if (args.stage === "beta") {
|
|
331
|
+
(0, env_js_1.setEnvironmentVariable)("_LANGSMITH_IMAGE_PREFIX", "rc-");
|
|
332
|
+
}
|
|
333
|
+
await smith.pull({ stage: args.stage });
|
|
334
|
+
});
|
|
306
335
|
const statusCommand = new commander_1.Command("status")
|
|
307
|
-
.command("status")
|
|
308
336
|
.description("Get the status of the LangSmith server")
|
|
309
|
-
.action(async () =>
|
|
337
|
+
.action(async () => {
|
|
338
|
+
const smith = await SmithCommand.create();
|
|
339
|
+
await smith.status();
|
|
340
|
+
});
|
|
310
341
|
program
|
|
311
342
|
.description("Manage the LangSmith server")
|
|
312
343
|
.addCommand(startCommand)
|
package/dist/cli/main.js
CHANGED
|
@@ -123,6 +123,12 @@ class SmithCommand {
|
|
|
123
123
|
writable: true,
|
|
124
124
|
value: ""
|
|
125
125
|
});
|
|
126
|
+
Object.defineProperty(this, "dockerComposeBetaFile", {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
configurable: true,
|
|
129
|
+
writable: true,
|
|
130
|
+
value: ""
|
|
131
|
+
});
|
|
126
132
|
Object.defineProperty(this, "ngrokPath", {
|
|
127
133
|
enumerable: true,
|
|
128
134
|
configurable: true,
|
|
@@ -132,6 +138,7 @@ class SmithCommand {
|
|
|
132
138
|
this.dockerComposeCommand = dockerComposeCommand;
|
|
133
139
|
this.dockerComposeFile = path.join(path.dirname(currentFileName), "docker-compose.yaml");
|
|
134
140
|
this.dockerComposeDevFile = path.join(path.dirname(currentFileName), "docker-compose.dev.yaml");
|
|
141
|
+
this.dockerComposeBetaFile = path.join(path.dirname(currentFileName), "docker-compose.beta.yaml");
|
|
135
142
|
this.ngrokPath = path.join(path.dirname(currentFileName), "docker-compose.ngrok.yaml");
|
|
136
143
|
}
|
|
137
144
|
async executeCommand(command) {
|
|
@@ -152,28 +159,16 @@ class SmithCommand {
|
|
|
152
159
|
});
|
|
153
160
|
}
|
|
154
161
|
static async create() {
|
|
162
|
+
console.info("BY USING THIS SOFTWARE YOU AGREE TO THE TERMS OF SERVICE AT:");
|
|
163
|
+
console.info("https://smith.langchain.com/terms-of-service.pdf");
|
|
155
164
|
const dockerComposeCommand = await getDockerComposeCommand();
|
|
156
165
|
return new SmithCommand({ dockerComposeCommand });
|
|
157
166
|
}
|
|
158
|
-
async
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (args.dev) {
|
|
162
|
-
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "rc-");
|
|
163
|
-
}
|
|
164
|
-
if (args.openaiApiKey) {
|
|
165
|
-
setEnvironmentVariable("OPENAI_API_KEY", args.openaiApiKey);
|
|
166
|
-
}
|
|
167
|
-
await this.pull(args);
|
|
168
|
-
if (args.expose) {
|
|
169
|
-
await this.startAndExpose(args.ngrokAuthtoken, args.dev);
|
|
167
|
+
async pull({ stage = "prod" }) {
|
|
168
|
+
if (stage === "dev") {
|
|
169
|
+
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "dev-");
|
|
170
170
|
}
|
|
171
|
-
else {
|
|
172
|
-
await this.startLocal(args.dev);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
async pull(args) {
|
|
176
|
-
if (args.dev) {
|
|
171
|
+
else if (stage === "beta") {
|
|
177
172
|
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "rc-");
|
|
178
173
|
}
|
|
179
174
|
const command = [
|
|
@@ -184,15 +179,18 @@ class SmithCommand {
|
|
|
184
179
|
];
|
|
185
180
|
await this.executeCommand(command);
|
|
186
181
|
}
|
|
187
|
-
async startLocal(
|
|
182
|
+
async startLocal(stage = "prod") {
|
|
188
183
|
const command = [
|
|
189
184
|
...this.dockerComposeCommand,
|
|
190
185
|
"-f",
|
|
191
186
|
this.dockerComposeFile,
|
|
192
187
|
];
|
|
193
|
-
if (dev) {
|
|
188
|
+
if (stage === "dev") {
|
|
194
189
|
command.push("-f", this.dockerComposeDevFile);
|
|
195
190
|
}
|
|
191
|
+
else if (stage === "beta") {
|
|
192
|
+
command.push("-f", this.dockerComposeBetaFile);
|
|
193
|
+
}
|
|
196
194
|
command.push("up", "--quiet-pull", "--wait");
|
|
197
195
|
await this.executeCommand(command);
|
|
198
196
|
console.info("LangSmith server is running at http://localhost:1984.\n" +
|
|
@@ -202,7 +200,7 @@ class SmithCommand {
|
|
|
202
200
|
" when running your LangChain application.");
|
|
203
201
|
console.info("\tLANGCHAIN_TRACING_V2=true");
|
|
204
202
|
}
|
|
205
|
-
async startAndExpose(ngrokAuthToken,
|
|
203
|
+
async startAndExpose(ngrokAuthToken, stage = "prod") {
|
|
206
204
|
const configPath = await createNgrokConfig(ngrokAuthToken);
|
|
207
205
|
const command = [
|
|
208
206
|
...this.dockerComposeCommand,
|
|
@@ -211,9 +209,12 @@ class SmithCommand {
|
|
|
211
209
|
"-f",
|
|
212
210
|
this.ngrokPath,
|
|
213
211
|
];
|
|
214
|
-
if (dev) {
|
|
212
|
+
if (stage === "dev") {
|
|
215
213
|
command.push("-f", this.dockerComposeDevFile);
|
|
216
214
|
}
|
|
215
|
+
else if (stage === "beta") {
|
|
216
|
+
command.push("-f", this.dockerComposeBetaFile);
|
|
217
|
+
}
|
|
217
218
|
command.push("up", "--quiet-pull", "--wait");
|
|
218
219
|
await this.executeCommand(command);
|
|
219
220
|
console.info("ngrok is running. You can view the dashboard at http://0.0.0.0:4040");
|
|
@@ -263,24 +264,54 @@ const startCommand = new Command("start")
|
|
|
263
264
|
.description("Start the LangSmith server")
|
|
264
265
|
.option("--expose", "Expose the server to the internet via ngrok (requires ngrok to be installed)")
|
|
265
266
|
.option("--ngrok-authtoken <ngrokAuthtoken>", "Your ngrok auth token. If this is set, --expose is implied.")
|
|
266
|
-
.option("--
|
|
267
|
+
.option("--stage <stage>", "Which version of LangSmith to run. Options: prod, dev, beta (default: prod)")
|
|
267
268
|
.option("--openai-api-key <openaiApiKey>", "Your OpenAI API key. If not provided, the OpenAI API Key will be read" +
|
|
268
269
|
" from the OPENAI_API_KEY environment variable. If neither are provided," +
|
|
269
270
|
" some features of LangSmith will not be available.")
|
|
270
|
-
.action(async (args) =>
|
|
271
|
+
.action(async (args) => {
|
|
272
|
+
const smith = await SmithCommand.create();
|
|
273
|
+
if (args.stage === "dev") {
|
|
274
|
+
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "dev-");
|
|
275
|
+
}
|
|
276
|
+
else if (args.stage === "beta") {
|
|
277
|
+
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "rc-");
|
|
278
|
+
}
|
|
279
|
+
if (args.openaiApiKey) {
|
|
280
|
+
setEnvironmentVariable("OPENAI_API_KEY", args.openaiApiKey);
|
|
281
|
+
}
|
|
282
|
+
await smith.pull({ stage: args.stage });
|
|
283
|
+
if (args.expose) {
|
|
284
|
+
await smith.startAndExpose(args.ngrokAuthtoken, args.stage);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
await smith.startLocal(args.stage);
|
|
288
|
+
}
|
|
289
|
+
});
|
|
271
290
|
const stopCommand = new Command("stop")
|
|
272
|
-
.command("stop")
|
|
273
291
|
.description("Stop the LangSmith server")
|
|
274
|
-
.action(async () =>
|
|
292
|
+
.action(async () => {
|
|
293
|
+
const smith = await SmithCommand.create();
|
|
294
|
+
await smith.stop();
|
|
295
|
+
});
|
|
275
296
|
const pullCommand = new Command("pull")
|
|
276
|
-
.command("pull")
|
|
277
297
|
.description("Pull the latest version of the LangSmith server")
|
|
278
|
-
.option("--
|
|
279
|
-
.action(async (args) =>
|
|
298
|
+
.option("--stage <stage>", "Which version of LangSmith to pull. Options: prod, dev, beta (default: prod)")
|
|
299
|
+
.action(async (args) => {
|
|
300
|
+
const smith = await SmithCommand.create();
|
|
301
|
+
if (args.stage === "dev") {
|
|
302
|
+
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "dev-");
|
|
303
|
+
}
|
|
304
|
+
else if (args.stage === "beta") {
|
|
305
|
+
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "rc-");
|
|
306
|
+
}
|
|
307
|
+
await smith.pull({ stage: args.stage });
|
|
308
|
+
});
|
|
280
309
|
const statusCommand = new Command("status")
|
|
281
|
-
.command("status")
|
|
282
310
|
.description("Get the status of the LangSmith server")
|
|
283
|
-
.action(async () =>
|
|
311
|
+
.action(async () => {
|
|
312
|
+
const smith = await SmithCommand.create();
|
|
313
|
+
await smith.status();
|
|
314
|
+
});
|
|
284
315
|
program
|
|
285
316
|
.description("Manage the LangSmith server")
|
|
286
317
|
.addCommand(startCommand)
|
package/dist/cli/main.ts
CHANGED
|
@@ -126,6 +126,7 @@ class SmithCommand {
|
|
|
126
126
|
dockerComposeCommand: string[] = [];
|
|
127
127
|
dockerComposeFile = "";
|
|
128
128
|
dockerComposeDevFile = "";
|
|
129
|
+
dockerComposeBetaFile = "";
|
|
129
130
|
ngrokPath = "";
|
|
130
131
|
|
|
131
132
|
constructor({ dockerComposeCommand }: { dockerComposeCommand: string[] }) {
|
|
@@ -138,6 +139,10 @@ class SmithCommand {
|
|
|
138
139
|
path.dirname(currentFileName),
|
|
139
140
|
"docker-compose.dev.yaml"
|
|
140
141
|
);
|
|
142
|
+
this.dockerComposeBetaFile = path.join(
|
|
143
|
+
path.dirname(currentFileName),
|
|
144
|
+
"docker-compose.beta.yaml"
|
|
145
|
+
);
|
|
141
146
|
this.ngrokPath = path.join(
|
|
142
147
|
path.dirname(currentFileName),
|
|
143
148
|
"docker-compose.ngrok.yaml"
|
|
@@ -164,31 +169,18 @@ class SmithCommand {
|
|
|
164
169
|
}
|
|
165
170
|
|
|
166
171
|
public static async create() {
|
|
167
|
-
const dockerComposeCommand = await getDockerComposeCommand();
|
|
168
|
-
return new SmithCommand({ dockerComposeCommand });
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async start(args: any) {
|
|
172
172
|
console.info(
|
|
173
173
|
"BY USING THIS SOFTWARE YOU AGREE TO THE TERMS OF SERVICE AT:"
|
|
174
174
|
);
|
|
175
175
|
console.info("https://smith.langchain.com/terms-of-service.pdf");
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
179
|
-
if (args.openaiApiKey) {
|
|
180
|
-
setEnvironmentVariable("OPENAI_API_KEY", args.openaiApiKey);
|
|
181
|
-
}
|
|
182
|
-
await this.pull(args);
|
|
183
|
-
if (args.expose) {
|
|
184
|
-
await this.startAndExpose(args.ngrokAuthtoken, args.dev);
|
|
185
|
-
} else {
|
|
186
|
-
await this.startLocal(args.dev);
|
|
187
|
-
}
|
|
176
|
+
const dockerComposeCommand = await getDockerComposeCommand();
|
|
177
|
+
return new SmithCommand({ dockerComposeCommand });
|
|
188
178
|
}
|
|
189
179
|
|
|
190
|
-
async pull(
|
|
191
|
-
if (
|
|
180
|
+
async pull({ stage = "prod" }) {
|
|
181
|
+
if (stage === "dev") {
|
|
182
|
+
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "dev-");
|
|
183
|
+
} else if (stage === "beta") {
|
|
192
184
|
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "rc-");
|
|
193
185
|
}
|
|
194
186
|
|
|
@@ -201,17 +193,22 @@ class SmithCommand {
|
|
|
201
193
|
await this.executeCommand(command);
|
|
202
194
|
}
|
|
203
195
|
|
|
204
|
-
async startLocal(
|
|
196
|
+
async startLocal(stage = "prod") {
|
|
205
197
|
const command = [
|
|
206
198
|
...this.dockerComposeCommand,
|
|
207
199
|
"-f",
|
|
208
200
|
this.dockerComposeFile,
|
|
209
201
|
];
|
|
210
|
-
|
|
202
|
+
|
|
203
|
+
if (stage === "dev") {
|
|
211
204
|
command.push("-f", this.dockerComposeDevFile);
|
|
205
|
+
} else if (stage === "beta") {
|
|
206
|
+
command.push("-f", this.dockerComposeBetaFile);
|
|
212
207
|
}
|
|
208
|
+
|
|
213
209
|
command.push("up", "--quiet-pull", "--wait");
|
|
214
210
|
await this.executeCommand(command);
|
|
211
|
+
|
|
215
212
|
console.info(
|
|
216
213
|
"LangSmith server is running at http://localhost:1984.\n" +
|
|
217
214
|
"To view the app, navigate your browser to http://localhost:80" +
|
|
@@ -219,10 +216,11 @@ class SmithCommand {
|
|
|
219
216
|
" locally, set the following environment variable" +
|
|
220
217
|
" when running your LangChain application."
|
|
221
218
|
);
|
|
219
|
+
|
|
222
220
|
console.info("\tLANGCHAIN_TRACING_V2=true");
|
|
223
221
|
}
|
|
224
222
|
|
|
225
|
-
async startAndExpose(ngrokAuthToken: string | null,
|
|
223
|
+
async startAndExpose(ngrokAuthToken: string | null, stage = "prod") {
|
|
226
224
|
const configPath = await createNgrokConfig(ngrokAuthToken);
|
|
227
225
|
const command = [
|
|
228
226
|
...this.dockerComposeCommand,
|
|
@@ -231,11 +229,16 @@ class SmithCommand {
|
|
|
231
229
|
"-f",
|
|
232
230
|
this.ngrokPath,
|
|
233
231
|
];
|
|
234
|
-
|
|
232
|
+
|
|
233
|
+
if (stage === "dev") {
|
|
235
234
|
command.push("-f", this.dockerComposeDevFile);
|
|
235
|
+
} else if (stage === "beta") {
|
|
236
|
+
command.push("-f", this.dockerComposeBetaFile);
|
|
236
237
|
}
|
|
238
|
+
|
|
237
239
|
command.push("up", "--quiet-pull", "--wait");
|
|
238
240
|
await this.executeCommand(command);
|
|
241
|
+
|
|
239
242
|
console.info(
|
|
240
243
|
"ngrok is running. You can view the dashboard at http://0.0.0.0:4040"
|
|
241
244
|
);
|
|
@@ -264,6 +267,7 @@ class SmithCommand {
|
|
|
264
267
|
];
|
|
265
268
|
await this.executeCommand(command);
|
|
266
269
|
}
|
|
270
|
+
|
|
267
271
|
async status() {
|
|
268
272
|
const command = [
|
|
269
273
|
...this.dockerComposeCommand,
|
|
@@ -295,30 +299,63 @@ const startCommand = new Command("start")
|
|
|
295
299
|
"--ngrok-authtoken <ngrokAuthtoken>",
|
|
296
300
|
"Your ngrok auth token. If this is set, --expose is implied."
|
|
297
301
|
)
|
|
298
|
-
.option(
|
|
302
|
+
.option(
|
|
303
|
+
"--stage <stage>",
|
|
304
|
+
"Which version of LangSmith to run. Options: prod, dev, beta (default: prod)"
|
|
305
|
+
)
|
|
299
306
|
.option(
|
|
300
307
|
"--openai-api-key <openaiApiKey>",
|
|
301
308
|
"Your OpenAI API key. If not provided, the OpenAI API Key will be read" +
|
|
302
309
|
" from the OPENAI_API_KEY environment variable. If neither are provided," +
|
|
303
310
|
" some features of LangSmith will not be available."
|
|
304
311
|
)
|
|
305
|
-
.action(async (args
|
|
312
|
+
.action(async (args) => {
|
|
313
|
+
const smith = await SmithCommand.create();
|
|
314
|
+
if (args.stage === "dev") {
|
|
315
|
+
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "dev-");
|
|
316
|
+
} else if (args.stage === "beta") {
|
|
317
|
+
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "rc-");
|
|
318
|
+
}
|
|
319
|
+
if (args.openaiApiKey) {
|
|
320
|
+
setEnvironmentVariable("OPENAI_API_KEY", args.openaiApiKey);
|
|
321
|
+
}
|
|
322
|
+
await smith.pull({ stage: args.stage });
|
|
323
|
+
if (args.expose) {
|
|
324
|
+
await smith.startAndExpose(args.ngrokAuthtoken, args.stage);
|
|
325
|
+
} else {
|
|
326
|
+
await smith.startLocal(args.stage);
|
|
327
|
+
}
|
|
328
|
+
});
|
|
306
329
|
|
|
307
330
|
const stopCommand = new Command("stop")
|
|
308
|
-
.command("stop")
|
|
309
331
|
.description("Stop the LangSmith server")
|
|
310
|
-
.action(async () =>
|
|
332
|
+
.action(async () => {
|
|
333
|
+
const smith = await SmithCommand.create();
|
|
334
|
+
await smith.stop();
|
|
335
|
+
});
|
|
311
336
|
|
|
312
337
|
const pullCommand = new Command("pull")
|
|
313
|
-
.command("pull")
|
|
314
338
|
.description("Pull the latest version of the LangSmith server")
|
|
315
|
-
.option(
|
|
316
|
-
|
|
339
|
+
.option(
|
|
340
|
+
"--stage <stage>",
|
|
341
|
+
"Which version of LangSmith to pull. Options: prod, dev, beta (default: prod)"
|
|
342
|
+
)
|
|
343
|
+
.action(async (args) => {
|
|
344
|
+
const smith = await SmithCommand.create();
|
|
345
|
+
if (args.stage === "dev") {
|
|
346
|
+
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "dev-");
|
|
347
|
+
} else if (args.stage === "beta") {
|
|
348
|
+
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "rc-");
|
|
349
|
+
}
|
|
350
|
+
await smith.pull({ stage: args.stage });
|
|
351
|
+
});
|
|
317
352
|
|
|
318
353
|
const statusCommand = new Command("status")
|
|
319
|
-
.command("status")
|
|
320
354
|
.description("Get the status of the LangSmith server")
|
|
321
|
-
.action(async () =>
|
|
355
|
+
.action(async () => {
|
|
356
|
+
const smith = await SmithCommand.create();
|
|
357
|
+
await smith.status();
|
|
358
|
+
});
|
|
322
359
|
|
|
323
360
|
program
|
|
324
361
|
.description("Manage the LangSmith server")
|
package/dist/client.cjs
CHANGED
|
@@ -588,7 +588,7 @@ class Client {
|
|
|
588
588
|
const path = `/examples/${exampleId}`;
|
|
589
589
|
return await this._get(path);
|
|
590
590
|
}
|
|
591
|
-
async *listExamples({ datasetId, datasetName, } = {}) {
|
|
591
|
+
async *listExamples({ datasetId, datasetName, exampleIds, } = {}) {
|
|
592
592
|
let datasetId_;
|
|
593
593
|
if (datasetId !== undefined && datasetName !== undefined) {
|
|
594
594
|
throw new Error("Must provide either datasetName or datasetId, not both");
|
|
@@ -604,6 +604,11 @@ class Client {
|
|
|
604
604
|
throw new Error("Must provide a datasetName or datasetId");
|
|
605
605
|
}
|
|
606
606
|
const params = new URLSearchParams({ dataset: datasetId_ });
|
|
607
|
+
if (exampleIds !== undefined) {
|
|
608
|
+
for (const id_ of exampleIds) {
|
|
609
|
+
params.append("id", id_);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
607
612
|
for await (const examples of this._getPaginated("/examples", params)) {
|
|
608
613
|
yield* examples;
|
|
609
614
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -122,9 +122,10 @@ export declare class Client {
|
|
|
122
122
|
createdAt?: Date;
|
|
123
123
|
}): Promise<Example>;
|
|
124
124
|
readExample(exampleId: string): Promise<Example>;
|
|
125
|
-
listExamples({ datasetId, datasetName, }?: {
|
|
125
|
+
listExamples({ datasetId, datasetName, exampleIds, }?: {
|
|
126
126
|
datasetId?: string;
|
|
127
127
|
datasetName?: string;
|
|
128
|
+
exampleIds?: string[];
|
|
128
129
|
}): AsyncIterable<Example>;
|
|
129
130
|
deleteExample(exampleId: string): Promise<void>;
|
|
130
131
|
updateExample(exampleId: string, update: ExampleUpdate): Promise<object>;
|
package/dist/client.js
CHANGED
|
@@ -562,7 +562,7 @@ export class Client {
|
|
|
562
562
|
const path = `/examples/${exampleId}`;
|
|
563
563
|
return await this._get(path);
|
|
564
564
|
}
|
|
565
|
-
async *listExamples({ datasetId, datasetName, } = {}) {
|
|
565
|
+
async *listExamples({ datasetId, datasetName, exampleIds, } = {}) {
|
|
566
566
|
let datasetId_;
|
|
567
567
|
if (datasetId !== undefined && datasetName !== undefined) {
|
|
568
568
|
throw new Error("Must provide either datasetName or datasetId, not both");
|
|
@@ -578,6 +578,11 @@ export class Client {
|
|
|
578
578
|
throw new Error("Must provide a datasetName or datasetId");
|
|
579
579
|
}
|
|
580
580
|
const params = new URLSearchParams({ dataset: datasetId_ });
|
|
581
|
+
if (exampleIds !== undefined) {
|
|
582
|
+
for (const id_ of exampleIds) {
|
|
583
|
+
params.append("id", id_);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
581
586
|
for await (const examples of this._getPaginated("/examples", params)) {
|
|
582
587
|
yield* examples;
|
|
583
588
|
}
|
package/dist/run_trees.cjs
CHANGED
|
@@ -27,6 +27,13 @@ exports.RunTree = void 0;
|
|
|
27
27
|
const uuid = __importStar(require("uuid"));
|
|
28
28
|
const env_js_1 = require("./utils/env.cjs");
|
|
29
29
|
const client_js_1 = require("./client.cjs");
|
|
30
|
+
const warnedMessages = {};
|
|
31
|
+
function warnOnce(message) {
|
|
32
|
+
if (!warnedMessages[message]) {
|
|
33
|
+
console.warn(message);
|
|
34
|
+
warnedMessages[message] = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
30
37
|
class RunTree {
|
|
31
38
|
constructor(config) {
|
|
32
39
|
Object.defineProperty(this, "id", {
|
|
@@ -220,8 +227,14 @@ class RunTree {
|
|
|
220
227
|
return persistedRun;
|
|
221
228
|
}
|
|
222
229
|
async postRun(excludeChildRuns = true) {
|
|
223
|
-
const runCreate = await this._convertToCreate(this,
|
|
230
|
+
const runCreate = await this._convertToCreate(this, true);
|
|
224
231
|
await this.client.createRun(runCreate);
|
|
232
|
+
if (!excludeChildRuns) {
|
|
233
|
+
warnOnce("Posting with excludeChildRuns=false is deprecated and will be removed in a future version.");
|
|
234
|
+
for (const childRun of this.child_runs) {
|
|
235
|
+
await childRun.postRun(false);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
225
238
|
}
|
|
226
239
|
async patchRun() {
|
|
227
240
|
const runUpdate = {
|
package/dist/run_trees.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import * as uuid from "uuid";
|
|
2
2
|
import { getEnvironmentVariable, getRuntimeEnvironment } from "./utils/env.js";
|
|
3
3
|
import { Client } from "./client.js";
|
|
4
|
+
const warnedMessages = {};
|
|
5
|
+
function warnOnce(message) {
|
|
6
|
+
if (!warnedMessages[message]) {
|
|
7
|
+
console.warn(message);
|
|
8
|
+
warnedMessages[message] = true;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
4
11
|
export class RunTree {
|
|
5
12
|
constructor(config) {
|
|
6
13
|
Object.defineProperty(this, "id", {
|
|
@@ -194,8 +201,14 @@ export class RunTree {
|
|
|
194
201
|
return persistedRun;
|
|
195
202
|
}
|
|
196
203
|
async postRun(excludeChildRuns = true) {
|
|
197
|
-
const runCreate = await this._convertToCreate(this,
|
|
204
|
+
const runCreate = await this._convertToCreate(this, true);
|
|
198
205
|
await this.client.createRun(runCreate);
|
|
206
|
+
if (!excludeChildRuns) {
|
|
207
|
+
warnOnce("Posting with excludeChildRuns=false is deprecated and will be removed in a future version.");
|
|
208
|
+
for (const childRun of this.child_runs) {
|
|
209
|
+
await childRun.postRun(false);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
199
212
|
}
|
|
200
213
|
async patchRun() {
|
|
201
214
|
const runUpdate = {
|