Socket
Socket
Sign inDemoInstall

langsmith

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

langsmith - npm Package Compare versions

Comparing version 0.0.39 to 0.0.40

17

dist/client.d.ts

@@ -9,2 +9,3 @@ import { AsyncCallerParams } from "./utils/async_caller.js";

timeout_ms?: number;
webUrl?: string;
}

@@ -52,2 +53,6 @@ interface ListRunsParams {

}
interface projectOptions {
projectName?: string;
projectId?: string;
}
export type FeedbackSourceType = "model" | "api" | "app";

@@ -63,4 +68,6 @@ export type CreateExampleOptions = {

private apiUrl;
private webUrl?;
private caller;
private timeout_ms;
private _tenantId;
constructor(config?: ClientConfig);

@@ -70,2 +77,3 @@ static getDefaultClientConfig(): {

apiKey?: string;
webUrl?: string;
};

@@ -82,5 +90,7 @@ private validateApiKeyIfHosted;

}): Promise<Run>;
getRunUrl({ runId, }: {
runId: string;
}): Promise<string | undefined>;
getRunUrl({ runId, run, projectOpts, }: {
runId?: string;
run?: Run;
projectOpts?: projectOptions;
}): Promise<string>;
private _loadChildRuns;

@@ -103,2 +113,3 @@ listRuns({ projectId, projectName, parentRunId, referenceExampleId, startTime, executionOrder, runType, error, id, limit, offset, query, filter, }: ListRunsParams): AsyncIterable<Run>;

}): Promise<TracerSessionResult>;
private _getTenantId;
listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, }?: {

@@ -105,0 +116,0 @@ projectIds?: string[];

@@ -61,2 +61,8 @@ import * as uuid from "uuid";

});
Object.defineProperty(this, "webUrl", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
Object.defineProperty(this, "caller", {

@@ -74,5 +80,12 @@ enumerable: true,

});
Object.defineProperty(this, "_tenantId", {
enumerable: true,
configurable: true,
writable: true,
value: null
});
const defaultConfig = Client.getDefaultClientConfig();
this.apiUrl = trimQuotes(config.apiUrl ?? defaultConfig.apiUrl) ?? "";
this.apiKey = trimQuotes(config.apiKey ?? defaultConfig.apiKey);
this.webUrl = trimQuotes(config.webUrl ?? defaultConfig.webUrl);
this.validateApiKeyIfHosted();

@@ -89,2 +102,3 @@ this.timeout_ms = config.timeout_ms ?? 4000;

apiKey: apiKey,
webUrl: undefined,
};

@@ -99,9 +113,15 @@ }

getHostUrl() {
if (isLocalhost(this.apiUrl)) {
if (this.webUrl) {
return this.webUrl;
}
else if (isLocalhost(this.apiUrl)) {
this.webUrl = "http://localhost";
return "http://localhost";
}
else if (this.apiUrl.split(".", 1)[0].includes("dev")) {
this.webUrl = "https://dev.smith.langchain.com";
return "https://dev.smith.langchain.com";
}
else {
this.webUrl = "https://smith.langchain.com";
return "https://smith.langchain.com";

@@ -208,9 +228,34 @@ }

}
async getRunUrl({ runId, }) {
const run = await this.readRun(runId);
if (!run.app_path) {
return undefined;
async getRunUrl({ runId, run, projectOpts, }) {
if (run !== undefined) {
let sessionId;
if (run.session_id) {
sessionId = run.session_id;
}
else if (projectOpts?.projectName) {
sessionId = (await this.readProject({ projectName: projectOpts?.projectName })).id;
}
else if (projectOpts?.projectId) {
sessionId = projectOpts?.projectId;
}
else {
const project = await this.readProject({
projectName: getEnvironmentVariable("LANGCHAIN_PROJECT") || "default",
});
sessionId = project.id;
}
const tenantId = await this._getTenantId();
return `${this.getHostUrl()}/o/${tenantId}/projects/p/${sessionId}/r/${run.id}?poll=true`;
}
const baseUrl = this.getHostUrl();
return `${baseUrl}${run.app_path}`;
else if (runId !== undefined) {
const run_ = await this.readRun(runId);
if (!run_.app_path) {
throw new Error(`Run ${runId} has no app_path`);
}
const baseUrl = this.getHostUrl();
return `${baseUrl}${run_.app_path}`;
}
else {
throw new Error("Must provide either runId or run");
}
}

@@ -382,2 +427,13 @@ async _loadChildRuns(run) {

}
async _getTenantId() {
if (this._tenantId !== null) {
return this._tenantId;
}
const queryParams = new URLSearchParams({ limit: "1" });
for await (const projects of this._getPaginated("/sessions", queryParams)) {
this._tenantId = projects[0].tenant_id;
return projects[0].tenant_id;
}
throw new Error("No projects found to resolve tenant.");
}
async *listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, } = {}) {

@@ -384,0 +440,0 @@ const params = new URLSearchParams();

2

package.json
{
"name": "langsmith",
"version": "0.0.39",
"version": "0.0.40",
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",

@@ -5,0 +5,0 @@ "files": [

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc