langchain 0.3.14 → 0.3.15
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/base.cjs +28 -5
- package/dist/hub/base.d.ts +1 -0
- package/dist/hub/base.js +26 -4
- package/dist/hub/index.cjs +1 -1
- package/dist/hub/index.js +2 -2
- package/dist/hub/node.cjs +1 -1
- package/dist/hub/node.js +2 -2
- package/package.json +1 -1
package/dist/hub/base.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateModelImportMap = exports.basePull = exports.basePush = void 0;
|
|
3
|
+
exports.generateOptionalImportMap = exports.generateModelImportMap = exports.basePull = exports.basePush = void 0;
|
|
4
4
|
const langsmith_1 = require("langsmith");
|
|
5
5
|
/**
|
|
6
6
|
* Push a prompt to the hub.
|
|
@@ -70,10 +70,6 @@ function generateModelImportMap(
|
|
|
70
70
|
modelClass) {
|
|
71
71
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
72
|
const modelImportMap = {};
|
|
73
|
-
// TODO: Fix in 0.4.0. We can't get lc_id without instantiating the class, so we
|
|
74
|
-
// must put them inline here. In the future, make this less hacky
|
|
75
|
-
// This should probably use dynamic imports and have a web-only entrypoint
|
|
76
|
-
// in a future breaking release
|
|
77
73
|
if (modelClass !== undefined) {
|
|
78
74
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
79
75
|
const modelLcName = modelClass?.lc_name();
|
|
@@ -113,3 +109,30 @@ modelClass) {
|
|
|
113
109
|
return modelImportMap;
|
|
114
110
|
}
|
|
115
111
|
exports.generateModelImportMap = generateModelImportMap;
|
|
112
|
+
function generateOptionalImportMap(
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
114
|
+
modelClass) {
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
116
|
+
const optionalImportMap = {};
|
|
117
|
+
if (modelClass !== undefined) {
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
119
|
+
const modelLcName = modelClass?.lc_name();
|
|
120
|
+
let optionalImportMapKey;
|
|
121
|
+
if (modelLcName === "ChatGoogleGenerativeAI") {
|
|
122
|
+
optionalImportMapKey = "langchain_google_genai/chat_models";
|
|
123
|
+
}
|
|
124
|
+
else if (modelLcName === "ChatBedrockConverse") {
|
|
125
|
+
optionalImportMapKey = "langchain_aws/chat_models";
|
|
126
|
+
}
|
|
127
|
+
else if (modelLcName === "ChatGroq") {
|
|
128
|
+
optionalImportMapKey = "langchain_groq/chat_models";
|
|
129
|
+
}
|
|
130
|
+
if (optionalImportMapKey !== undefined) {
|
|
131
|
+
optionalImportMap[optionalImportMapKey] = {
|
|
132
|
+
[modelLcName]: modelClass,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return optionalImportMap;
|
|
137
|
+
}
|
|
138
|
+
exports.generateOptionalImportMap = generateOptionalImportMap;
|
package/dist/hub/base.d.ts
CHANGED
|
@@ -27,3 +27,4 @@ export declare function basePull(ownerRepoCommit: string, options?: {
|
|
|
27
27
|
includeModel?: boolean;
|
|
28
28
|
}): Promise<import("langsmith/schemas").PromptCommit>;
|
|
29
29
|
export declare function generateModelImportMap(modelClass?: new (...args: any[]) => BaseLanguageModel): Record<string, any>;
|
|
30
|
+
export declare function generateOptionalImportMap(modelClass?: new (...args: any[]) => BaseLanguageModel): Record<string, any>;
|
package/dist/hub/base.js
CHANGED
|
@@ -65,10 +65,6 @@ export function generateModelImportMap(
|
|
|
65
65
|
modelClass) {
|
|
66
66
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
67
|
const modelImportMap = {};
|
|
68
|
-
// TODO: Fix in 0.4.0. We can't get lc_id without instantiating the class, so we
|
|
69
|
-
// must put them inline here. In the future, make this less hacky
|
|
70
|
-
// This should probably use dynamic imports and have a web-only entrypoint
|
|
71
|
-
// in a future breaking release
|
|
72
68
|
if (modelClass !== undefined) {
|
|
73
69
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
70
|
const modelLcName = modelClass?.lc_name();
|
|
@@ -107,3 +103,29 @@ modelClass) {
|
|
|
107
103
|
}
|
|
108
104
|
return modelImportMap;
|
|
109
105
|
}
|
|
106
|
+
export function generateOptionalImportMap(
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
108
|
+
modelClass) {
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
110
|
+
const optionalImportMap = {};
|
|
111
|
+
if (modelClass !== undefined) {
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
|
+
const modelLcName = modelClass?.lc_name();
|
|
114
|
+
let optionalImportMapKey;
|
|
115
|
+
if (modelLcName === "ChatGoogleGenerativeAI") {
|
|
116
|
+
optionalImportMapKey = "langchain_google_genai/chat_models";
|
|
117
|
+
}
|
|
118
|
+
else if (modelLcName === "ChatBedrockConverse") {
|
|
119
|
+
optionalImportMapKey = "langchain_aws/chat_models";
|
|
120
|
+
}
|
|
121
|
+
else if (modelLcName === "ChatGroq") {
|
|
122
|
+
optionalImportMapKey = "langchain_groq/chat_models";
|
|
123
|
+
}
|
|
124
|
+
if (optionalImportMapKey !== undefined) {
|
|
125
|
+
optionalImportMap[optionalImportMapKey] = {
|
|
126
|
+
[modelLcName]: modelClass,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return optionalImportMap;
|
|
131
|
+
}
|
package/dist/hub/index.cjs
CHANGED
|
@@ -23,7 +23,7 @@ Object.defineProperty(exports, "push", { enumerable: true, get: function () { re
|
|
|
23
23
|
async function pull(ownerRepoCommit, options) {
|
|
24
24
|
const promptObject = await (0, base_js_1.basePull)(ownerRepoCommit, options);
|
|
25
25
|
try {
|
|
26
|
-
const loadedPrompt = await (0, index_js_1.load)(JSON.stringify(promptObject.manifest), undefined,
|
|
26
|
+
const loadedPrompt = await (0, index_js_1.load)(JSON.stringify(promptObject.manifest), undefined, (0, base_js_1.generateOptionalImportMap)(options?.modelClass), (0, base_js_1.generateModelImportMap)(options?.modelClass));
|
|
27
27
|
return loadedPrompt;
|
|
28
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
29
|
}
|
package/dist/hub/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { load } from "../load/index.js";
|
|
2
|
-
import { basePush, basePull, generateModelImportMap } from "./base.js";
|
|
2
|
+
import { basePush, basePull, generateModelImportMap, generateOptionalImportMap, } from "./base.js";
|
|
3
3
|
export { basePush as push };
|
|
4
4
|
/**
|
|
5
5
|
* Pull a prompt from the hub.
|
|
@@ -20,7 +20,7 @@ export { basePush as push };
|
|
|
20
20
|
export async function pull(ownerRepoCommit, options) {
|
|
21
21
|
const promptObject = await basePull(ownerRepoCommit, options);
|
|
22
22
|
try {
|
|
23
|
-
const loadedPrompt = await load(JSON.stringify(promptObject.manifest), undefined,
|
|
23
|
+
const loadedPrompt = await load(JSON.stringify(promptObject.manifest), undefined, generateOptionalImportMap(options?.modelClass), generateModelImportMap(options?.modelClass));
|
|
24
24
|
return loadedPrompt;
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
26
|
}
|
package/dist/hub/node.cjs
CHANGED
|
@@ -47,7 +47,7 @@ async function pull(ownerRepoCommit, options) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
const loadedPrompt = await (0, index_js_1.load)(JSON.stringify(promptObject.manifest), undefined,
|
|
50
|
+
const loadedPrompt = await (0, index_js_1.load)(JSON.stringify(promptObject.manifest), undefined, (0, base_js_1.generateOptionalImportMap)(modelClass), (0, base_js_1.generateModelImportMap)(modelClass));
|
|
51
51
|
return loadedPrompt;
|
|
52
52
|
}
|
|
53
53
|
exports.pull = pull;
|
package/dist/hub/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { basePush, basePull, generateModelImportMap } from "./base.js";
|
|
1
|
+
import { basePush, basePull, generateModelImportMap, generateOptionalImportMap, } from "./base.js";
|
|
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 };
|
|
@@ -45,6 +45,6 @@ export async function pull(ownerRepoCommit, options) {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
const loadedPrompt = await load(JSON.stringify(promptObject.manifest), undefined,
|
|
48
|
+
const loadedPrompt = await load(JSON.stringify(promptObject.manifest), undefined, generateOptionalImportMap(modelClass), generateModelImportMap(modelClass));
|
|
49
49
|
return loadedPrompt;
|
|
50
50
|
}
|