langchain 0.3.32 → 0.3.33
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/hub/node.cjs +26 -2
- package/dist/hub/node.js +26 -2
- package/package.json +1 -1
package/dist/hub/node.cjs
CHANGED
|
@@ -38,6 +38,27 @@ exports.pull = pull;
|
|
|
38
38
|
const base_js_1 = require("./base.cjs");
|
|
39
39
|
Object.defineProperty(exports, "push", { enumerable: true, get: function () { return base_js_1.basePush; } });
|
|
40
40
|
const index_js_1 = require("../load/index.cjs");
|
|
41
|
+
function _idEquals(a, b) {
|
|
42
|
+
if (!Array.isArray(a) || !Array.isArray(b)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
if (a.length !== b.length) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
for (let i = 0; i < a.length; i++) {
|
|
49
|
+
if (a[i] !== b[i]) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
function isRunnableBinding(a) {
|
|
56
|
+
const wellKnownIds = [
|
|
57
|
+
["langchain_core", "runnables", "RunnableBinding"],
|
|
58
|
+
["langchain", "schema", "runnable", "RunnableBinding"],
|
|
59
|
+
];
|
|
60
|
+
return wellKnownIds.some((id) => _idEquals(a, id));
|
|
61
|
+
}
|
|
41
62
|
/**
|
|
42
63
|
* Pull a prompt from the hub.
|
|
43
64
|
* @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.
|
|
@@ -52,8 +73,11 @@ async function pull(ownerRepoCommit, options) {
|
|
|
52
73
|
const promptObject = await (0, base_js_1.basePull)(ownerRepoCommit, options);
|
|
53
74
|
let modelClass;
|
|
54
75
|
if (options?.includeModel) {
|
|
55
|
-
|
|
56
|
-
|
|
76
|
+
const chatModelObject = isRunnableBinding(promptObject.manifest.kwargs?.last?.id)
|
|
77
|
+
? promptObject.manifest.kwargs?.last?.kwargs?.bound
|
|
78
|
+
: promptObject.manifest.kwargs?.last;
|
|
79
|
+
if (Array.isArray(chatModelObject?.id)) {
|
|
80
|
+
const modelName = chatModelObject?.id.at(-1);
|
|
57
81
|
if (modelName === "ChatOpenAI") {
|
|
58
82
|
modelClass = (await Promise.resolve().then(() => __importStar(require("@langchain/openai")))).ChatOpenAI;
|
|
59
83
|
}
|
package/dist/hub/node.js
CHANGED
|
@@ -2,6 +2,27 @@ import { basePush, basePull, generateModelImportMap, generateOptionalImportMap,
|
|
|
2
2
|
import { load } from "../load/index.js";
|
|
3
3
|
// TODO: Make this the default, add web entrypoint in next breaking release
|
|
4
4
|
export { basePush as push };
|
|
5
|
+
function _idEquals(a, b) {
|
|
6
|
+
if (!Array.isArray(a) || !Array.isArray(b)) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (a.length !== b.length) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
for (let i = 0; i < a.length; i++) {
|
|
13
|
+
if (a[i] !== b[i]) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
function isRunnableBinding(a) {
|
|
20
|
+
const wellKnownIds = [
|
|
21
|
+
["langchain_core", "runnables", "RunnableBinding"],
|
|
22
|
+
["langchain", "schema", "runnable", "RunnableBinding"],
|
|
23
|
+
];
|
|
24
|
+
return wellKnownIds.some((id) => _idEquals(a, id));
|
|
25
|
+
}
|
|
5
26
|
/**
|
|
6
27
|
* Pull a prompt from the hub.
|
|
7
28
|
* @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.
|
|
@@ -16,8 +37,11 @@ export async function pull(ownerRepoCommit, options) {
|
|
|
16
37
|
const promptObject = await basePull(ownerRepoCommit, options);
|
|
17
38
|
let modelClass;
|
|
18
39
|
if (options?.includeModel) {
|
|
19
|
-
|
|
20
|
-
|
|
40
|
+
const chatModelObject = isRunnableBinding(promptObject.manifest.kwargs?.last?.id)
|
|
41
|
+
? promptObject.manifest.kwargs?.last?.kwargs?.bound
|
|
42
|
+
: promptObject.manifest.kwargs?.last;
|
|
43
|
+
if (Array.isArray(chatModelObject?.id)) {
|
|
44
|
+
const modelName = chatModelObject?.id.at(-1);
|
|
21
45
|
if (modelName === "ChatOpenAI") {
|
|
22
46
|
modelClass = (await import("@langchain/openai")).ChatOpenAI;
|
|
23
47
|
}
|