langsmith 0.0.1-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +262 -0
  2. package/client.cjs +1 -0
  3. package/client.d.ts +1 -0
  4. package/client.js +1 -0
  5. package/dist/cli/docker-compose.ngrok.yaml +17 -0
  6. package/dist/cli/docker-compose.yaml +43 -0
  7. package/dist/cli/main.cjs +278 -0
  8. package/dist/cli/main.d.ts +1 -0
  9. package/dist/cli/main.js +252 -0
  10. package/dist/cli/main.ts +292 -0
  11. package/dist/client.cjs +588 -0
  12. package/dist/client.d.ts +130 -0
  13. package/dist/client.js +561 -0
  14. package/dist/evaluation/evaluator.cjs +2 -0
  15. package/dist/evaluation/evaluator.d.ts +12 -0
  16. package/dist/evaluation/evaluator.js +1 -0
  17. package/dist/evaluation/index.cjs +5 -0
  18. package/dist/evaluation/index.d.ts +2 -0
  19. package/dist/evaluation/index.js +1 -0
  20. package/dist/evaluation/string_evaluator.cjs +66 -0
  21. package/dist/evaluation/string_evaluator.d.ts +30 -0
  22. package/dist/evaluation/string_evaluator.js +62 -0
  23. package/dist/index.cjs +7 -0
  24. package/dist/index.d.ts +3 -0
  25. package/dist/index.js +2 -0
  26. package/dist/run_trees.cjs +232 -0
  27. package/dist/run_trees.d.ts +47 -0
  28. package/dist/run_trees.js +205 -0
  29. package/dist/schemas.cjs +2 -0
  30. package/dist/schemas.d.ts +117 -0
  31. package/dist/schemas.js +1 -0
  32. package/dist/utils/async_caller.cjs +111 -0
  33. package/dist/utils/async_caller.d.ts +37 -0
  34. package/dist/utils/async_caller.js +104 -0
  35. package/dist/utils/env.cjs +80 -0
  36. package/dist/utils/env.d.ts +22 -0
  37. package/dist/utils/env.js +68 -0
  38. package/evaluation.cjs +1 -0
  39. package/evaluation.d.ts +1 -0
  40. package/evaluation.js +1 -0
  41. package/index.cjs +1 -0
  42. package/index.d.ts +1 -0
  43. package/index.js +1 -0
  44. package/package.json +121 -0
  45. package/run_trees.cjs +1 -0
  46. package/run_trees.d.ts +1 -0
  47. package/run_trees.js +1 -0
  48. package/schemas.cjs +1 -0
  49. package/schemas.d.ts +1 -0
  50. package/schemas.js +1 -0
