Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

langsmith

Package Overview
Dependencies
Maintainers
1
Versions
173
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.7 to 0.0.8

19

dist/client.d.ts

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

private _get;
private _getPaginated;
createRun(run: CreateRunParams): Promise<void>;

@@ -74,3 +75,3 @@ updateRun(runId: string, run: RunUpdate): Promise<void>;

private _loadChildRuns;
listRuns({ projectId, projectName, parentRunId, referenceExampleId, datasetId, startTime, endTime, executionOrder, runType, error, id, limit, offset, query, filter, orderBy, }: ListRunsParams): Promise<Run[]>;
listRuns({ projectId, projectName, parentRunId, referenceExampleId, datasetId, startTime, endTime, executionOrder, runType, error, id, limit, offset, query, filter, orderBy, }: ListRunsParams): AsyncIterable<Run>;
deleteRun(runId: string): Promise<void>;

@@ -86,3 +87,3 @@ createProject({ projectName, projectExtra, upsert, }: {

}): Promise<TracerSessionResult>;
listProjects(): Promise<TracerSession[]>;
listProjects(): AsyncIterable<TracerSession>;
deleteProject({ projectId, projectName, }: {

@@ -104,3 +105,3 @@ projectId?: string;

offset?: number;
}): Promise<Dataset[]>;
}): AsyncIterable<Dataset>;
deleteDataset({ datasetId, datasetName, }: {

@@ -116,8 +117,6 @@ datasetId?: string;

readExample(exampleId: string): Promise<Example>;
listExamples({ datasetId, datasetName, limit, offset, }?: {
listExamples({ datasetId, datasetName, }?: {
datasetId?: string;
datasetName?: string;
limit?: number;
offset?: number;
}): Promise<Example[]>;
}): AsyncIterable<Example>;
deleteExample(exampleId: string): Promise<void>;

@@ -139,8 +138,6 @@ updateExample(exampleId: string, update: ExampleUpdate): Promise<object>;

deleteFeedback(feedbackId: string): Promise<void>;
listFeedback({ runIds, limit, offset, }?: {
listFeedback({ runIds, }?: {
runIds?: string[];
limit?: number;
offset?: number;
}): Promise<Feedback[]>;
}): AsyncIterable<Feedback>;
}
export {};

@@ -18,2 +18,9 @@ import * as uuid from "uuid";

};
async function toArray(iterable) {
const result = [];
for await (const item of iterable) {
result.push(item);
}
return result;
}
export class Client {

@@ -53,5 +60,8 @@ constructor(config = {}) {

static getDefaultClientConfig() {
const apiKey = getEnvironmentVariable("LANGCHAIN_API_KEY");
const apiUrl = getEnvironmentVariable("LANGCHAIN_ENDPOINT") ??
(apiKey ? "https://api.smith.langchain.com" : "http://localhost:1984");
return {
apiUrl: getEnvironmentVariable("LANGCHAIN_ENDPOINT") ?? "http://localhost:1984",
apiKey: getEnvironmentVariable("LANGCHAIN_API_KEY"),
apiUrl: apiUrl,
apiKey: apiKey,
};

@@ -85,2 +95,28 @@ }

}
async *_getPaginated(path, queryParams = new URLSearchParams()) {
let offset = Number(queryParams.get("offset")) || 0;
const limit = Number(queryParams.get("limit")) || 100;
while (true) {
queryParams.set("offset", String(offset));
queryParams.set("limit", String(limit));
const url = `${this.apiUrl}${path}?${queryParams}`;
const response = await this.caller.call(fetch, url, {
method: "GET",
headers: this.headers,
signal: AbortSignal.timeout(this.timeout_ms),
});
if (!response.ok) {
throw new Error(`Failed to fetch ${path}: ${response.status} ${response.statusText}`);
}
const items = await response.json();
if (items.length === 0) {
break;
}
yield items;
if (items.length < limit) {
break;
}
offset += items.length;
}
}
async createRun(run) {

@@ -129,3 +165,3 @@ const headers = { ...this.headers, "Content-Type": "application/json" };

async _loadChildRuns(run) {
const childRuns = await this.listRuns({ id: run.child_run_ids });
const childRuns = await toArray(this.listRuns({ id: run.child_run_ids }));
const treemap = {};

@@ -153,3 +189,3 @@ const runs = {};

}
async listRuns({ projectId, projectName, parentRunId, referenceExampleId, datasetId, startTime, endTime, executionOrder, runType, error, id, limit, offset, query, filter, orderBy, }) {
async *listRuns({ projectId, projectName, parentRunId, referenceExampleId, datasetId, startTime, endTime, executionOrder, runType, error, id, limit, offset, query, filter, orderBy, }) {
const queryParams = new URLSearchParams();

@@ -210,3 +246,5 @@ let projectId_ = projectId;

}
return this._get("/runs", queryParams);
for await (const runs of this._getPaginated("/runs", queryParams)) {
yield* runs;
}
}

@@ -270,4 +308,6 @@ async deleteRun(runId) {

}
async listProjects() {
return this._get("/sessions");
async *listProjects() {
for await (const projects of this._getPaginated("/sessions")) {
yield* projects;
}
}

@@ -383,3 +423,3 @@ async deleteProject({ projectId, projectName, }) {

}
async listDatasets({ limit = 100, offset = 0, } = {}) {
async *listDatasets({ limit = 100, offset = 0, } = {}) {
const path = "/datasets";

@@ -390,7 +430,5 @@ const params = new URLSearchParams({

});
const response = await this._get(path, params);
if (!Array.isArray(response)) {
throw new Error(`Expected ${path} to return an array, but got ${response}`);
for await (const datasets of this._getPaginated(path, params)) {
yield* datasets;
}
return response;
}

@@ -458,3 +496,3 @@ async deleteDataset({ datasetId, datasetName, }) {

}
async listExamples({ datasetId, datasetName, limit, offset, } = {}) {
async *listExamples({ datasetId, datasetName, } = {}) {
let datasetId_;

@@ -474,11 +512,6 @@ if (datasetId !== undefined && datasetName !== undefined) {

}
const response = await this._get("/examples", new URLSearchParams({
dataset: datasetId_,
limit: limit?.toString() ?? "100",
offset: offset?.toString() ?? "0",
}));
if (!Array.isArray(response)) {
throw new Error(`Expected /examples to return an array, but got ${response}`);
const params = new URLSearchParams({ dataset: datasetId_ });
for await (const examples of this._getPaginated("/examples", params)) {
yield* examples;
}
return response;
}

@@ -590,3 +623,3 @@ async deleteExample(exampleId) {

}
async listFeedback({ runIds, limit, offset, } = {}) {
async *listFeedback({ runIds, } = {}) {
const queryParams = new URLSearchParams();

@@ -596,11 +629,6 @@ if (runIds) {

}
if (limit !== undefined) {
queryParams.append("limit", limit.toString());
for await (const feedbacks of this._getPaginated("/feedback", queryParams)) {
yield* feedbacks;
}
if (offset !== undefined) {
queryParams.append("offset", offset.toString());
}
const response = await this._get("/feedback", queryParams);
return response;
}
}

@@ -32,3 +32,3 @@ import { BaseRun, KVMap, RunType } from "./schemas.js";

start_time: number;
end_time: number;
end_time?: number;
extra: KVMap;

@@ -35,0 +35,0 @@ error?: string;

@@ -130,3 +130,2 @@ import * as uuid from "uuid";

start_time: Date.now(),
end_time: Date.now(),
serialized: {},

@@ -133,0 +132,0 @@ inputs: {},

{
"name": "langsmith",
"version": "0.0.7",
"version": "0.0.8",
"description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",

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

@@ -17,3 +17,3 @@ # LangSmith Client SDK

1. Set up an account with LangSmith or host your [local server](https://docs.smith.langchain.com/docs/additional-resources/local_installation).
1. Set up an account with LangSmith.
2. Log traces.

@@ -28,3 +28,3 @@ 3. Debug, Create Datasets, and Evaluate Runs.

Then, create a unique API key on the [Settings Page](https://smith.langchain.com/settings), which is found in the menu at the top right corner of the page.
Then, create a unique API key on the [Settings Page](https://smith.langchain.com/settings).

@@ -216,4 +216,6 @@ Note: Save the API Key in a secure location. It will not be shown again.

You can run evaluations directly using the LangSmith client.
Check out the [LangSmith Testing & Evaluation dos](https://docs.smith.langchain.com/docs/evaluation/) for up-to-date workflows.
For generating automated feedback on individual runs, you can run evaluations directly using the LangSmith client.
```ts

@@ -220,0 +222,0 @@ import { StringEvaluator } from "langsmith/evaluation";

Sorry, the diff of this file is not supported yet

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