langsmith
Advanced tools
Comparing version 0.0.25 to 0.0.26
@@ -126,2 +126,8 @@ import * as fs from "fs"; | ||
}); | ||
Object.defineProperty(this, "dockerComposeBetaFile", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: "" | ||
}); | ||
Object.defineProperty(this, "ngrokPath", { | ||
@@ -136,2 +142,3 @@ enumerable: true, | ||
this.dockerComposeDevFile = path.join(path.dirname(currentFileName), "docker-compose.dev.yaml"); | ||
this.dockerComposeBetaFile = path.join(path.dirname(currentFileName), "docker-compose.beta.yaml"); | ||
this.ngrokPath = path.join(path.dirname(currentFileName), "docker-compose.ngrok.yaml"); | ||
@@ -157,24 +164,12 @@ } | ||
static async create() { | ||
console.info("BY USING THIS SOFTWARE YOU AGREE TO THE TERMS OF SERVICE AT:"); | ||
console.info("https://smith.langchain.com/terms-of-service.pdf"); | ||
const dockerComposeCommand = await getDockerComposeCommand(); | ||
return new SmithCommand({ dockerComposeCommand }); | ||
} | ||
async start(args) { | ||
console.info("BY USING THIS SOFTWARE YOU AGREE TO THE TERMS OF SERVICE AT:"); | ||
console.info("https://smith.langchain.com/terms-of-service.pdf"); | ||
if (args.dev) { | ||
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "rc-"); | ||
async pull({ stage = "prod" }) { | ||
if (stage === "dev") { | ||
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "dev-"); | ||
} | ||
if (args.openaiApiKey) { | ||
setEnvironmentVariable("OPENAI_API_KEY", args.openaiApiKey); | ||
} | ||
await this.pull(args); | ||
if (args.expose) { | ||
await this.startAndExpose(args.ngrokAuthtoken, args.dev); | ||
} | ||
else { | ||
await this.startLocal(args.dev); | ||
} | ||
} | ||
async pull(args) { | ||
if (args.dev) { | ||
else if (stage === "beta") { | ||
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "rc-"); | ||
@@ -190,3 +185,3 @@ } | ||
} | ||
async startLocal(dev) { | ||
async startLocal(stage = "prod") { | ||
const command = [ | ||
@@ -197,5 +192,8 @@ ...this.dockerComposeCommand, | ||
]; | ||
if (dev) { | ||
if (stage === "dev") { | ||
command.push("-f", this.dockerComposeDevFile); | ||
} | ||
else if (stage === "beta") { | ||
command.push("-f", this.dockerComposeBetaFile); | ||
} | ||
command.push("up", "--quiet-pull", "--wait"); | ||
@@ -210,3 +208,3 @@ await this.executeCommand(command); | ||
} | ||
async startAndExpose(ngrokAuthToken, dev) { | ||
async startAndExpose(ngrokAuthToken, stage = "prod") { | ||
const configPath = await createNgrokConfig(ngrokAuthToken); | ||
@@ -220,5 +218,8 @@ const command = [ | ||
]; | ||
if (dev) { | ||
if (stage === "dev") { | ||
command.push("-f", this.dockerComposeDevFile); | ||
} | ||
else if (stage === "beta") { | ||
command.push("-f", this.dockerComposeBetaFile); | ||
} | ||
command.push("up", "--quiet-pull", "--wait"); | ||
@@ -273,20 +274,50 @@ await this.executeCommand(command); | ||
.option("--ngrok-authtoken <ngrokAuthtoken>", "Your ngrok auth token. If this is set, --expose is implied.") | ||
.option("--dev", "Run the development version of the LangSmith server") | ||
.option("--stage <stage>", "Which version of LangSmith to run. Options: prod, dev, beta (default: prod)") | ||
.option("--openai-api-key <openaiApiKey>", "Your OpenAI API key. If not provided, the OpenAI API Key will be read" + | ||
" from the OPENAI_API_KEY environment variable. If neither are provided," + | ||
" some features of LangSmith will not be available.") | ||
.action(async (args) => (await SmithCommand.create()).start(args)); | ||
.action(async (args) => { | ||
const smith = await SmithCommand.create(); | ||
if (args.stage === "dev") { | ||
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "dev-"); | ||
} | ||
else if (args.stage === "beta") { | ||
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "rc-"); | ||
} | ||
if (args.openaiApiKey) { | ||
setEnvironmentVariable("OPENAI_API_KEY", args.openaiApiKey); | ||
} | ||
await smith.pull({ stage: args.stage }); | ||
if (args.expose) { | ||
await smith.startAndExpose(args.ngrokAuthtoken, args.stage); | ||
} | ||
else { | ||
await smith.startLocal(args.stage); | ||
} | ||
}); | ||
const stopCommand = new Command("stop") | ||
.command("stop") | ||
.description("Stop the LangSmith server") | ||
.action(async () => (await SmithCommand.create()).stop()); | ||
.action(async () => { | ||
const smith = await SmithCommand.create(); | ||
await smith.stop(); | ||
}); | ||
const pullCommand = new Command("pull") | ||
.command("pull") | ||
.description("Pull the latest version of the LangSmith server") | ||
.option("--dev", "Pull the development version of the LangSmith server") | ||
.action(async (args) => (await SmithCommand.create()).pull(args)); | ||
.option("--stage <stage>", "Which version of LangSmith to pull. Options: prod, dev, beta (default: prod)") | ||
.action(async (args) => { | ||
const smith = await SmithCommand.create(); | ||
if (args.stage === "dev") { | ||
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "dev-"); | ||
} | ||
else if (args.stage === "beta") { | ||
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "rc-"); | ||
} | ||
await smith.pull({ stage: args.stage }); | ||
}); | ||
const statusCommand = new Command("status") | ||
.command("status") | ||
.description("Get the status of the LangSmith server") | ||
.action(async () => (await SmithCommand.create()).status()); | ||
.action(async () => { | ||
const smith = await SmithCommand.create(); | ||
await smith.status(); | ||
}); | ||
program | ||
@@ -293,0 +324,0 @@ .description("Manage the LangSmith server") |
@@ -129,2 +129,3 @@ import * as fs from "fs"; | ||
dockerComposeDevFile = ""; | ||
dockerComposeBetaFile = ""; | ||
ngrokPath = ""; | ||
@@ -142,2 +143,6 @@ | ||
); | ||
this.dockerComposeBetaFile = path.join( | ||
path.dirname(currentFileName), | ||
"docker-compose.beta.yaml" | ||
); | ||
this.ngrokPath = path.join( | ||
@@ -169,7 +174,2 @@ path.dirname(currentFileName), | ||
public static async create() { | ||
const dockerComposeCommand = await getDockerComposeCommand(); | ||
return new SmithCommand({ dockerComposeCommand }); | ||
} | ||
async start(args: any) { | ||
console.info( | ||
@@ -179,18 +179,10 @@ "BY USING THIS SOFTWARE YOU AGREE TO THE TERMS OF SERVICE AT:" | ||
console.info("https://smith.langchain.com/terms-of-service.pdf"); | ||
if (args.dev) { | ||
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "rc-"); | ||
} | ||
if (args.openaiApiKey) { | ||
setEnvironmentVariable("OPENAI_API_KEY", args.openaiApiKey); | ||
} | ||
await this.pull(args); | ||
if (args.expose) { | ||
await this.startAndExpose(args.ngrokAuthtoken, args.dev); | ||
} else { | ||
await this.startLocal(args.dev); | ||
} | ||
const dockerComposeCommand = await getDockerComposeCommand(); | ||
return new SmithCommand({ dockerComposeCommand }); | ||
} | ||
async pull(args: any) { | ||
if (args.dev) { | ||
async pull({ stage = "prod" }) { | ||
if (stage === "dev") { | ||
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "dev-"); | ||
} else if (stage === "beta") { | ||
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "rc-"); | ||
@@ -208,3 +200,3 @@ } | ||
async startLocal(dev: boolean) { | ||
async startLocal(stage = "prod") { | ||
const command = [ | ||
@@ -215,7 +207,12 @@ ...this.dockerComposeCommand, | ||
]; | ||
if (dev) { | ||
if (stage === "dev") { | ||
command.push("-f", this.dockerComposeDevFile); | ||
} else if (stage === "beta") { | ||
command.push("-f", this.dockerComposeBetaFile); | ||
} | ||
command.push("up", "--quiet-pull", "--wait"); | ||
await this.executeCommand(command); | ||
console.info( | ||
@@ -228,6 +225,7 @@ "LangSmith server is running at http://localhost:1984.\n" + | ||
); | ||
console.info("\tLANGCHAIN_TRACING_V2=true"); | ||
} | ||
async startAndExpose(ngrokAuthToken: string | null, dev: boolean) { | ||
async startAndExpose(ngrokAuthToken: string | null, stage = "prod") { | ||
const configPath = await createNgrokConfig(ngrokAuthToken); | ||
@@ -241,7 +239,12 @@ const command = [ | ||
]; | ||
if (dev) { | ||
if (stage === "dev") { | ||
command.push("-f", this.dockerComposeDevFile); | ||
} else if (stage === "beta") { | ||
command.push("-f", this.dockerComposeBetaFile); | ||
} | ||
command.push("up", "--quiet-pull", "--wait"); | ||
await this.executeCommand(command); | ||
console.info( | ||
@@ -275,2 +278,3 @@ "ngrok is running. You can view the dashboard at http://0.0.0.0:4040" | ||
} | ||
async status() { | ||
@@ -307,4 +311,7 @@ const command = [ | ||
) | ||
.option("--dev", "Run the development version of the LangSmith server") | ||
.option( | ||
"--stage <stage>", | ||
"Which version of LangSmith to run. Options: prod, dev, beta (default: prod)" | ||
) | ||
.option( | ||
"--openai-api-key <openaiApiKey>", | ||
@@ -315,19 +322,49 @@ "Your OpenAI API key. If not provided, the OpenAI API Key will be read" + | ||
) | ||
.action(async (args: string[]) => (await SmithCommand.create()).start(args)); | ||
.action(async (args) => { | ||
const smith = await SmithCommand.create(); | ||
if (args.stage === "dev") { | ||
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "dev-"); | ||
} else if (args.stage === "beta") { | ||
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "rc-"); | ||
} | ||
if (args.openaiApiKey) { | ||
setEnvironmentVariable("OPENAI_API_KEY", args.openaiApiKey); | ||
} | ||
await smith.pull({ stage: args.stage }); | ||
if (args.expose) { | ||
await smith.startAndExpose(args.ngrokAuthtoken, args.stage); | ||
} else { | ||
await smith.startLocal(args.stage); | ||
} | ||
}); | ||
const stopCommand = new Command("stop") | ||
.command("stop") | ||
.description("Stop the LangSmith server") | ||
.action(async () => (await SmithCommand.create()).stop()); | ||
.action(async () => { | ||
const smith = await SmithCommand.create(); | ||
await smith.stop(); | ||
}); | ||
const pullCommand = new Command("pull") | ||
.command("pull") | ||
.description("Pull the latest version of the LangSmith server") | ||
.option("--dev", "Pull the development version of the LangSmith server") | ||
.action(async (args: string[]) => (await SmithCommand.create()).pull(args)); | ||
.option( | ||
"--stage <stage>", | ||
"Which version of LangSmith to pull. Options: prod, dev, beta (default: prod)" | ||
) | ||
.action(async (args) => { | ||
const smith = await SmithCommand.create(); | ||
if (args.stage === "dev") { | ||
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "dev-"); | ||
} else if (args.stage === "beta") { | ||
setEnvironmentVariable("_LANGSMITH_IMAGE_PREFIX", "rc-"); | ||
} | ||
await smith.pull({ stage: args.stage }); | ||
}); | ||
const statusCommand = new Command("status") | ||
.command("status") | ||
.description("Get the status of the LangSmith server") | ||
.action(async () => (await SmithCommand.create()).status()); | ||
.action(async () => { | ||
const smith = await SmithCommand.create(); | ||
await smith.status(); | ||
}); | ||
@@ -334,0 +371,0 @@ program |
import * as uuid from "uuid"; | ||
import { getEnvironmentVariable, getRuntimeEnvironment } from "./utils/env.js"; | ||
import { Client } from "./client.js"; | ||
const warnedMessages = {}; | ||
function warnOnce(message) { | ||
if (!warnedMessages[message]) { | ||
console.warn(message); | ||
warnedMessages[message] = true; | ||
} | ||
} | ||
export class RunTree { | ||
@@ -197,4 +204,10 @@ constructor(config) { | ||
async postRun(excludeChildRuns = true) { | ||
const runCreate = await this._convertToCreate(this, excludeChildRuns); | ||
const runCreate = await this._convertToCreate(this, true); | ||
await this.client.createRun(runCreate); | ||
if (!excludeChildRuns) { | ||
warnOnce("Posting with excludeChildRuns=false is deprecated and will be removed in a future version."); | ||
for (const childRun of this.child_runs) { | ||
await childRun.postRun(false); | ||
} | ||
} | ||
} | ||
@@ -201,0 +214,0 @@ async patchRun() { |
{ | ||
"name": "langsmith", | ||
"version": "0.0.25", | ||
"version": "0.0.26", | ||
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -115,2 +115,4 @@ # LangSmith Client SDK | ||
await parentRun.postRun(); | ||
const childLlmRun = await parentRun.createChild({ | ||
@@ -127,2 +129,4 @@ name: "My Proprietary LLM", | ||
await childLlmRun.postRun(); | ||
await childLlmRun.end({ | ||
@@ -137,2 +141,4 @@ outputs: { | ||
await childLlmRun.patchRun(); | ||
const childToolRun = await parentRun.createChild({ | ||
@@ -146,2 +152,3 @@ name: "transcript_loader", | ||
}); | ||
await childToolRun.postRun(); | ||
@@ -154,2 +161,4 @@ await childToolRun.end({ | ||
await childToolRun.patchRun(); | ||
const childChainRun = await parentRun.createChild({ | ||
@@ -163,2 +172,4 @@ name: "Unreliable Component", | ||
await childChainRun.postRun(); | ||
try { | ||
@@ -171,4 +182,8 @@ // .... the component does work | ||
}); | ||
await childChainRun.patchRun(); | ||
throw e; | ||
} | ||
await childChainRun.patchRun(); | ||
await parentRun.end({ | ||
@@ -181,3 +196,3 @@ outputs: { | ||
// False directs to not exclude child runs | ||
await parentRun.postRun(false); | ||
await parentRun.patchRun(); | ||
``` | ||
@@ -184,0 +199,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
158312
52
3900
281