package/README.md ADDED
@@ -0,0 +1,262 @@
1
+ # LangSmith Client SDK
2
+
3
+ This package contains the TypeScript client for interacting with the [LangSmith platform](https://www.langchain.plus/).
4
+
5
+ To install:
6
+
7
+ ```bash
8
+ yarn add langsmith
9
+ ```
10
+
11
+ LangSmith helps you and your team develop and evaluate language models and intelligent agents. It is compatible with any LLM Application and provides seamless integration with [LangChain](https://github.com/hwchase17/langchainjs), a widely recognized open-source framework that simplifies the process for developers to create powerful language model applications.
12
+
13
+ > **Note**: You can enjoy the benefits of LangSmith without using the LangChain open-source packages! To get started with your own proprietary framework, set up your account and then skip to [Logging Traces Outside LangChain](#logging-traces-outside-langchain).
14
+
15
+ A typical workflow looks like:
16
+
17
+ 1. Set up an account with LangSmith or host your [local server](https://docs.langchain.plus/docs/getting-started/local_installation).
18
+ 2. Log traces.
19
+ 3. Debug, Create Datasets, and Evaluate Runs.
20
+
21
+ We'll walk through these steps in more detail below.
22
+
23
+ ## 1. Connect to LangSmith
24
+
25
+ Sign up for [LangSmith](https://www.langchain.plus/) using your GitHub, Discord accounts, or an email address and password. If you sign up with an email, make sure to verify your email address before logging in.
26
+
27
+ Then, create a unique API key on the [Settings Page](https://www.langchain.plus/settings), which is found in the menu at the top right corner of the page.
28
+
29
+ Note: Save the API Key in a secure location. It will not be shown again.
30
+
31
+ ## 2. Log Traces
32
+
33
+ You can log traces natively in your LangChain application or using a LangSmith RunTree.
34
+
35
+ ### Logging Traces with LangChain
36
+
37
+ LangSmith seamlessly integrates with the JavaScript LangChain library to record traces from your LLM applications.
38
+
39
+ ```bash
40
+ yarn add langchain
41
+ ```
42
+
43
+ 1. **Copy the environment variables from the Settings Page and add them to your application.**
44
+
45
+ Tracing can be activated by setting the following environment variables or by manually specifying the LangChainTracer.
46
+
47
+ ```typescript
48
+ process.env["LANGCHAIN_TRACING_V2"] = "true";
49
+ process.env["LANGCHAIN_ENDPOINT"] = "https://api.langchain.plus"; // or your own server
50
+ process.env["LANGCHAIN_API_KEY"] = "<YOUR-LANGCHAINPLUS-API-KEY>";
51
+ // process.env["LANGCHAIN_PROJECT"] = "My Project Name"; // Optional: "default" is used if not set
52
+ ```
53
+
54
+ > **Tip:** Projects are groups of traces. All runs are logged to a project. If not specified, the project is set to `default`.
55
+
56
+ 2. **Run an Agent, Chain, or Language Model in LangChain**
57
+
58
+ If the environment variables are correctly set, your application will automatically connect to the LangSmith platform.
59
+
60
+ ```typescript
61
+ import { ChatOpenAI } from "langchain/chat_models/openai";
62
+
63
+ const chat = new ChatOpenAI({ temperature: 0 });
64
+ const response = await chat.predict(
65
+ "Translate this sentence from English to French. I love programming."
66
+ );
67
+ console.log(response);
68
+ ```
69
+
70
+ ### Logging Traces Outside LangChain
71
+
72
+ _Note: this API is experimental and may change in the future_
73
+
74
+ You can still use the LangSmith development platform without depending on any
75
+ LangChain code. You can connect either by setting the appropriate environment variables,
76
+ or by directly specifying the connection information in the RunTree.
77
+
78
+ 1. **Copy the environment variables from the Settings Page and add them to your application.**
79
+
80
+ ```typescript
81
+ process.env["LANGCHAIN_ENDPOINT"] = "https://api.langchain.plus"; // or your own server
82
+ process.env["LANGCHAIN_API_KEY"] = "<YOUR-LANGCHAINPLUS-API-KEY>";
83
+ // process.env["LANGCHAIN_PROJECT"] = "My Project Name"; // Optional: "default" is used if not set
84
+ ```
85
+
86
+ 2. **Log traces using a RunTree.**
87
+
88
+ A RunTree tracks your application. Each RunTree object is required to have a name and run_type. These and other important attributes are as follows:
89
+
90
+ - `name`: `string` - used to identify the component's purpose
91
+ - `run_type`: `string` - Currently one of "llm", "chain" or "tool"; more options will be added in the future
92
+ - `inputs`: `Record<string, any>` - the inputs to the component
93
+ - `outputs`: `Optional<Record<string, any>>` - the (optional) returned values from the component
94
+ - `error`: `Optional<string>` - Any error messages that may have arisen during the call
95
+
96
+ ```typescript
97
+ import { RunTree, RunTreeConfig } from "langsmith";
98
+
99
+ const parentRunConfig: RunTreeConfig = {
100
+ name: "My Chat Bot",
101
+ run_type: "chain",
102
+ inputs: {
103
+ text: "Summarize this morning's meetings.",
104
+ },
105
+ serialized: {}, // Serialized representation of this chain
106
+ // project_name: "Defaults to the LANGCHAIN_PROJECT env var"
107
+ // apiUrl: "Defaults to the LANGCHAIN_ENDPOINT env var"
108
+ // apiKey: "Defaults to the LANGCHAIN_API_KEY env var"
109
+ };
110
+
111
+ const parentRun = new RunTree(parentRunConfig);
112
+
113
+ const childLlmRun = await parentRun.createChild({
114
+ name: "My Proprietary LLM",
115
+ run_type: "llm",
116
+ inputs: {
117
+ prompts: [
118
+ "You are an AI Assistant. The time is XYZ." +
119
+ " Summarize this morning's meetings.",
120
+ ],
121
+ },
122
+ });
123
+
124
+ await childLlmRun.end({
125
+ outputs: {
126
+ generations: [
127
+ "I should use the transcript_loader tool" +
128
+ " to fetch meeting_transcripts from XYZ",
129
+ ],
130
+ },
131
+ });
132
+
133
+ const childToolRun = await parentRun.createChild({
134
+ name: "transcript_loader",
135
+ run_type: "tool",
136
+ inputs: {
137
+ date: "XYZ",
138
+ content_type: "meeting_transcripts",
139
+ },
140
+ });
141
+
142
+ await childToolRun.end({
143
+ outputs: {
144
+ meetings: ["Meeting1 notes.."],
145
+ },
146
+ });
147
+
148
+ const childChainRun = await parentRun.createChild({
149
+ name: "Unreliable Component",
150
+ run_type: "tool",
151
+ inputs: {
152
+ input: "Summarize these notes...",
153
+ },
154
+ });
155
+
156
+ try {
157
+ // .... the component does work
158
+ throw new Error("Something went wrong");
159
+ } catch (e) {
160
+ await childChainRun.end({
161
+ error: `I errored again ${e.message}`,
162
+ });
163
+ }
164
+
165
+ await parentRun.end({
166
+ outputs: {
167
+ output: ["The meeting notes are as follows:..."],
168
+ },
169
+ });
170
+
171
+ await parentRun.postRun({
172
+ exclude_child_runs: false,
173
+ });
174
+ ```
175
+
176
+ ### Create a Dataset from Existing Runs
177
+
178
+ Once your runs are stored in LangSmith, you can convert them into a dataset.
179
+ For this example, we will do so using the Client, but you can also do this using
180
+ the web interface, as explained in the [LangSmith docs](https://docs.langchain.plus/docs/).
181
+
182
+ ```typescript
183
+ import { Client } from "langsmith/client";
184
+ const client = new Client({
185
+ // apiUrl: "https://api.langchain.com", // Defaults to the LANGCHAIN_ENDPOINT env var
186
+ // apiKey: "my_api_key", // Defaults to the LANGCHAIN_API_KEY env var
187
+ /* callerOptions: {
188
+ maxConcurrency?: Infinity; // Maximum number of concurrent requests to make
189
+ maxRetries?: 6; // Maximum number of retries to make
190
+ */
191
+ });
192
+ const datasetName = "Example Dataset";
193
+ // We will only use examples from the top level AgentExecutor run here,
194
+ // and exclude runs that errored.
195
+ const runs = await client.listRuns({
196
+ projectName: "my_project",
197
+ executionOrder: 1,
198
+ error: false,
199
+ });
200
+
201
+ const dataset = await client.createDataset(datasetName, {
202
+ description: "An example dataset",
203
+ });
204
+
205
+ for (const run of runs) {
206
+ await client.createExample(run.inputs, run.outputs ?? {}, {
207
+ datasetId: dataset.id,
208
+ });
209
+ }
210
+ ```
211
+
212
+ # Evaluating Runs
213
+
214
+ You can run evaluations directly using the LangSmith client.
215
+
216
+ ```ts
217
+ import { StringEvaluator } from "langsmith/evaluation";
218
+
219
+ function jaccardChars(output: string, answer: string): number {
220
+ const predictionChars = new Set(output.trim().toLowerCase());
221
+ const answerChars = new Set(answer.trim().toLowerCase());
222
+ const intersection = [...predictionChars].filter((x) => answerChars.has(x));
223
+ const union = new Set([...predictionChars, ...answerChars]);
224
+ return intersection.length / union.size;
225
+ }
226
+
227
+ async function grader(config: {
228
+ input: string;
229
+ prediction: string;
230
+ answer?: string;
231
+ }): Promise<{ score: number; value: string }> {
232
+ let value: string;
233
+ let score: number;
234
+ if (config.answer === null || config.answer === undefined) {
235
+ value = "AMBIGUOUS";
236
+ score = 0.5;
237
+ } else {
238
+ score = jaccardChars(config.prediction, config.answer);
239
+ value = score > 0.9 ? "CORRECT" : "INCORRECT";
240
+ }
241
+ return { score: score, value: value };
242
+ }
243
+
244
+ const evaluator = new StringEvaluator({
245
+ evaluationName: "Jaccard",
246
+ gradingFunction: grader,
247
+ });
248
+
249
+ const runs = await client.listRuns({
250
+ projectName: "my_project",
251
+ executionOrder: 1,
252
+ error: false,
253
+ });
254
+
255
+ for (const run of runs) {
256
+ client.evaluateRun(run, evaluator);
257
+ }
258
+ ```
259
+
260
+ ## Additional Documentation
261
+
262
+ To learn more about the LangSmith platform, check out the [docs](https://docs.langchain.plus/docs/).
package/client.cjs ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/client.cjs');
package/client.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/client.js'
package/client.js ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/client.js'
@@ -0,0 +1,17 @@
1
+ version: '3'
2
+ services:
3
+ ngrok:
4
+ image: ngrok/ngrok:latest
5
+ restart: unless-stopped
6
+ command:
7
+ - "start"
8
+ - "--all"
9
+ - "--config"
10
+ - "/etc/ngrok.yml"
11
+ volumes:
12
+ - ./ngrok_config.yaml:/etc/ngrok.yml
13
+ ports:
14
+ - 4040:4040
15
+ langchain-backend:
16
+ depends_on:
17
+ - ngrok
@@ -0,0 +1,43 @@
1
+ version: "3"
2
+ services:
3
+ langchain-frontend:
4
+ image: langchain/${_LANGCHAINPLUS_IMAGE_PREFIX-}langchainplus-frontend:latest
5
+ ports:
6
+ - 80:80
7
+ environment:
8
+ - REACT_APP_BACKEND_URL=http://localhost:1984
9
+ depends_on:
10
+ - langchain-backend
11
+ volumes:
12
+ - ./conf/nginx.conf:/etc/nginx/default.conf:ro
13
+ langchain-backend:
14
+ image: langchain/${_LANGCHAINPLUS_IMAGE_PREFIX-}langchainplus-backend:latest
15
+ environment:
16
+ - PORT=1984
17
+ - LANGCHAIN_ENV=local_docker
18
+ - LOG_LEVEL=warning
19
+ - OPENAI_API_KEY=${OPENAI_API_KEY}
20
+ ports:
21
+ - 1984:1984
22
+ depends_on:
23
+ - langchain-db
24
+ langchain-db:
25
+ image: postgres:14.1
26
+ command:
27
+ [
28
+ "postgres",
29
+ "-c",
30
+ "log_min_messages=WARNING",
31
+ "-c",
32
+ "client_min_messages=WARNING",
33
+ ]
34
+ environment:
35
+ - POSTGRES_PASSWORD=postgres
36
+ - POSTGRES_USER=postgres
37
+ - POSTGRES_DB=postgres
38
+ volumes:
39
+ - langchain-db-data:/var/lib/postgresql/data
40
+ ports:
41
+ - 5433:5432
42
+ volumes:
43
+ langchain-db-data:
@@ -0,0 +1,278 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ const fs = __importStar(require("fs"));
28
+ const path = __importStar(require("path"));
29
+ const util = __importStar(require("util"));
30
+ const commander_1 = require("commander");
31
+ const child_process = __importStar(require("child_process"));
32
+ const env_js_1 = require("../utils/env.cjs");
33
+ const currentFileName = __filename;
34
+ const currentDirName = __dirname;
35
+ const exec = util.promisify(child_process.exec);
36
+ const program = new commander_1.Command();
37
+ async function getDockerComposeCommand() {
38
+ try {
39
+ await exec("docker compose --version");
40
+ return ["docker", "compose"];
41
+ }
42
+ catch {
43
+ try {
44
+ await exec("docker-compose --version");
45
+ return ["docker-compose"];
46
+ }
47
+ catch {
48
+ throw new Error("Neither 'docker compose' nor 'docker-compose' commands are available. Please install the Docker server following the instructions for your operating system at https://docs.docker.com/engine/install/");
49
+ }
50
+ }
51
+ }
52
+ async function pprintServices(servicesStatus) {
53
+ const services = [];
54
+ for (const service of servicesStatus) {
55
+ const serviceStatus = {
56
+ Service: String(service["Service"]),
57
+ Status: String(service["Status"]),
58
+ };
59
+ const publishers = service["Publishers"] || [];
60
+ if (publishers) {
61
+ serviceStatus["PublishedPorts"] = publishers
62
+ .map((publisher) => String(publisher["PublishedPort"]))
63
+ .join(", ");
64
+ }
65
+ services.push(serviceStatus);
66
+ }
67
+ const maxServiceLen = Math.max(...services.map((service) => service["Service"].length));
68
+ const maxStateLen = Math.max(...services.map((service) => service["Status"].length));
69
+ const serviceMessage = [
70
+ "\n" +
71
+ "Service".padEnd(maxServiceLen + 2) +
72
+ "Status".padEnd(maxStateLen + 2) +
73
+ "Published Ports",
74
+ ];
75
+ for (const service of services) {
76
+ const serviceStr = service["Service"].padEnd(maxServiceLen + 2);
77
+ const stateStr = service["Status"].padEnd(maxStateLen + 2);
78
+ const portsStr = service["PublishedPorts"] || "";
79
+ serviceMessage.push(serviceStr + stateStr + portsStr);
80
+ }
81
+ let langchainEndpoint = "http://localhost:1984";
82
+ const usedNgrok = services.some((service) => service["Service"].includes("ngrok"));
83
+ if (usedNgrok) {
84
+ langchainEndpoint = await getNgrokUrl();
85
+ }
86
+ serviceMessage.push("\nTo connect, set the following environment variables" +
87
+ " in your LangChain application:" +
88
+ "\nLANGCHAIN_TRACING_V2=true" +
89
+ `\nLANGCHAIN_ENDPOINT=${langchainEndpoint}`);
90
+ console.info(serviceMessage.join("\n"));
91
+ }
92
+ async function getNgrokUrl() {
93
+ const ngrokUrl = "http://localhost:4040/api/tunnels";
94
+ try {
95
+ // const response = await axios.get(ngrokUrl);
96
+ const response = await fetch(ngrokUrl);
97
+ if (response.status !== 200) {
98
+ throw new Error(`Could not connect to ngrok console. ${response.status}, ${response.statusText}`);
99
+ }
100
+ const result = await response.json();
101
+ const exposedUrl = result["tunnels"][0]["public_url"];
102
+ return exposedUrl;
103
+ }
104
+ catch (error) {
105
+ throw new Error(`Could not connect to ngrok console. ${error}`);
106
+ }
107
+ }
108
+ async function createNgrokConfig(authToken) {
109
+ const configPath = path.join(currentDirName, "ngrok_config.yaml");
110
+ // Check if is a directory
111
+ if (fs.existsSync(configPath) && fs.lstatSync(configPath).isDirectory()) {
112
+ fs.rmdirSync(configPath, { recursive: true });
113
+ }
114
+ else if (fs.existsSync(configPath)) {
115
+ fs.unlinkSync(configPath);
116
+ }
117
+ let ngrokConfig = `
118
+ region: us
119
+ tunnels:
120
+ langchain:
121
+ addr: langchain-backend:1984
122
+ proto: http
123
+ version: '2'
124
+ `;
125
+ if (authToken !== null) {
126
+ ngrokConfig += `authtoken: ${authToken}`;
127
+ }
128
+ fs.writeFileSync(configPath, ngrokConfig);
129
+ return configPath;
130
+ }
131
+ class PlusCommand {
132
+ constructor({ dockerComposeCommand }) {
133
+ Object.defineProperty(this, "dockerComposeCommand", {
134
+ enumerable: true,
135
+ configurable: true,
136
+ writable: true,
137
+ value: []
138
+ });
139
+ Object.defineProperty(this, "dockerComposeFile", {
140
+ enumerable: true,
141
+ configurable: true,
142
+ writable: true,
143
+ value: ""
144
+ });
145
+ Object.defineProperty(this, "ngrokPath", {
146
+ enumerable: true,
147
+ configurable: true,
148
+ writable: true,
149
+ value: ""
150
+ });
151
+ this.dockerComposeCommand = dockerComposeCommand;
152
+ this.dockerComposeFile = path.join(path.dirname(currentFileName), "docker-compose.yaml");
153
+ this.ngrokPath = path.join(path.dirname(currentFileName), "docker-compose.ngrok.yaml");
154
+ }
155
+ static async create() {
156
+ const dockerComposeCommand = await getDockerComposeCommand();
157
+ return new PlusCommand({ dockerComposeCommand });
158
+ }
159
+ async start(args) {
160
+ if (args.dev) {
161
+ (0, env_js_1.setEnvironmentVariable)("_LANGCHAINPLUS_IMAGE_PREFIX", "rc-");
162
+ }
163
+ if (args.openaiApiKey) {
164
+ (0, env_js_1.setEnvironmentVariable)("OPENAI_API_KEY", args.openaiApiKey);
165
+ }
166
+ if (args.expose) {
167
+ await this.startAndExpose(args.ngrokAuthtoken);
168
+ }
169
+ else {
170
+ await this.startLocal();
171
+ }
172
+ }
173
+ async pull(args) {
174
+ if (args.dev) {
175
+ (0, env_js_1.setEnvironmentVariable)("_LANGCHAINPLUS_IMAGE_PREFIX", "rc-");
176
+ }
177
+ const command = [
178
+ ...this.dockerComposeCommand,
179
+ "-f",
180
+ this.dockerComposeFile,
181
+ "pull",
182
+ ];
183
+ await exec(command.join(" "));
184
+ }
185
+ async startLocal() {
186
+ const command = [
187
+ ...this.dockerComposeCommand,
188
+ "-f",
189
+ this.dockerComposeFile,
190
+ "up",
191
+ "--pull=always",
192
+ "--quiet-pull",
193
+ "--wait",
194
+ ];
195
+ await exec(command.join(" "));
196
+ console.info("LangSmith server is running at http://localhost:1984. To connect locally, set the following environment variable when running your LangChain application.");
197
+ console.info("\tLANGCHAIN_TRACING_V2=true");
198
+ }
199
+ async startAndExpose(ngrokAuthToken) {
200
+ const configPath = await createNgrokConfig(ngrokAuthToken);
201
+ const command = [
202
+ ...this.dockerComposeCommand,
203
+ "-f",
204
+ this.dockerComposeFile,
205
+ "-f",
206
+ this.ngrokPath,
207
+ "up",
208
+ "--pull=always",
209
+ "--quiet-pull",
210
+ "--wait",
211
+ ];
212
+ await exec(command.join(" "));
213
+ console.info("ngrok is running. You can view the dashboard at http://0.0.0.0:4040");
214
+ const ngrokUrl = await getNgrokUrl();
215
+ console.info("LangSmith server is running at http://localhost:1984. To connect remotely, set the following environment variable when running your LangChain application.");
216
+ console.info("\tLANGCHAIN_TRACING_V2=true");
217
+ console.info(`\tLANGCHAIN_ENDPOINT=${ngrokUrl}`);
218
+ fs.unlinkSync(configPath);
219
+ }
220
+ async stop() {
221
+ const command = [
222
+ ...this.dockerComposeCommand,
223
+ "-f",
224
+ this.dockerComposeFile,
225
+ "-f",
226
+ this.ngrokPath,
227
+ "down",
228
+ ];
229
+ await exec(command.join(" "));
230
+ }
231
+ async status() {
232
+ const command = [
233
+ ...this.dockerComposeCommand,
234
+ "-f",
235
+ this.dockerComposeFile,
236
+ "ps",
237
+ "--format",
238
+ "json",
239
+ ];
240
+ const result = await exec(command.join(" "));
241
+ const servicesStatus = JSON.parse(result.stdout);
242
+ if (servicesStatus) {
243
+ console.info("The LangSmith server is currently running.");
244
+ await pprintServices(servicesStatus);
245
+ }
246
+ else {
247
+ console.info("The LangSmith server is not running.");
248
+ }
249
+ }
250
+ }
251
+ const startCommand = new commander_1.Command("start")
252
+ .description("Start the LangSmith server")
253
+ .option("--expose", "Expose the server to the internet via ngrok (requires ngrok to be installed)")
254
+ .option("--ngrok-authtoken <ngrokAuthtoken>", "Your ngrok auth token. If this is set, --expose is implied.")
255
+ .option("--dev", "Run the development version of the LangSmith server")
256
+ .option("--openai-api-key <openaiApiKey>", "Your OpenAI API key. If this is set, the server will be able to process text and return enhanced plus results.")
257
+ .action(async (args) => (await PlusCommand.create()).start(args));
258
+ const stopCommand = new commander_1.Command("stop")
259
+ .command("stop")
260
+ .description("Stop the LangSmith server")
261
+ .action(async () => (await PlusCommand.create()).stop());
262
+ const pullCommand = new commander_1.Command("pull")
263
+ .command("pull")
264
+ .description("Pull the latest version of the LangSmith server")
265
+ .option("--dev", "Pull the development version of the LangSmith server")
266
+ .action(async (args) => (await PlusCommand.create()).pull(args));
267
+ const statusCommand = new commander_1.Command("status")
268
+ .command("status")
269
+ .description("Get the status of the LangSmith server")
270
+ .action(async () => (await PlusCommand.create()).status());
271
+ program
272
+ .command("plus")
273
+ .description("Manage the LangSmith server")
274
+ .addCommand(startCommand)
275
+ .addCommand(stopCommand)
276
+ .addCommand(pullCommand)
277
+ .addCommand(statusCommand);
278
+ program.parse(process.argv);
@@ -0,0 +1 @@
1
+ export {};