langsmith 0.1.42 → 0.1.43
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/dist/client.cjs +77 -1
- package/dist/client.d.ts +33 -2
- package/dist/client.js +77 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/schemas.d.ts +3 -0
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -1354,7 +1354,7 @@ class Client {
|
|
|
1354
1354
|
const result = await response.json();
|
|
1355
1355
|
return result;
|
|
1356
1356
|
}
|
|
1357
|
-
async createDataset(name, { description, dataType, } = {}) {
|
|
1357
|
+
async createDataset(name, { description, dataType, inputsSchema, outputsSchema, } = {}) {
|
|
1358
1358
|
const body = {
|
|
1359
1359
|
name,
|
|
1360
1360
|
description,
|
|
@@ -1362,6 +1362,12 @@ class Client {
|
|
|
1362
1362
|
if (dataType) {
|
|
1363
1363
|
body.data_type = dataType;
|
|
1364
1364
|
}
|
|
1365
|
+
if (inputsSchema) {
|
|
1366
|
+
body.inputs_schema_definition = inputsSchema;
|
|
1367
|
+
}
|
|
1368
|
+
if (outputsSchema) {
|
|
1369
|
+
body.outputs_schema_definition = outputsSchema;
|
|
1370
|
+
}
|
|
1365
1371
|
const response = await this.caller.call(fetch, `${this.apiUrl}/datasets`, {
|
|
1366
1372
|
method: "POST",
|
|
1367
1373
|
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
@@ -1537,6 +1543,76 @@ class Client {
|
|
|
1537
1543
|
}
|
|
1538
1544
|
await response.json();
|
|
1539
1545
|
}
|
|
1546
|
+
async indexDataset({ datasetId, datasetName, tag, }) {
|
|
1547
|
+
let datasetId_ = datasetId;
|
|
1548
|
+
if (!datasetId_ && !datasetName) {
|
|
1549
|
+
throw new Error("Must provide either datasetName or datasetId");
|
|
1550
|
+
}
|
|
1551
|
+
else if (datasetId_ && datasetName) {
|
|
1552
|
+
throw new Error("Must provide either datasetName or datasetId, not both");
|
|
1553
|
+
}
|
|
1554
|
+
else if (!datasetId_) {
|
|
1555
|
+
const dataset = await this.readDataset({ datasetName });
|
|
1556
|
+
datasetId_ = dataset.id;
|
|
1557
|
+
}
|
|
1558
|
+
(0, _uuid_js_1.assertUuid)(datasetId_);
|
|
1559
|
+
const data = {
|
|
1560
|
+
tag: tag,
|
|
1561
|
+
};
|
|
1562
|
+
const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId_}/index`, {
|
|
1563
|
+
method: "POST",
|
|
1564
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
1565
|
+
body: JSON.stringify(data),
|
|
1566
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1567
|
+
...this.fetchOptions,
|
|
1568
|
+
});
|
|
1569
|
+
if (!response.ok) {
|
|
1570
|
+
throw new Error(`Failed to index dataset ${datasetId_}: ${response.status} ${response.statusText}`);
|
|
1571
|
+
}
|
|
1572
|
+
await response.json();
|
|
1573
|
+
}
|
|
1574
|
+
/**
|
|
1575
|
+
* Lets you run a similarity search query on a dataset.
|
|
1576
|
+
*
|
|
1577
|
+
* Requires the dataset to be indexed. Please see the `indexDataset` method to set up indexing.
|
|
1578
|
+
*
|
|
1579
|
+
* @param inputs The input on which to run the similarity search. Must have the
|
|
1580
|
+
* same schema as the dataset.
|
|
1581
|
+
*
|
|
1582
|
+
* @param datasetId The dataset to search for similar examples.
|
|
1583
|
+
*
|
|
1584
|
+
* @param limit The maximum number of examples to return. Will return the top `limit` most
|
|
1585
|
+
* similar examples in order of most similar to least similar. If no similar
|
|
1586
|
+
* examples are found, random examples will be returned.
|
|
1587
|
+
*
|
|
1588
|
+
* @returns A list of similar examples.
|
|
1589
|
+
*
|
|
1590
|
+
*
|
|
1591
|
+
* @example
|
|
1592
|
+
* dataset_id = "123e4567-e89b-12d3-a456-426614174000"
|
|
1593
|
+
* inputs = {"text": "How many people live in Berlin?"}
|
|
1594
|
+
* limit = 5
|
|
1595
|
+
* examples = await client.similarExamples(inputs, dataset_id, limit)
|
|
1596
|
+
*/
|
|
1597
|
+
async similarExamples(inputs, datasetId, limit) {
|
|
1598
|
+
const data = {
|
|
1599
|
+
limit: limit,
|
|
1600
|
+
inputs: inputs,
|
|
1601
|
+
};
|
|
1602
|
+
(0, _uuid_js_1.assertUuid)(datasetId);
|
|
1603
|
+
const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/search`, {
|
|
1604
|
+
method: "POST",
|
|
1605
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
1606
|
+
body: JSON.stringify(data),
|
|
1607
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1608
|
+
...this.fetchOptions,
|
|
1609
|
+
});
|
|
1610
|
+
if (!response.ok) {
|
|
1611
|
+
throw new Error(`Failed to fetch similar examples: ${response.status} ${response.statusText}`);
|
|
1612
|
+
}
|
|
1613
|
+
const result = await response.json();
|
|
1614
|
+
return result["examples"];
|
|
1615
|
+
}
|
|
1540
1616
|
async createExample(inputs, outputs, { datasetId, datasetName, createdAt, exampleId, metadata, split, }) {
|
|
1541
1617
|
let datasetId_ = datasetId;
|
|
1542
1618
|
if (datasetId_ === undefined && datasetName === undefined) {
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsyncCallerParams } from "./utils/async_caller.js";
|
|
2
|
-
import { ComparativeExperiment, DataType, Dataset, DatasetDiffInfo, DatasetShareSchema, Example, ExampleUpdate, ExampleUpdateWithId, Feedback, FeedbackConfig, FeedbackIngestToken, KVMap, LangChainBaseMessage, LangSmithSettings, LikePromptResponse, Prompt, PromptCommit, PromptSortField, Run, RunCreate, RunUpdate, ScoreType, TimeDelta, TracerSession, TracerSessionResult, ValueType } from "./schemas.js";
|
|
2
|
+
import { ComparativeExperiment, DataType, Dataset, DatasetDiffInfo, DatasetShareSchema, Example, ExampleUpdate, ExampleUpdateWithId, Feedback, FeedbackConfig, FeedbackIngestToken, KVMap, LangChainBaseMessage, LangSmithSettings, LikePromptResponse, Prompt, PromptCommit, PromptSortField, Run, RunCreate, RunUpdate, ScoreType, ExampleSearch, TimeDelta, TracerSession, TracerSessionResult, ValueType } from "./schemas.js";
|
|
3
3
|
import { EvaluationResult, EvaluationResults, RunEvaluator } from "./evaluation/evaluator.js";
|
|
4
4
|
interface ClientConfig {
|
|
5
5
|
apiUrl?: string;
|
|
@@ -379,9 +379,11 @@ export declare class Client {
|
|
|
379
379
|
projectName?: string;
|
|
380
380
|
}): Promise<void>;
|
|
381
381
|
uploadCsv({ csvFile, fileName, inputKeys, outputKeys, description, dataType, name, }: UploadCSVParams): Promise<Dataset>;
|
|
382
|
-
createDataset(name: string, { description, dataType, }?: {
|
|
382
|
+
createDataset(name: string, { description, dataType, inputsSchema, outputsSchema, }?: {
|
|
383
383
|
description?: string;
|
|
384
384
|
dataType?: DataType;
|
|
385
|
+
inputsSchema?: KVMap;
|
|
386
|
+
outputsSchema?: KVMap;
|
|
385
387
|
}): Promise<Dataset>;
|
|
386
388
|
readDataset({ datasetId, datasetName, }: {
|
|
387
389
|
datasetId?: string;
|
|
@@ -423,6 +425,35 @@ export declare class Client {
|
|
|
423
425
|
datasetId?: string;
|
|
424
426
|
datasetName?: string;
|
|
425
427
|
}): Promise<void>;
|
|
428
|
+
indexDataset({ datasetId, datasetName, tag, }: {
|
|
429
|
+
datasetId?: string;
|
|
430
|
+
datasetName?: string;
|
|
431
|
+
tag?: string;
|
|
432
|
+
}): Promise<void>;
|
|
433
|
+
/**
|
|
434
|
+
* Lets you run a similarity search query on a dataset.
|
|
435
|
+
*
|
|
436
|
+
* Requires the dataset to be indexed. Please see the `indexDataset` method to set up indexing.
|
|
437
|
+
*
|
|
438
|
+
* @param inputs The input on which to run the similarity search. Must have the
|
|
439
|
+
* same schema as the dataset.
|
|
440
|
+
*
|
|
441
|
+
* @param datasetId The dataset to search for similar examples.
|
|
442
|
+
*
|
|
443
|
+
* @param limit The maximum number of examples to return. Will return the top `limit` most
|
|
444
|
+
* similar examples in order of most similar to least similar. If no similar
|
|
445
|
+
* examples are found, random examples will be returned.
|
|
446
|
+
*
|
|
447
|
+
* @returns A list of similar examples.
|
|
448
|
+
*
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* dataset_id = "123e4567-e89b-12d3-a456-426614174000"
|
|
452
|
+
* inputs = {"text": "How many people live in Berlin?"}
|
|
453
|
+
* limit = 5
|
|
454
|
+
* examples = await client.similarExamples(inputs, dataset_id, limit)
|
|
455
|
+
*/
|
|
456
|
+
similarExamples(inputs: KVMap, datasetId: string, limit: number): Promise<ExampleSearch[]>;
|
|
426
457
|
createExample(inputs: KVMap, outputs: KVMap, { datasetId, datasetName, createdAt, exampleId, metadata, split, }: CreateExampleOptions): Promise<Example>;
|
|
427
458
|
createExamples(props: {
|
|
428
459
|
inputs: Array<KVMap>;
|
package/dist/client.js
CHANGED
|
@@ -1327,7 +1327,7 @@ export class Client {
|
|
|
1327
1327
|
const result = await response.json();
|
|
1328
1328
|
return result;
|
|
1329
1329
|
}
|
|
1330
|
-
async createDataset(name, { description, dataType, } = {}) {
|
|
1330
|
+
async createDataset(name, { description, dataType, inputsSchema, outputsSchema, } = {}) {
|
|
1331
1331
|
const body = {
|
|
1332
1332
|
name,
|
|
1333
1333
|
description,
|
|
@@ -1335,6 +1335,12 @@ export class Client {
|
|
|
1335
1335
|
if (dataType) {
|
|
1336
1336
|
body.data_type = dataType;
|
|
1337
1337
|
}
|
|
1338
|
+
if (inputsSchema) {
|
|
1339
|
+
body.inputs_schema_definition = inputsSchema;
|
|
1340
|
+
}
|
|
1341
|
+
if (outputsSchema) {
|
|
1342
|
+
body.outputs_schema_definition = outputsSchema;
|
|
1343
|
+
}
|
|
1338
1344
|
const response = await this.caller.call(fetch, `${this.apiUrl}/datasets`, {
|
|
1339
1345
|
method: "POST",
|
|
1340
1346
|
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
@@ -1510,6 +1516,76 @@ export class Client {
|
|
|
1510
1516
|
}
|
|
1511
1517
|
await response.json();
|
|
1512
1518
|
}
|
|
1519
|
+
async indexDataset({ datasetId, datasetName, tag, }) {
|
|
1520
|
+
let datasetId_ = datasetId;
|
|
1521
|
+
if (!datasetId_ && !datasetName) {
|
|
1522
|
+
throw new Error("Must provide either datasetName or datasetId");
|
|
1523
|
+
}
|
|
1524
|
+
else if (datasetId_ && datasetName) {
|
|
1525
|
+
throw new Error("Must provide either datasetName or datasetId, not both");
|
|
1526
|
+
}
|
|
1527
|
+
else if (!datasetId_) {
|
|
1528
|
+
const dataset = await this.readDataset({ datasetName });
|
|
1529
|
+
datasetId_ = dataset.id;
|
|
1530
|
+
}
|
|
1531
|
+
assertUuid(datasetId_);
|
|
1532
|
+
const data = {
|
|
1533
|
+
tag: tag,
|
|
1534
|
+
};
|
|
1535
|
+
const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId_}/index`, {
|
|
1536
|
+
method: "POST",
|
|
1537
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
1538
|
+
body: JSON.stringify(data),
|
|
1539
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1540
|
+
...this.fetchOptions,
|
|
1541
|
+
});
|
|
1542
|
+
if (!response.ok) {
|
|
1543
|
+
throw new Error(`Failed to index dataset ${datasetId_}: ${response.status} ${response.statusText}`);
|
|
1544
|
+
}
|
|
1545
|
+
await response.json();
|
|
1546
|
+
}
|
|
1547
|
+
/**
|
|
1548
|
+
* Lets you run a similarity search query on a dataset.
|
|
1549
|
+
*
|
|
1550
|
+
* Requires the dataset to be indexed. Please see the `indexDataset` method to set up indexing.
|
|
1551
|
+
*
|
|
1552
|
+
* @param inputs The input on which to run the similarity search. Must have the
|
|
1553
|
+
* same schema as the dataset.
|
|
1554
|
+
*
|
|
1555
|
+
* @param datasetId The dataset to search for similar examples.
|
|
1556
|
+
*
|
|
1557
|
+
* @param limit The maximum number of examples to return. Will return the top `limit` most
|
|
1558
|
+
* similar examples in order of most similar to least similar. If no similar
|
|
1559
|
+
* examples are found, random examples will be returned.
|
|
1560
|
+
*
|
|
1561
|
+
* @returns A list of similar examples.
|
|
1562
|
+
*
|
|
1563
|
+
*
|
|
1564
|
+
* @example
|
|
1565
|
+
* dataset_id = "123e4567-e89b-12d3-a456-426614174000"
|
|
1566
|
+
* inputs = {"text": "How many people live in Berlin?"}
|
|
1567
|
+
* limit = 5
|
|
1568
|
+
* examples = await client.similarExamples(inputs, dataset_id, limit)
|
|
1569
|
+
*/
|
|
1570
|
+
async similarExamples(inputs, datasetId, limit) {
|
|
1571
|
+
const data = {
|
|
1572
|
+
limit: limit,
|
|
1573
|
+
inputs: inputs,
|
|
1574
|
+
};
|
|
1575
|
+
assertUuid(datasetId);
|
|
1576
|
+
const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/search`, {
|
|
1577
|
+
method: "POST",
|
|
1578
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
1579
|
+
body: JSON.stringify(data),
|
|
1580
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1581
|
+
...this.fetchOptions,
|
|
1582
|
+
});
|
|
1583
|
+
if (!response.ok) {
|
|
1584
|
+
throw new Error(`Failed to fetch similar examples: ${response.status} ${response.statusText}`);
|
|
1585
|
+
}
|
|
1586
|
+
const result = await response.json();
|
|
1587
|
+
return result["examples"];
|
|
1588
|
+
}
|
|
1513
1589
|
async createExample(inputs, outputs, { datasetId, datasetName, createdAt, exampleId, metadata, split, }) {
|
|
1514
1590
|
let datasetId_ = datasetId;
|
|
1515
1591
|
if (datasetId_ === undefined && datasetName === undefined) {
|
package/dist/index.cjs
CHANGED
|
@@ -6,4 +6,4 @@ Object.defineProperty(exports, "Client", { enumerable: true, get: function () {
|
|
|
6
6
|
var run_trees_js_1 = require("./run_trees.cjs");
|
|
7
7
|
Object.defineProperty(exports, "RunTree", { enumerable: true, get: function () { return run_trees_js_1.RunTree; } });
|
|
8
8
|
// Update using yarn bump-version
|
|
9
|
-
exports.__version__ = "0.1.
|
|
9
|
+
exports.__version__ = "0.1.43";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Client } from "./client.js";
|
|
2
2
|
export type { Dataset, Example, TracerSession, Run, Feedback, RetrieverOutput, } from "./schemas.js";
|
|
3
3
|
export { RunTree, type RunTreeConfig } from "./run_trees.js";
|
|
4
|
-
export declare const __version__ = "0.1.
|
|
4
|
+
export declare const __version__ = "0.1.43";
|
package/dist/index.js
CHANGED
package/dist/schemas.d.ts
CHANGED
|
@@ -181,6 +181,9 @@ export interface ExampleUpdate {
|
|
|
181
181
|
export interface ExampleUpdateWithId extends ExampleUpdate {
|
|
182
182
|
id: string;
|
|
183
183
|
}
|
|
184
|
+
export interface ExampleSearch extends BaseExample {
|
|
185
|
+
id: string;
|
|
186
|
+
}
|
|
184
187
|
export interface BaseDataset {
|
|
185
188
|
name: string;
|
|
186
189
|
description: string;
|