@langchain/core 0.2.27 → 0.2.28
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/document_loaders/langsmith.cjs +198 -0
- package/dist/document_loaders/langsmith.d.ts +96 -0
- package/dist/document_loaders/langsmith.js +194 -0
- package/dist/messages/utils.cjs +8 -0
- package/dist/messages/utils.js +8 -0
- package/dist/tools/index.d.ts +5 -0
- package/document_loaders/langsmith.cjs +1 -0
- package/document_loaders/langsmith.d.cts +1 -0
- package/document_loaders/langsmith.d.ts +1 -0
- package/document_loaders/langsmith.js +1 -0
- package/package.json +15 -2
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LangSmithLoader = void 0;
|
|
4
|
+
const langsmith_1 = require("langsmith");
|
|
5
|
+
const base_js_1 = require("./base.cjs");
|
|
6
|
+
/**
|
|
7
|
+
* Document loader integration with LangSmith.
|
|
8
|
+
*
|
|
9
|
+
* ## [Constructor args](https://api.js.langchain.com/interfaces/_langchain_core.document_loaders_langsmith.LangSmithLoaderFields.html)
|
|
10
|
+
*
|
|
11
|
+
* <details open>
|
|
12
|
+
* <summary><strong>Load</strong></summary>
|
|
13
|
+
*
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { LangSmithLoader } from '@langchain/core/document_loaders/langsmith';
|
|
16
|
+
* import { Client } from 'langsmith';
|
|
17
|
+
*
|
|
18
|
+
* const langSmithClient = new Client({
|
|
19
|
+
* apiKey: process.env.LANGSMITH_API_KEY,
|
|
20
|
+
* })
|
|
21
|
+
*
|
|
22
|
+
* const loader = new LangSmithLoader({
|
|
23
|
+
* datasetId: "9a3b36f7-b308-40a5-9b46-6613853b6330",
|
|
24
|
+
* limit: 1,
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* const docs = await loader.load();
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* ```txt
|
|
31
|
+
* [
|
|
32
|
+
* {
|
|
33
|
+
* pageContent: '{\n "input_key_str": "string",\n "input_key_bool": true\n}',
|
|
34
|
+
* metadata: {
|
|
35
|
+
* id: '8523d9e9-c123-4b23-9b46-21021nds289e',
|
|
36
|
+
* created_at: '2024-08-19T17:09:14.806441+00:00',
|
|
37
|
+
* modified_at: '2024-08-19T17:09:14.806441+00:00',
|
|
38
|
+
* name: '#8517 @ brace-test-dataset',
|
|
39
|
+
* dataset_id: '9a3b36f7-b308-40a5-9b46-6613853b6330',
|
|
40
|
+
* source_run_id: null,
|
|
41
|
+
* metadata: [Object],
|
|
42
|
+
* inputs: [Object],
|
|
43
|
+
* outputs: [Object]
|
|
44
|
+
* }
|
|
45
|
+
* }
|
|
46
|
+
* ]
|
|
47
|
+
* ```
|
|
48
|
+
* </details>
|
|
49
|
+
*/
|
|
50
|
+
class LangSmithLoader extends base_js_1.BaseDocumentLoader {
|
|
51
|
+
constructor(fields) {
|
|
52
|
+
super();
|
|
53
|
+
Object.defineProperty(this, "datasetId", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
configurable: true,
|
|
56
|
+
writable: true,
|
|
57
|
+
value: void 0
|
|
58
|
+
});
|
|
59
|
+
Object.defineProperty(this, "datasetName", {
|
|
60
|
+
enumerable: true,
|
|
61
|
+
configurable: true,
|
|
62
|
+
writable: true,
|
|
63
|
+
value: void 0
|
|
64
|
+
});
|
|
65
|
+
Object.defineProperty(this, "exampleIds", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
configurable: true,
|
|
68
|
+
writable: true,
|
|
69
|
+
value: void 0
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(this, "asOf", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
configurable: true,
|
|
74
|
+
writable: true,
|
|
75
|
+
value: void 0
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(this, "splits", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
configurable: true,
|
|
80
|
+
writable: true,
|
|
81
|
+
value: void 0
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(this, "inlineS3Urls", {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
configurable: true,
|
|
86
|
+
writable: true,
|
|
87
|
+
value: void 0
|
|
88
|
+
});
|
|
89
|
+
Object.defineProperty(this, "offset", {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
configurable: true,
|
|
92
|
+
writable: true,
|
|
93
|
+
value: void 0
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(this, "limit", {
|
|
96
|
+
enumerable: true,
|
|
97
|
+
configurable: true,
|
|
98
|
+
writable: true,
|
|
99
|
+
value: void 0
|
|
100
|
+
});
|
|
101
|
+
Object.defineProperty(this, "metadata", {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
configurable: true,
|
|
104
|
+
writable: true,
|
|
105
|
+
value: void 0
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(this, "filter", {
|
|
108
|
+
enumerable: true,
|
|
109
|
+
configurable: true,
|
|
110
|
+
writable: true,
|
|
111
|
+
value: void 0
|
|
112
|
+
});
|
|
113
|
+
Object.defineProperty(this, "contentKey", {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
configurable: true,
|
|
116
|
+
writable: true,
|
|
117
|
+
value: void 0
|
|
118
|
+
});
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
+
Object.defineProperty(this, "formatContent", {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
configurable: true,
|
|
123
|
+
writable: true,
|
|
124
|
+
value: void 0
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperty(this, "client", {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
configurable: true,
|
|
129
|
+
writable: true,
|
|
130
|
+
value: void 0
|
|
131
|
+
});
|
|
132
|
+
if (fields.client && fields.clientConfig) {
|
|
133
|
+
throw new Error("client and clientConfig cannot both be provided.");
|
|
134
|
+
}
|
|
135
|
+
this.client = fields.client ?? new langsmith_1.Client(fields?.clientConfig);
|
|
136
|
+
this.contentKey = fields.contentKey ? fields.contentKey.split(".") : [];
|
|
137
|
+
this.formatContent = fields.formatContent ?? _stringify;
|
|
138
|
+
this.datasetId = fields.datasetId;
|
|
139
|
+
this.datasetName = fields.datasetName;
|
|
140
|
+
this.exampleIds = fields.exampleIds;
|
|
141
|
+
this.asOf = fields.asOf;
|
|
142
|
+
this.splits = fields.splits;
|
|
143
|
+
this.inlineS3Urls = fields.inlineS3Urls;
|
|
144
|
+
this.offset = fields.offset;
|
|
145
|
+
this.limit = fields.limit;
|
|
146
|
+
this.metadata = fields.metadata;
|
|
147
|
+
this.filter = fields.filter;
|
|
148
|
+
}
|
|
149
|
+
async load() {
|
|
150
|
+
const documents = [];
|
|
151
|
+
for await (const example of this.client.listExamples({
|
|
152
|
+
datasetId: this.datasetId,
|
|
153
|
+
datasetName: this.datasetName,
|
|
154
|
+
exampleIds: this.exampleIds,
|
|
155
|
+
asOf: this.asOf,
|
|
156
|
+
splits: this.splits,
|
|
157
|
+
inlineS3Urls: this.inlineS3Urls,
|
|
158
|
+
offset: this.offset,
|
|
159
|
+
limit: this.limit,
|
|
160
|
+
metadata: this.metadata,
|
|
161
|
+
filter: this.filter,
|
|
162
|
+
})) {
|
|
163
|
+
let content = example.inputs;
|
|
164
|
+
for (const key of this.contentKey) {
|
|
165
|
+
content = content[key];
|
|
166
|
+
}
|
|
167
|
+
const contentStr = this.formatContent(content);
|
|
168
|
+
const metadata = example;
|
|
169
|
+
["created_at", "modified_at"].forEach((k) => {
|
|
170
|
+
if (k in metadata) {
|
|
171
|
+
if (typeof metadata[k] === "object") {
|
|
172
|
+
// Dates are of type `object`, we want to convert them to strings.
|
|
173
|
+
metadata[k] = metadata[k].toString();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
documents.push({
|
|
178
|
+
pageContent: contentStr,
|
|
179
|
+
metadata,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
return documents;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
exports.LangSmithLoader = LangSmithLoader;
|
|
186
|
+
function _stringify(x) {
|
|
187
|
+
if (typeof x === "string") {
|
|
188
|
+
return x;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
try {
|
|
192
|
+
return JSON.stringify(x, null, 2);
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
return String(x);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { KVMap } from "langsmith/schemas";
|
|
2
|
+
import { Client } from "langsmith";
|
|
3
|
+
import { Document } from "../documents/document.js";
|
|
4
|
+
import { AsyncCallerParams } from "../utils/async_caller.js";
|
|
5
|
+
import { BaseDocumentLoader } from "./base.js";
|
|
6
|
+
interface ClientConfig {
|
|
7
|
+
apiUrl?: string;
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
callerOptions?: AsyncCallerParams;
|
|
10
|
+
timeout_ms?: number;
|
|
11
|
+
webUrl?: string;
|
|
12
|
+
anonymizer?: (values: KVMap) => KVMap;
|
|
13
|
+
hideInputs?: boolean | ((inputs: KVMap) => KVMap);
|
|
14
|
+
hideOutputs?: boolean | ((outputs: KVMap) => KVMap);
|
|
15
|
+
autoBatchTracing?: boolean;
|
|
16
|
+
pendingAutoBatchedRunLimit?: number;
|
|
17
|
+
fetchOptions?: RequestInit;
|
|
18
|
+
}
|
|
19
|
+
export interface LangSmithLoaderFields {
|
|
20
|
+
datasetId?: string;
|
|
21
|
+
datasetName?: string;
|
|
22
|
+
exampleIds?: Array<string>;
|
|
23
|
+
asOf?: Date | string;
|
|
24
|
+
splits?: string[];
|
|
25
|
+
inlineS3Urls?: boolean;
|
|
26
|
+
offset?: number;
|
|
27
|
+
limit?: number;
|
|
28
|
+
metadata?: KVMap;
|
|
29
|
+
filter?: string;
|
|
30
|
+
contentKey?: string;
|
|
31
|
+
formatContent?: (content: any) => string;
|
|
32
|
+
client?: Client;
|
|
33
|
+
clientConfig?: ClientConfig;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Document loader integration with LangSmith.
|
|
37
|
+
*
|
|
38
|
+
* ## [Constructor args](https://api.js.langchain.com/interfaces/_langchain_core.document_loaders_langsmith.LangSmithLoaderFields.html)
|
|
39
|
+
*
|
|
40
|
+
* <details open>
|
|
41
|
+
* <summary><strong>Load</strong></summary>
|
|
42
|
+
*
|
|
43
|
+
* ```typescript
|
|
44
|
+
* import { LangSmithLoader } from '@langchain/core/document_loaders/langsmith';
|
|
45
|
+
* import { Client } from 'langsmith';
|
|
46
|
+
*
|
|
47
|
+
* const langSmithClient = new Client({
|
|
48
|
+
* apiKey: process.env.LANGSMITH_API_KEY,
|
|
49
|
+
* })
|
|
50
|
+
*
|
|
51
|
+
* const loader = new LangSmithLoader({
|
|
52
|
+
* datasetId: "9a3b36f7-b308-40a5-9b46-6613853b6330",
|
|
53
|
+
* limit: 1,
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* const docs = await loader.load();
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* ```txt
|
|
60
|
+
* [
|
|
61
|
+
* {
|
|
62
|
+
* pageContent: '{\n "input_key_str": "string",\n "input_key_bool": true\n}',
|
|
63
|
+
* metadata: {
|
|
64
|
+
* id: '8523d9e9-c123-4b23-9b46-21021nds289e',
|
|
65
|
+
* created_at: '2024-08-19T17:09:14.806441+00:00',
|
|
66
|
+
* modified_at: '2024-08-19T17:09:14.806441+00:00',
|
|
67
|
+
* name: '#8517 @ brace-test-dataset',
|
|
68
|
+
* dataset_id: '9a3b36f7-b308-40a5-9b46-6613853b6330',
|
|
69
|
+
* source_run_id: null,
|
|
70
|
+
* metadata: [Object],
|
|
71
|
+
* inputs: [Object],
|
|
72
|
+
* outputs: [Object]
|
|
73
|
+
* }
|
|
74
|
+
* }
|
|
75
|
+
* ]
|
|
76
|
+
* ```
|
|
77
|
+
* </details>
|
|
78
|
+
*/
|
|
79
|
+
export declare class LangSmithLoader extends BaseDocumentLoader {
|
|
80
|
+
datasetId?: string;
|
|
81
|
+
datasetName?: string;
|
|
82
|
+
exampleIds?: Array<string>;
|
|
83
|
+
asOf?: Date | string;
|
|
84
|
+
splits?: string[];
|
|
85
|
+
inlineS3Urls?: boolean;
|
|
86
|
+
offset?: number;
|
|
87
|
+
limit?: number;
|
|
88
|
+
metadata?: KVMap;
|
|
89
|
+
filter?: string;
|
|
90
|
+
contentKey: string[];
|
|
91
|
+
formatContent: (content: any) => string;
|
|
92
|
+
client: Client;
|
|
93
|
+
constructor(fields: LangSmithLoaderFields);
|
|
94
|
+
load(): Promise<Document[]>;
|
|
95
|
+
}
|
|
96
|
+
export {};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { Client } from "langsmith";
|
|
2
|
+
import { BaseDocumentLoader } from "./base.js";
|
|
3
|
+
/**
|
|
4
|
+
* Document loader integration with LangSmith.
|
|
5
|
+
*
|
|
6
|
+
* ## [Constructor args](https://api.js.langchain.com/interfaces/_langchain_core.document_loaders_langsmith.LangSmithLoaderFields.html)
|
|
7
|
+
*
|
|
8
|
+
* <details open>
|
|
9
|
+
* <summary><strong>Load</strong></summary>
|
|
10
|
+
*
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { LangSmithLoader } from '@langchain/core/document_loaders/langsmith';
|
|
13
|
+
* import { Client } from 'langsmith';
|
|
14
|
+
*
|
|
15
|
+
* const langSmithClient = new Client({
|
|
16
|
+
* apiKey: process.env.LANGSMITH_API_KEY,
|
|
17
|
+
* })
|
|
18
|
+
*
|
|
19
|
+
* const loader = new LangSmithLoader({
|
|
20
|
+
* datasetId: "9a3b36f7-b308-40a5-9b46-6613853b6330",
|
|
21
|
+
* limit: 1,
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* const docs = await loader.load();
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* ```txt
|
|
28
|
+
* [
|
|
29
|
+
* {
|
|
30
|
+
* pageContent: '{\n "input_key_str": "string",\n "input_key_bool": true\n}',
|
|
31
|
+
* metadata: {
|
|
32
|
+
* id: '8523d9e9-c123-4b23-9b46-21021nds289e',
|
|
33
|
+
* created_at: '2024-08-19T17:09:14.806441+00:00',
|
|
34
|
+
* modified_at: '2024-08-19T17:09:14.806441+00:00',
|
|
35
|
+
* name: '#8517 @ brace-test-dataset',
|
|
36
|
+
* dataset_id: '9a3b36f7-b308-40a5-9b46-6613853b6330',
|
|
37
|
+
* source_run_id: null,
|
|
38
|
+
* metadata: [Object],
|
|
39
|
+
* inputs: [Object],
|
|
40
|
+
* outputs: [Object]
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ]
|
|
44
|
+
* ```
|
|
45
|
+
* </details>
|
|
46
|
+
*/
|
|
47
|
+
export class LangSmithLoader extends BaseDocumentLoader {
|
|
48
|
+
constructor(fields) {
|
|
49
|
+
super();
|
|
50
|
+
Object.defineProperty(this, "datasetId", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true,
|
|
54
|
+
value: void 0
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(this, "datasetName", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
configurable: true,
|
|
59
|
+
writable: true,
|
|
60
|
+
value: void 0
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(this, "exampleIds", {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
configurable: true,
|
|
65
|
+
writable: true,
|
|
66
|
+
value: void 0
|
|
67
|
+
});
|
|
68
|
+
Object.defineProperty(this, "asOf", {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
configurable: true,
|
|
71
|
+
writable: true,
|
|
72
|
+
value: void 0
|
|
73
|
+
});
|
|
74
|
+
Object.defineProperty(this, "splits", {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
configurable: true,
|
|
77
|
+
writable: true,
|
|
78
|
+
value: void 0
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(this, "inlineS3Urls", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
configurable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
value: void 0
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(this, "offset", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
configurable: true,
|
|
89
|
+
writable: true,
|
|
90
|
+
value: void 0
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(this, "limit", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
configurable: true,
|
|
95
|
+
writable: true,
|
|
96
|
+
value: void 0
|
|
97
|
+
});
|
|
98
|
+
Object.defineProperty(this, "metadata", {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
configurable: true,
|
|
101
|
+
writable: true,
|
|
102
|
+
value: void 0
|
|
103
|
+
});
|
|
104
|
+
Object.defineProperty(this, "filter", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
configurable: true,
|
|
107
|
+
writable: true,
|
|
108
|
+
value: void 0
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(this, "contentKey", {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
configurable: true,
|
|
113
|
+
writable: true,
|
|
114
|
+
value: void 0
|
|
115
|
+
});
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
117
|
+
Object.defineProperty(this, "formatContent", {
|
|
118
|
+
enumerable: true,
|
|
119
|
+
configurable: true,
|
|
120
|
+
writable: true,
|
|
121
|
+
value: void 0
|
|
122
|
+
});
|
|
123
|
+
Object.defineProperty(this, "client", {
|
|
124
|
+
enumerable: true,
|
|
125
|
+
configurable: true,
|
|
126
|
+
writable: true,
|
|
127
|
+
value: void 0
|
|
128
|
+
});
|
|
129
|
+
if (fields.client && fields.clientConfig) {
|
|
130
|
+
throw new Error("client and clientConfig cannot both be provided.");
|
|
131
|
+
}
|
|
132
|
+
this.client = fields.client ?? new Client(fields?.clientConfig);
|
|
133
|
+
this.contentKey = fields.contentKey ? fields.contentKey.split(".") : [];
|
|
134
|
+
this.formatContent = fields.formatContent ?? _stringify;
|
|
135
|
+
this.datasetId = fields.datasetId;
|
|
136
|
+
this.datasetName = fields.datasetName;
|
|
137
|
+
this.exampleIds = fields.exampleIds;
|
|
138
|
+
this.asOf = fields.asOf;
|
|
139
|
+
this.splits = fields.splits;
|
|
140
|
+
this.inlineS3Urls = fields.inlineS3Urls;
|
|
141
|
+
this.offset = fields.offset;
|
|
142
|
+
this.limit = fields.limit;
|
|
143
|
+
this.metadata = fields.metadata;
|
|
144
|
+
this.filter = fields.filter;
|
|
145
|
+
}
|
|
146
|
+
async load() {
|
|
147
|
+
const documents = [];
|
|
148
|
+
for await (const example of this.client.listExamples({
|
|
149
|
+
datasetId: this.datasetId,
|
|
150
|
+
datasetName: this.datasetName,
|
|
151
|
+
exampleIds: this.exampleIds,
|
|
152
|
+
asOf: this.asOf,
|
|
153
|
+
splits: this.splits,
|
|
154
|
+
inlineS3Urls: this.inlineS3Urls,
|
|
155
|
+
offset: this.offset,
|
|
156
|
+
limit: this.limit,
|
|
157
|
+
metadata: this.metadata,
|
|
158
|
+
filter: this.filter,
|
|
159
|
+
})) {
|
|
160
|
+
let content = example.inputs;
|
|
161
|
+
for (const key of this.contentKey) {
|
|
162
|
+
content = content[key];
|
|
163
|
+
}
|
|
164
|
+
const contentStr = this.formatContent(content);
|
|
165
|
+
const metadata = example;
|
|
166
|
+
["created_at", "modified_at"].forEach((k) => {
|
|
167
|
+
if (k in metadata) {
|
|
168
|
+
if (typeof metadata[k] === "object") {
|
|
169
|
+
// Dates are of type `object`, we want to convert them to strings.
|
|
170
|
+
metadata[k] = metadata[k].toString();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
documents.push({
|
|
175
|
+
pageContent: contentStr,
|
|
176
|
+
metadata,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
return documents;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function _stringify(x) {
|
|
183
|
+
if (typeof x === "string") {
|
|
184
|
+
return x;
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
try {
|
|
188
|
+
return JSON.stringify(x, null, 2);
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
return String(x);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
package/dist/messages/utils.cjs
CHANGED
|
@@ -19,6 +19,14 @@ function _constructMessageFromParams(params) {
|
|
|
19
19
|
else if (type === "system") {
|
|
20
20
|
return new system_js_1.SystemMessage(rest);
|
|
21
21
|
}
|
|
22
|
+
else if (type === "tool" && "tool_call_id" in rest) {
|
|
23
|
+
return new tool_js_1.ToolMessage({
|
|
24
|
+
...rest,
|
|
25
|
+
content: rest.content,
|
|
26
|
+
tool_call_id: rest.tool_call_id,
|
|
27
|
+
name: rest.name,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
22
30
|
else {
|
|
23
31
|
throw new Error(`Unable to coerce message from array: only human, AI, or system message coercion is currently supported.`);
|
|
24
32
|
}
|
package/dist/messages/utils.js
CHANGED
|
@@ -16,6 +16,14 @@ function _constructMessageFromParams(params) {
|
|
|
16
16
|
else if (type === "system") {
|
|
17
17
|
return new SystemMessage(rest);
|
|
18
18
|
}
|
|
19
|
+
else if (type === "tool" && "tool_call_id" in rest) {
|
|
20
|
+
return new ToolMessage({
|
|
21
|
+
...rest,
|
|
22
|
+
content: rest.content,
|
|
23
|
+
tool_call_id: rest.tool_call_id,
|
|
24
|
+
name: rest.name,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
19
27
|
else {
|
|
20
28
|
throw new Error(`Unable to coerce message from array: only human, AI, or system message coercion is currently supported.`);
|
|
21
29
|
}
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -26,6 +26,11 @@ export interface ToolParams extends BaseLangChainParams {
|
|
|
26
26
|
*/
|
|
27
27
|
responseFormat?: ResponseFormat;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Schema for defining tools.
|
|
31
|
+
*
|
|
32
|
+
* @version 0.2.19
|
|
33
|
+
*/
|
|
29
34
|
export interface StructuredToolParams extends Pick<StructuredToolInterface, "name" | "schema"> {
|
|
30
35
|
/**
|
|
31
36
|
* An optional description of the tool to pass to the model.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('../dist/document_loaders/langsmith.cjs');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/document_loaders/langsmith.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/document_loaders/langsmith.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/document_loaders/langsmith.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/core",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.28",
|
|
4
4
|
"description": "Core LangChain.js abstractions and schemas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"camelcase": "6",
|
|
46
46
|
"decamelize": "1.2.0",
|
|
47
47
|
"js-tiktoken": "^1.0.12",
|
|
48
|
-
"langsmith": "
|
|
48
|
+
"langsmith": "^0.1.43",
|
|
49
49
|
"mustache": "^4.2.0",
|
|
50
50
|
"p-queue": "^6.6.2",
|
|
51
51
|
"p-retry": "4",
|
|
@@ -186,6 +186,15 @@
|
|
|
186
186
|
"import": "./document_loaders/base.js",
|
|
187
187
|
"require": "./document_loaders/base.cjs"
|
|
188
188
|
},
|
|
189
|
+
"./document_loaders/langsmith": {
|
|
190
|
+
"types": {
|
|
191
|
+
"import": "./document_loaders/langsmith.d.ts",
|
|
192
|
+
"require": "./document_loaders/langsmith.d.cts",
|
|
193
|
+
"default": "./document_loaders/langsmith.d.ts"
|
|
194
|
+
},
|
|
195
|
+
"import": "./document_loaders/langsmith.js",
|
|
196
|
+
"require": "./document_loaders/langsmith.cjs"
|
|
197
|
+
},
|
|
189
198
|
"./embeddings": {
|
|
190
199
|
"types": {
|
|
191
200
|
"import": "./embeddings.d.ts",
|
|
@@ -653,6 +662,10 @@
|
|
|
653
662
|
"document_loaders/base.js",
|
|
654
663
|
"document_loaders/base.d.ts",
|
|
655
664
|
"document_loaders/base.d.cts",
|
|
665
|
+
"document_loaders/langsmith.cjs",
|
|
666
|
+
"document_loaders/langsmith.js",
|
|
667
|
+
"document_loaders/langsmith.d.ts",
|
|
668
|
+
"document_loaders/langsmith.d.cts",
|
|
656
669
|
"embeddings.cjs",
|
|
657
670
|
"embeddings.js",
|
|
658
671
|
"embeddings.d.ts",
|