langchain 1.2.17 → 1.2.19

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/agents/index.cjs.map +1 -1
  3. package/dist/agents/index.js.map +1 -1
  4. package/dist/agents/middleware/llmToolSelector.d.ts +4 -4
  5. package/dist/agents/middleware/llmToolSelector.d.ts.map +1 -1
  6. package/dist/agents/middleware/summarization.d.ts +8 -8
  7. package/dist/agents/middleware/summarization.d.ts.map +1 -1
  8. package/dist/agents/middleware/types.d.cts.map +1 -1
  9. package/dist/agents/nodes/AgentNode.cjs.map +1 -1
  10. package/dist/agents/nodes/AgentNode.js.map +1 -1
  11. package/dist/agents/responses.cjs.map +1 -1
  12. package/dist/agents/responses.d.cts +9 -0
  13. package/dist/agents/responses.d.cts.map +1 -1
  14. package/dist/agents/responses.d.ts +9 -0
  15. package/dist/agents/responses.d.ts.map +1 -1
  16. package/dist/agents/responses.js.map +1 -1
  17. package/dist/agents/utils.cjs.map +1 -1
  18. package/dist/agents/utils.js.map +1 -1
  19. package/dist/chat_models/universal.cjs +12 -6
  20. package/dist/chat_models/universal.cjs.map +1 -1
  21. package/dist/chat_models/universal.d.cts +4 -2
  22. package/dist/chat_models/universal.d.cts.map +1 -1
  23. package/dist/chat_models/universal.d.ts +4 -2
  24. package/dist/chat_models/universal.d.ts.map +1 -1
  25. package/dist/chat_models/universal.js +12 -6
  26. package/dist/chat_models/universal.js.map +1 -1
  27. package/dist/hub/base.cjs +6 -3
  28. package/dist/hub/base.cjs.map +1 -1
  29. package/dist/hub/base.d.cts +2 -0
  30. package/dist/hub/base.d.cts.map +1 -1
  31. package/dist/hub/base.d.ts +2 -0
  32. package/dist/hub/base.d.ts.map +1 -1
  33. package/dist/hub/base.js +6 -3
  34. package/dist/hub/base.js.map +1 -1
  35. package/dist/hub/index.cjs +2 -0
  36. package/dist/hub/index.cjs.map +1 -1
  37. package/dist/hub/index.d.cts +5 -0
  38. package/dist/hub/index.d.cts.map +1 -1
  39. package/dist/hub/index.d.ts +5 -0
  40. package/dist/hub/index.d.ts.map +1 -1
  41. package/dist/hub/index.js +2 -0
  42. package/dist/hub/index.js.map +1 -1
  43. package/dist/hub/node.cjs +29 -1
  44. package/dist/hub/node.cjs.map +1 -1
  45. package/dist/hub/node.d.cts +15 -1
  46. package/dist/hub/node.d.cts.map +1 -1
  47. package/dist/hub/node.d.ts +15 -1
  48. package/dist/hub/node.d.ts.map +1 -1
  49. package/dist/hub/node.js +29 -2
  50. package/dist/hub/node.js.map +1 -1
  51. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["ownerRepoCommit: string","options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n }","e: any"],"sources":["../../src/hub/index.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport { load } from \"../load/index.js\";\nimport {\n basePush,\n basePull,\n generateModelImportMap,\n generateOptionalImportMap,\n bindOutputSchema,\n} from \"./base.js\";\n\nexport { basePush as push };\n\n/**\n * Pull a prompt from the hub.\n *\n * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.\n * @param options.apiKey LangSmith API key to use when pulling the prompt\n * @param options.apiUrl LangSmith API URL to use when pulling the prompt\n * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,\n * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will\n * also invoke the instantiated model. For non-OpenAI models, you must also set \"modelClass\" to the\n * correct class of the model.\n * @param options.modelClass If includeModel is true, the class of the model to instantiate. Required\n * for non-OpenAI models. If you are running in Node or another environment that supports dynamic imports,\n * you may instead import this function from \"langchain/hub/node\" and pass \"includeModel: true\" instead\n * of specifying this parameter.\n * @param options.secrets A map of secrets to use when loading, e.g.\n * {'OPENAI_API_KEY': 'sk-...'}`.\n * If a secret is not found in the map, it will be loaded from the\n * environment if `secrets_from_env` is `True`. Should only be needed when\n * `includeModel` is `true`.\n * @param options.secretsFromEnv Whether to load secrets from environment variables.\n * Use with caution and only with trusted prompts.\n * @returns\n */\nexport async function pull<T extends Runnable>(\n ownerRepoCommit: string,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n }\n) {\n const promptObject = await basePull(ownerRepoCommit, options);\n try {\n const loadedPrompt = await load<T>(\n JSON.stringify(promptObject.manifest),\n options?.secrets,\n generateOptionalImportMap(options?.modelClass),\n generateModelImportMap(options?.modelClass),\n options?.secretsFromEnv\n );\n return bindOutputSchema(loadedPrompt);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n if (options?.includeModel) {\n throw new Error(\n [\n e.message,\n \"\",\n `To load prompts with an associated non-OpenAI model, you must use the \"langchain/hub/node\" entrypoint, or pass a \"modelClass\" parameter like this:`,\n \"\",\n \"```\",\n `import { pull } from \"langchain/hub\";`,\n `import { ChatAnthropic } from \"@langchain/anthropic\";`,\n \"\",\n `const prompt = await pull(\"my-prompt\", {`,\n ` includeModel: true,`,\n ` modelClass: ChatAnthropic,`,\n `});`,\n \"```\",\n ].join(\"\\n\")\n );\n } else {\n throw e;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,eAAsB,KACpBA,iBACAC,SASA;CACA,MAAM,eAAe,MAAM,SAAS,iBAAiB,QAAQ;AAC7D,KAAI;EACF,MAAM,eAAe,MAAM,KACzB,KAAK,UAAU,aAAa,SAAS,EACrC,SAAS,SACT,0BAA0B,SAAS,WAAW,EAC9C,uBAAuB,SAAS,WAAW,EAC3C,SAAS,eACV;AACD,SAAO,iBAAiB,aAAa;CAEtC,SAAQC,GAAQ;AACf,MAAI,SAAS,aACX,OAAM,IAAI,MACR;GACE,EAAE;GACF;GACA,CAAC,kJAAkJ,CAAC;GACpJ;GACA;GACA,CAAC,qCAAqC,CAAC;GACvC,CAAC,qDAAqD,CAAC;GACvD;GACA,CAAC,wCAAwC,CAAC;GAC1C,CAAC,qBAAqB,CAAC;GACvB,CAAC,4BAA4B,CAAC;GAC9B,CAAC,GAAG,CAAC;GACL;EACD,EAAC,KAAK,KAAK;MAGd,OAAM;CAET;AACF"}
1
+ {"version":3,"file":"index.js","names":["ownerRepoCommit: string","options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n client?: Client;\n skipCache?: boolean;\n }","e: any"],"sources":["../../src/hub/index.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport type { Client } from \"langsmith\";\nimport type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport { load } from \"../load/index.js\";\nimport {\n basePush,\n basePull,\n generateModelImportMap,\n generateOptionalImportMap,\n bindOutputSchema,\n} from \"./base.js\";\n\nexport { basePush as push };\n\n/**\n * Pull a prompt from the hub.\n *\n * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.\n * @param options.apiKey LangSmith API key to use when pulling the prompt\n * @param options.apiUrl LangSmith API URL to use when pulling the prompt\n * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,\n * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will\n * also invoke the instantiated model. For non-OpenAI models, you must also set \"modelClass\" to the\n * correct class of the model.\n * @param options.modelClass If includeModel is true, the class of the model to instantiate. Required\n * for non-OpenAI models. If you are running in Node or another environment that supports dynamic imports,\n * you may instead import this function from \"langchain/hub/node\" and pass \"includeModel: true\" instead\n * of specifying this parameter.\n * @param options.secrets A map of secrets to use when loading, e.g.\n * {'OPENAI_API_KEY': 'sk-...'}`.\n * If a secret is not found in the map, it will be loaded from the\n * environment if `secrets_from_env` is `True`. Should only be needed when\n * `includeModel` is `true`.\n * @param options.secretsFromEnv Whether to load secrets from environment variables.\n * Use with caution and only with trusted prompts.\n * @param options.client LangSmith client to use when pulling the prompt\n * @param options.skipCache Whether to skip the global default cache when pulling the prompt\n * @returns\n */\nexport async function pull<T extends Runnable>(\n ownerRepoCommit: string,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n client?: Client;\n skipCache?: boolean;\n }\n) {\n const promptObject = await basePull(ownerRepoCommit, options);\n try {\n const loadedPrompt = await load<T>(\n JSON.stringify(promptObject.manifest),\n options?.secrets,\n generateOptionalImportMap(options?.modelClass),\n generateModelImportMap(options?.modelClass),\n options?.secretsFromEnv\n );\n return bindOutputSchema(loadedPrompt);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n if (options?.includeModel) {\n throw new Error(\n [\n e.message,\n \"\",\n `To load prompts with an associated non-OpenAI model, you must use the \"langchain/hub/node\" entrypoint, or pass a \"modelClass\" parameter like this:`,\n \"\",\n \"```\",\n `import { pull } from \"langchain/hub\";`,\n `import { ChatAnthropic } from \"@langchain/anthropic\";`,\n \"\",\n `const prompt = await pull(\"my-prompt\", {`,\n ` includeModel: true,`,\n ` modelClass: ChatAnthropic,`,\n `});`,\n \"```\",\n ].join(\"\\n\")\n );\n } else {\n throw e;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,eAAsB,KACpBA,iBACAC,SAWA;CACA,MAAM,eAAe,MAAM,SAAS,iBAAiB,QAAQ;AAC7D,KAAI;EACF,MAAM,eAAe,MAAM,KACzB,KAAK,UAAU,aAAa,SAAS,EACrC,SAAS,SACT,0BAA0B,SAAS,WAAW,EAC9C,uBAAuB,SAAS,WAAW,EAC3C,SAAS,eACV;AACD,SAAO,iBAAiB,aAAa;CAEtC,SAAQC,GAAQ;AACf,MAAI,SAAS,aACX,OAAM,IAAI,MACR;GACE,EAAE;GACF;GACA,CAAC,kJAAkJ,CAAC;GACpJ;GACA;GACA,CAAC,qCAAqC,CAAC;GACvC,CAAC,qDAAqD,CAAC;GACvD;GACA,CAAC,wCAAwC,CAAC;GAC1C,CAAC,qBAAqB,CAAC;GACvB,CAAC,4BAA4B,CAAC;GAC9B,CAAC,GAAG,CAAC;GACL;EACD,EAAC,KAAK,KAAK;MAGd,OAAM;CAET;AACF"}
package/dist/hub/node.cjs CHANGED
@@ -23,6 +23,30 @@ function isRunnableBinding(a) {
23
23
  return wellKnownIds.some((id) => _idEquals(a, id));
24
24
  }
25
25
  /**
26
+ * Infer modelProvider from the id namespace to avoid className collisions.
27
+ * For non-langchain packages, extracts the provider name from the namespace.
28
+ * e.g., ["langchain", "chat_models", "vertexai", "ChatVertexAI"] -> "google-vertexai"
29
+ * e.g., ["langchain_deepseek", "chat_models", "ChatDeepSeek"] -> "deepseek"
30
+ * @param idArray The full id array from the manifest
31
+ * @returns The inferred modelProvider key or undefined
32
+ */
33
+ function inferModelProviderFromNamespace(idArray) {
34
+ if (!Array.isArray(idArray) || idArray.length < 2) return void 0;
35
+ const namespace = idArray.slice(0, -1);
36
+ for (const part of namespace) {
37
+ if (part === "langchain" || part === "langchain_core" || part === "chat_models" || part === "runnables" || part === "schema") continue;
38
+ if (part.startsWith("langchain_")) {
39
+ const providerName = part.slice(10);
40
+ return providerName.replace(/_/g, "-");
41
+ }
42
+ if (part.includes("vertexai_web")) return "google-vertexai-web";
43
+ else if (part.includes("vertexai")) return "google-vertexai";
44
+ else if (part.includes("genai") || part.includes("google_genai")) return "google-genai";
45
+ if (!part.includes("langchain") && part !== "chat_models" && part !== "runnables") return part.replace(/_/g, "-");
46
+ }
47
+ return void 0;
48
+ }
49
+ /**
26
50
  * Pull a prompt from the hub.
27
51
  * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.
28
52
  * @param options.apiKey LangSmith API key to use when pulling the prompt
@@ -37,6 +61,8 @@ function isRunnableBinding(a) {
37
61
  * `includeModel` is `true`.
38
62
  * @param options.secretsFromEnv Whether to load secrets from environment variables.
39
63
  * Use with caution and only with trusted prompts.
64
+ * @param options.client LangSmith client to use when pulling the prompt
65
+ * @param options.skipCache Whether to skip the global default cache when pulling the prompt
40
66
  * @returns
41
67
  */
42
68
  async function pull(ownerRepoCommit, options) {
@@ -47,7 +73,8 @@ async function pull(ownerRepoCommit, options) {
47
73
  if (Array.isArray(chatModelObject?.id)) {
48
74
  const modelName = chatModelObject?.id.at(-1);
49
75
  if (modelName) {
50
- modelClass = await require_chat_models_universal.getChatModelByClassName(modelName);
76
+ const modelProvider = inferModelProviderFromNamespace(chatModelObject.id);
77
+ modelClass = await require_chat_models_universal.getChatModelByClassName(modelName, modelProvider);
51
78
  if (!modelClass) console.warn(`Received unknown model name from prompt hub: "${modelName}"`);
52
79
  }
53
80
  }
@@ -57,6 +84,7 @@ async function pull(ownerRepoCommit, options) {
57
84
  }
58
85
 
59
86
  //#endregion
87
+ exports.inferModelProviderFromNamespace = inferModelProviderFromNamespace;
60
88
  exports.pull = pull;
61
89
  exports.push = require_base.basePush;
62
90
  //# sourceMappingURL=node.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.cjs","names":["a: string[]","b: string[]","ownerRepoCommit: string","options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n }","basePull","getChatModelByClassName","load","generateOptionalImportMap","generateModelImportMap","bindOutputSchema"],"sources":["../../src/hub/node.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport {\n basePull,\n generateModelImportMap,\n generateOptionalImportMap,\n bindOutputSchema,\n} from \"./base.js\";\nimport { load } from \"../load/index.js\";\nimport { getChatModelByClassName } from \"../chat_models/universal.js\";\n\nexport { basePush as push } from \"./base.js\";\n\nfunction _idEquals(a: string[], b: string[]): boolean {\n if (!Array.isArray(a) || !Array.isArray(b)) {\n return false;\n }\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\nfunction isRunnableBinding(a: string[]): boolean {\n const wellKnownIds = [\n [\"langchain_core\", \"runnables\", \"RunnableBinding\"],\n [\"langchain\", \"schema\", \"runnable\", \"RunnableBinding\"],\n ];\n return wellKnownIds.some((id) => _idEquals(a, id));\n}\n\n/**\n * Pull a prompt from the hub.\n * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.\n * @param options.apiKey LangSmith API key to use when pulling the prompt\n * @param options.apiUrl LangSmith API URL to use when pulling the prompt\n * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,\n * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will\n * also invoke the instantiated model. You must have the appropriate LangChain integration package installed.\n * @param options.secrets A map of secrets to use when loading, e.g.\n * {'OPENAI_API_KEY': 'sk-...'}`.\n * If a secret is not found in the map, it will be loaded from the\n * environment if `secrets_from_env` is `True`. Should only be needed when\n * `includeModel` is `true`.\n * @param options.secretsFromEnv Whether to load secrets from environment variables.\n * Use with caution and only with trusted prompts.\n * @returns\n */\nexport async function pull<T extends Runnable>(\n ownerRepoCommit: string,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n }\n) {\n const promptObject = await basePull(ownerRepoCommit, options);\n let modelClass;\n if (options?.includeModel) {\n const chatModelObject = isRunnableBinding(\n promptObject.manifest.kwargs?.last?.id\n )\n ? promptObject.manifest.kwargs?.last?.kwargs?.bound\n : promptObject.manifest.kwargs?.last;\n\n if (Array.isArray(chatModelObject?.id)) {\n const modelName = chatModelObject?.id.at(-1);\n\n if (modelName) {\n modelClass = await getChatModelByClassName(modelName);\n if (!modelClass) {\n console.warn(\n `Received unknown model name from prompt hub: \"${modelName}\"`\n );\n }\n }\n }\n }\n const loadedPrompt = await load<T>(\n JSON.stringify(promptObject.manifest),\n options?.secrets,\n generateOptionalImportMap(modelClass),\n generateModelImportMap(modelClass),\n options?.secretsFromEnv\n );\n return bindOutputSchema(loadedPrompt);\n}\n"],"mappings":";;;;;AAYA,SAAS,UAAUA,GAAaC,GAAsB;AACpD,KAAI,CAAC,MAAM,QAAQ,EAAE,IAAI,CAAC,MAAM,QAAQ,EAAE,CACxC,QAAO;AAET,KAAI,EAAE,WAAW,EAAE,OACjB,QAAO;AAET,MAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,IAC5B,KAAI,EAAE,OAAO,EAAE,GACb,QAAO;AAGX,QAAO;AACR;AAED,SAAS,kBAAkBD,GAAsB;CAC/C,MAAM,eAAe,CACnB;EAAC;EAAkB;EAAa;CAAkB,GAClD;EAAC;EAAa;EAAU;EAAY;CAAkB,CACvD;AACD,QAAO,aAAa,KAAK,CAAC,OAAO,UAAU,GAAG,GAAG,CAAC;AACnD;;;;;;;;;;;;;;;;;;AAmBD,eAAsB,KACpBE,iBACAC,SAOA;CACA,MAAM,eAAe,MAAMC,sBAAS,iBAAiB,QAAQ;CAC7D,IAAI;AACJ,KAAI,SAAS,cAAc;EACzB,MAAM,kBAAkB,kBACtB,aAAa,SAAS,QAAQ,MAAM,GACrC,GACG,aAAa,SAAS,QAAQ,MAAM,QAAQ,QAC5C,aAAa,SAAS,QAAQ;AAElC,MAAI,MAAM,QAAQ,iBAAiB,GAAG,EAAE;GACtC,MAAM,YAAY,iBAAiB,GAAG,GAAG,GAAG;AAE5C,OAAI,WAAW;IACb,aAAa,MAAMC,sDAAwB,UAAU;AACrD,QAAI,CAAC,YACH,QAAQ,KACN,CAAC,8CAA8C,EAAE,UAAU,CAAC,CAAC,CAC9D;GAEJ;EACF;CACF;CACD,MAAM,eAAe,MAAMC,wBACzB,KAAK,UAAU,aAAa,SAAS,EACrC,SAAS,SACTC,uCAA0B,WAAW,EACrCC,oCAAuB,WAAW,EAClC,SAAS,eACV;AACD,QAAOC,8BAAiB,aAAa;AACtC"}
1
+ {"version":3,"file":"node.cjs","names":["a: string[]","b: string[]","idArray: string[]","ownerRepoCommit: string","options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n client?: Client;\n skipCache?: boolean;\n }","basePull","getChatModelByClassName","load","generateOptionalImportMap","generateModelImportMap","bindOutputSchema"],"sources":["../../src/hub/node.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport type { Client } from \"langsmith\";\nimport {\n basePull,\n generateModelImportMap,\n generateOptionalImportMap,\n bindOutputSchema,\n} from \"./base.js\";\nimport { load } from \"../load/index.js\";\nimport { getChatModelByClassName } from \"../chat_models/universal.js\";\n\nexport { basePush as push } from \"./base.js\";\n\nfunction _idEquals(a: string[], b: string[]): boolean {\n if (!Array.isArray(a) || !Array.isArray(b)) {\n return false;\n }\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\nfunction isRunnableBinding(a: string[]): boolean {\n const wellKnownIds = [\n [\"langchain_core\", \"runnables\", \"RunnableBinding\"],\n [\"langchain\", \"schema\", \"runnable\", \"RunnableBinding\"],\n ];\n return wellKnownIds.some((id) => _idEquals(a, id));\n}\n\n/**\n * Infer modelProvider from the id namespace to avoid className collisions.\n * For non-langchain packages, extracts the provider name from the namespace.\n * e.g., [\"langchain\", \"chat_models\", \"vertexai\", \"ChatVertexAI\"] -> \"google-vertexai\"\n * e.g., [\"langchain_deepseek\", \"chat_models\", \"ChatDeepSeek\"] -> \"deepseek\"\n * @param idArray The full id array from the manifest\n * @returns The inferred modelProvider key or undefined\n */\nexport function inferModelProviderFromNamespace(\n idArray: string[]\n): string | undefined {\n if (!Array.isArray(idArray) || idArray.length < 2) {\n return undefined;\n }\n\n // Check namespace parts (excluding the className at the end)\n const namespace = idArray.slice(0, -1);\n\n // Look for a part that looks like a provider package (not langchain/langchain_core)\n for (const part of namespace) {\n // Skip standard langchain packages\n if (\n part === \"langchain\" ||\n part === \"langchain_core\" ||\n part === \"chat_models\" ||\n part === \"runnables\" ||\n part === \"schema\"\n ) {\n continue;\n }\n\n // If it starts with \"langchain_\", extract the provider name\n // e.g., \"langchain_google_genai\" -> \"google-genai\"\n // e.g., \"langchain_deepseek\" -> \"deepseek\"\n if (part.startsWith(\"langchain_\")) {\n const providerName = part.slice(\"langchain_\".length);\n // Convert underscores to hyphens to match MODEL_PROVIDER_CONFIG keys\n return providerName.replace(/_/g, \"-\");\n }\n\n // Handle special cases for Google providers that need prefix\n if (part.includes(\"vertexai_web\")) {\n return \"google-vertexai-web\";\n } else if (part.includes(\"vertexai\")) {\n return \"google-vertexai\";\n } else if (part.includes(\"genai\") || part.includes(\"google_genai\")) {\n return \"google-genai\";\n }\n\n // For other provider-looking parts, use as-is with underscores converted to hyphens\n // e.g., \"openai\" -> \"openai\", \"anthropic\" -> \"anthropic\"\n if (\n !part.includes(\"langchain\") &&\n part !== \"chat_models\" &&\n part !== \"runnables\"\n ) {\n return part.replace(/_/g, \"-\");\n }\n }\n\n return undefined;\n}\n\n/**\n * Pull a prompt from the hub.\n * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.\n * @param options.apiKey LangSmith API key to use when pulling the prompt\n * @param options.apiUrl LangSmith API URL to use when pulling the prompt\n * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,\n * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will\n * also invoke the instantiated model. You must have the appropriate LangChain integration package installed.\n * @param options.secrets A map of secrets to use when loading, e.g.\n * {'OPENAI_API_KEY': 'sk-...'}`.\n * If a secret is not found in the map, it will be loaded from the\n * environment if `secrets_from_env` is `True`. Should only be needed when\n * `includeModel` is `true`.\n * @param options.secretsFromEnv Whether to load secrets from environment variables.\n * Use with caution and only with trusted prompts.\n * @param options.client LangSmith client to use when pulling the prompt\n * @param options.skipCache Whether to skip the global default cache when pulling the prompt\n * @returns\n */\nexport async function pull<T extends Runnable>(\n ownerRepoCommit: string,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n client?: Client;\n skipCache?: boolean;\n }\n) {\n const promptObject = await basePull(ownerRepoCommit, options);\n let modelClass;\n if (options?.includeModel) {\n const chatModelObject = isRunnableBinding(\n promptObject.manifest.kwargs?.last?.id\n )\n ? promptObject.manifest.kwargs?.last?.kwargs?.bound\n : promptObject.manifest.kwargs?.last;\n\n if (Array.isArray(chatModelObject?.id)) {\n const modelName = chatModelObject?.id.at(-1);\n\n if (modelName) {\n const modelProvider = inferModelProviderFromNamespace(\n chatModelObject.id\n );\n modelClass = await getChatModelByClassName(modelName, modelProvider);\n if (!modelClass) {\n console.warn(\n `Received unknown model name from prompt hub: \"${modelName}\"`\n );\n }\n }\n }\n }\n const loadedPrompt = await load<T>(\n JSON.stringify(promptObject.manifest),\n options?.secrets,\n generateOptionalImportMap(modelClass),\n generateModelImportMap(modelClass),\n options?.secretsFromEnv\n );\n return bindOutputSchema(loadedPrompt);\n}\n"],"mappings":";;;;;AAaA,SAAS,UAAUA,GAAaC,GAAsB;AACpD,KAAI,CAAC,MAAM,QAAQ,EAAE,IAAI,CAAC,MAAM,QAAQ,EAAE,CACxC,QAAO;AAET,KAAI,EAAE,WAAW,EAAE,OACjB,QAAO;AAET,MAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,IAC5B,KAAI,EAAE,OAAO,EAAE,GACb,QAAO;AAGX,QAAO;AACR;AAED,SAAS,kBAAkBD,GAAsB;CAC/C,MAAM,eAAe,CACnB;EAAC;EAAkB;EAAa;CAAkB,GAClD;EAAC;EAAa;EAAU;EAAY;CAAkB,CACvD;AACD,QAAO,aAAa,KAAK,CAAC,OAAO,UAAU,GAAG,GAAG,CAAC;AACnD;;;;;;;;;AAUD,SAAgB,gCACdE,SACoB;AACpB,KAAI,CAAC,MAAM,QAAQ,QAAQ,IAAI,QAAQ,SAAS,EAC9C,QAAO;CAIT,MAAM,YAAY,QAAQ,MAAM,GAAG,GAAG;AAGtC,MAAK,MAAM,QAAQ,WAAW;AAE5B,MACE,SAAS,eACT,SAAS,oBACT,SAAS,iBACT,SAAS,eACT,SAAS,SAET;AAMF,MAAI,KAAK,WAAW,aAAa,EAAE;GACjC,MAAM,eAAe,KAAK,MAAM,GAAoB;AAEpD,UAAO,aAAa,QAAQ,MAAM,IAAI;EACvC;AAGD,MAAI,KAAK,SAAS,eAAe,CAC/B,QAAO;WACE,KAAK,SAAS,WAAW,CAClC,QAAO;WACE,KAAK,SAAS,QAAQ,IAAI,KAAK,SAAS,eAAe,CAChE,QAAO;AAKT,MACE,CAAC,KAAK,SAAS,YAAY,IAC3B,SAAS,iBACT,SAAS,YAET,QAAO,KAAK,QAAQ,MAAM,IAAI;CAEjC;AAED,QAAO;AACR;;;;;;;;;;;;;;;;;;;;AAqBD,eAAsB,KACpBC,iBACAC,SASA;CACA,MAAM,eAAe,MAAMC,sBAAS,iBAAiB,QAAQ;CAC7D,IAAI;AACJ,KAAI,SAAS,cAAc;EACzB,MAAM,kBAAkB,kBACtB,aAAa,SAAS,QAAQ,MAAM,GACrC,GACG,aAAa,SAAS,QAAQ,MAAM,QAAQ,QAC5C,aAAa,SAAS,QAAQ;AAElC,MAAI,MAAM,QAAQ,iBAAiB,GAAG,EAAE;GACtC,MAAM,YAAY,iBAAiB,GAAG,GAAG,GAAG;AAE5C,OAAI,WAAW;IACb,MAAM,gBAAgB,gCACpB,gBAAgB,GACjB;IACD,aAAa,MAAMC,sDAAwB,WAAW,cAAc;AACpE,QAAI,CAAC,YACH,QAAQ,KACN,CAAC,8CAA8C,EAAE,UAAU,CAAC,CAAC,CAC9D;GAEJ;EACF;CACF;CACD,MAAM,eAAe,MAAMC,wBACzB,KAAK,UAAU,aAAa,SAAS,EACrC,SAAS,SACTC,uCAA0B,WAAW,EACrCC,oCAAuB,WAAW,EAClC,SAAS,eACV;AACD,QAAOC,8BAAiB,aAAa;AACtC"}
@@ -1,8 +1,18 @@
1
1
  import { basePush } from "./base.cjs";
2
2
  import { Runnable } from "@langchain/core/runnables";
3
+ import { Client } from "langsmith";
3
4
 
4
5
  //#region src/hub/node.d.ts
5
6
 
7
+ /**
8
+ * Infer modelProvider from the id namespace to avoid className collisions.
9
+ * For non-langchain packages, extracts the provider name from the namespace.
10
+ * e.g., ["langchain", "chat_models", "vertexai", "ChatVertexAI"] -> "google-vertexai"
11
+ * e.g., ["langchain_deepseek", "chat_models", "ChatDeepSeek"] -> "deepseek"
12
+ * @param idArray The full id array from the manifest
13
+ * @returns The inferred modelProvider key or undefined
14
+ */
15
+ declare function inferModelProviderFromNamespace(idArray: string[]): string | undefined;
6
16
  /**
7
17
  * Pull a prompt from the hub.
8
18
  * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.
@@ -18,6 +28,8 @@ import { Runnable } from "@langchain/core/runnables";
18
28
  * `includeModel` is `true`.
19
29
  * @param options.secretsFromEnv Whether to load secrets from environment variables.
20
30
  * Use with caution and only with trusted prompts.
31
+ * @param options.client LangSmith client to use when pulling the prompt
32
+ * @param options.skipCache Whether to skip the global default cache when pulling the prompt
21
33
  * @returns
22
34
  */
23
35
  declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
@@ -26,7 +38,9 @@ declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
26
38
  includeModel?: boolean;
27
39
  secrets?: Record<string, string>;
28
40
  secretsFromEnv?: boolean;
41
+ client?: Client;
42
+ skipCache?: boolean;
29
43
  }): Promise<T>;
30
44
  //#endregion
31
- export { pull, basePush as push };
45
+ export { inferModelProviderFromNamespace, pull, basePush as push };
32
46
  //# sourceMappingURL=node.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.cts","names":["Runnable","basePush","push","pull","T","Record","Promise"],"sources":["../../src/hub/node.d.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nexport { basePush as push } from \"./base.js\";\n/**\n * Pull a prompt from the hub.\n * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.\n * @param options.apiKey LangSmith API key to use when pulling the prompt\n * @param options.apiUrl LangSmith API URL to use when pulling the prompt\n * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,\n * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will\n * also invoke the instantiated model. You must have the appropriate LangChain integration package installed.\n * @param options.secrets A map of secrets to use when loading, e.g.\n * {'OPENAI_API_KEY': 'sk-...'}`.\n * If a secret is not found in the map, it will be loaded from the\n * environment if `secrets_from_env` is `True`. Should only be needed when\n * `includeModel` is `true`.\n * @param options.secretsFromEnv Whether to load secrets from environment variables.\n * Use with caution and only with trusted prompts.\n * @returns\n */\nexport declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n}): Promise<T>;\n//# sourceMappingURL=node.d.ts.map"],"mappings":";;;;;;;AAmBA;;;;;AAMW;;;;;;;;;;iBANaG,eAAeH;;;;YAIzBK;;IAEVC,QAAQF"}
1
+ {"version":3,"file":"node.d.cts","names":["Runnable","Client","basePush","push","inferModelProviderFromNamespace","pull","T","Record","Promise"],"sources":["../../src/hub/node.d.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport type { Client } from \"langsmith\";\nexport { basePush as push } from \"./base.js\";\n/**\n * Infer modelProvider from the id namespace to avoid className collisions.\n * For non-langchain packages, extracts the provider name from the namespace.\n * e.g., [\"langchain\", \"chat_models\", \"vertexai\", \"ChatVertexAI\"] -> \"google-vertexai\"\n * e.g., [\"langchain_deepseek\", \"chat_models\", \"ChatDeepSeek\"] -> \"deepseek\"\n * @param idArray The full id array from the manifest\n * @returns The inferred modelProvider key or undefined\n */\nexport declare function inferModelProviderFromNamespace(idArray: string[]): string | undefined;\n/**\n * Pull a prompt from the hub.\n * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.\n * @param options.apiKey LangSmith API key to use when pulling the prompt\n * @param options.apiUrl LangSmith API URL to use when pulling the prompt\n * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,\n * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will\n * also invoke the instantiated model. You must have the appropriate LangChain integration package installed.\n * @param options.secrets A map of secrets to use when loading, e.g.\n * {'OPENAI_API_KEY': 'sk-...'}`.\n * If a secret is not found in the map, it will be loaded from the\n * environment if `secrets_from_env` is `True`. Should only be needed when\n * `includeModel` is `true`.\n * @param options.secretsFromEnv Whether to load secrets from environment variables.\n * Use with caution and only with trusted prompts.\n * @param options.client LangSmith client to use when pulling the prompt\n * @param options.skipCache Whether to skip the global default cache when pulling the prompt\n * @returns\n */\nexport declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n client?: Client;\n skipCache?: boolean;\n}): Promise<T>;\n//# sourceMappingURL=node.d.ts.map"],"mappings":";;;;;;;;AAWA;AAoBA;;;;;AAQIQ,iBA5BoBJ,+BAAAA,CA4BpBI,OAAAA,EAAAA,MAAAA,EAAAA,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;AAAO;;;;;;;;;;;;;;;;;;;iBARaH,eAAeL;;;;YAIzBO;;WAEDN;;IAETO,QAAQF"}
@@ -1,8 +1,18 @@
1
1
  import { basePush } from "./base.js";
2
2
  import { Runnable } from "@langchain/core/runnables";
3
+ import { Client } from "langsmith";
3
4
 
4
5
  //#region src/hub/node.d.ts
5
6
 
7
+ /**
8
+ * Infer modelProvider from the id namespace to avoid className collisions.
9
+ * For non-langchain packages, extracts the provider name from the namespace.
10
+ * e.g., ["langchain", "chat_models", "vertexai", "ChatVertexAI"] -> "google-vertexai"
11
+ * e.g., ["langchain_deepseek", "chat_models", "ChatDeepSeek"] -> "deepseek"
12
+ * @param idArray The full id array from the manifest
13
+ * @returns The inferred modelProvider key or undefined
14
+ */
15
+ declare function inferModelProviderFromNamespace(idArray: string[]): string | undefined;
6
16
  /**
7
17
  * Pull a prompt from the hub.
8
18
  * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.
@@ -18,6 +28,8 @@ import { Runnable } from "@langchain/core/runnables";
18
28
  * `includeModel` is `true`.
19
29
  * @param options.secretsFromEnv Whether to load secrets from environment variables.
20
30
  * Use with caution and only with trusted prompts.
31
+ * @param options.client LangSmith client to use when pulling the prompt
32
+ * @param options.skipCache Whether to skip the global default cache when pulling the prompt
21
33
  * @returns
22
34
  */
23
35
  declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
@@ -26,7 +38,9 @@ declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
26
38
  includeModel?: boolean;
27
39
  secrets?: Record<string, string>;
28
40
  secretsFromEnv?: boolean;
41
+ client?: Client;
42
+ skipCache?: boolean;
29
43
  }): Promise<T>;
30
44
  //#endregion
31
- export { pull, basePush as push };
45
+ export { inferModelProviderFromNamespace, pull, basePush as push };
32
46
  //# sourceMappingURL=node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","names":["Runnable","basePush","push","pull","T","Record","Promise"],"sources":["../../src/hub/node.d.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nexport { basePush as push } from \"./base.js\";\n/**\n * Pull a prompt from the hub.\n * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.\n * @param options.apiKey LangSmith API key to use when pulling the prompt\n * @param options.apiUrl LangSmith API URL to use when pulling the prompt\n * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,\n * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will\n * also invoke the instantiated model. You must have the appropriate LangChain integration package installed.\n * @param options.secrets A map of secrets to use when loading, e.g.\n * {'OPENAI_API_KEY': 'sk-...'}`.\n * If a secret is not found in the map, it will be loaded from the\n * environment if `secrets_from_env` is `True`. Should only be needed when\n * `includeModel` is `true`.\n * @param options.secretsFromEnv Whether to load secrets from environment variables.\n * Use with caution and only with trusted prompts.\n * @returns\n */\nexport declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n}): Promise<T>;\n//# sourceMappingURL=node.d.ts.map"],"mappings":";;;;;;;AAmBA;;;;;AAMW;;;;;;;;;;iBANaG,eAAeH;;;;YAIzBK;;IAEVC,QAAQF"}
1
+ {"version":3,"file":"node.d.ts","names":["Runnable","Client","basePush","push","inferModelProviderFromNamespace","pull","T","Record","Promise"],"sources":["../../src/hub/node.d.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport type { Client } from \"langsmith\";\nexport { basePush as push } from \"./base.js\";\n/**\n * Infer modelProvider from the id namespace to avoid className collisions.\n * For non-langchain packages, extracts the provider name from the namespace.\n * e.g., [\"langchain\", \"chat_models\", \"vertexai\", \"ChatVertexAI\"] -> \"google-vertexai\"\n * e.g., [\"langchain_deepseek\", \"chat_models\", \"ChatDeepSeek\"] -> \"deepseek\"\n * @param idArray The full id array from the manifest\n * @returns The inferred modelProvider key or undefined\n */\nexport declare function inferModelProviderFromNamespace(idArray: string[]): string | undefined;\n/**\n * Pull a prompt from the hub.\n * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.\n * @param options.apiKey LangSmith API key to use when pulling the prompt\n * @param options.apiUrl LangSmith API URL to use when pulling the prompt\n * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,\n * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will\n * also invoke the instantiated model. You must have the appropriate LangChain integration package installed.\n * @param options.secrets A map of secrets to use when loading, e.g.\n * {'OPENAI_API_KEY': 'sk-...'}`.\n * If a secret is not found in the map, it will be loaded from the\n * environment if `secrets_from_env` is `True`. Should only be needed when\n * `includeModel` is `true`.\n * @param options.secretsFromEnv Whether to load secrets from environment variables.\n * Use with caution and only with trusted prompts.\n * @param options.client LangSmith client to use when pulling the prompt\n * @param options.skipCache Whether to skip the global default cache when pulling the prompt\n * @returns\n */\nexport declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n client?: Client;\n skipCache?: boolean;\n}): Promise<T>;\n//# sourceMappingURL=node.d.ts.map"],"mappings":";;;;;;;;AAWA;AAoBA;;;;;AAQIQ,iBA5BoBJ,+BAAAA,CA4BpBI,OAAAA,EAAAA,MAAAA,EAAAA,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;AAAO;;;;;;;;;;;;;;;;;;;iBARaH,eAAeL;;;;YAIzBO;;WAEDN;;IAETO,QAAQF"}
package/dist/hub/node.js CHANGED
@@ -23,6 +23,30 @@ function isRunnableBinding(a) {
23
23
  return wellKnownIds.some((id) => _idEquals(a, id));
24
24
  }
25
25
  /**
26
+ * Infer modelProvider from the id namespace to avoid className collisions.
27
+ * For non-langchain packages, extracts the provider name from the namespace.
28
+ * e.g., ["langchain", "chat_models", "vertexai", "ChatVertexAI"] -> "google-vertexai"
29
+ * e.g., ["langchain_deepseek", "chat_models", "ChatDeepSeek"] -> "deepseek"
30
+ * @param idArray The full id array from the manifest
31
+ * @returns The inferred modelProvider key or undefined
32
+ */
33
+ function inferModelProviderFromNamespace(idArray) {
34
+ if (!Array.isArray(idArray) || idArray.length < 2) return void 0;
35
+ const namespace = idArray.slice(0, -1);
36
+ for (const part of namespace) {
37
+ if (part === "langchain" || part === "langchain_core" || part === "chat_models" || part === "runnables" || part === "schema") continue;
38
+ if (part.startsWith("langchain_")) {
39
+ const providerName = part.slice(10);
40
+ return providerName.replace(/_/g, "-");
41
+ }
42
+ if (part.includes("vertexai_web")) return "google-vertexai-web";
43
+ else if (part.includes("vertexai")) return "google-vertexai";
44
+ else if (part.includes("genai") || part.includes("google_genai")) return "google-genai";
45
+ if (!part.includes("langchain") && part !== "chat_models" && part !== "runnables") return part.replace(/_/g, "-");
46
+ }
47
+ return void 0;
48
+ }
49
+ /**
26
50
  * Pull a prompt from the hub.
27
51
  * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.
28
52
  * @param options.apiKey LangSmith API key to use when pulling the prompt
@@ -37,6 +61,8 @@ function isRunnableBinding(a) {
37
61
  * `includeModel` is `true`.
38
62
  * @param options.secretsFromEnv Whether to load secrets from environment variables.
39
63
  * Use with caution and only with trusted prompts.
64
+ * @param options.client LangSmith client to use when pulling the prompt
65
+ * @param options.skipCache Whether to skip the global default cache when pulling the prompt
40
66
  * @returns
41
67
  */
42
68
  async function pull(ownerRepoCommit, options) {
@@ -47,7 +73,8 @@ async function pull(ownerRepoCommit, options) {
47
73
  if (Array.isArray(chatModelObject?.id)) {
48
74
  const modelName = chatModelObject?.id.at(-1);
49
75
  if (modelName) {
50
- modelClass = await getChatModelByClassName(modelName);
76
+ const modelProvider = inferModelProviderFromNamespace(chatModelObject.id);
77
+ modelClass = await getChatModelByClassName(modelName, modelProvider);
51
78
  if (!modelClass) console.warn(`Received unknown model name from prompt hub: "${modelName}"`);
52
79
  }
53
80
  }
@@ -57,5 +84,5 @@ async function pull(ownerRepoCommit, options) {
57
84
  }
58
85
 
59
86
  //#endregion
60
- export { pull, basePush as push };
87
+ export { inferModelProviderFromNamespace, pull, basePush as push };
61
88
  //# sourceMappingURL=node.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","names":["a: string[]","b: string[]","ownerRepoCommit: string","options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n }"],"sources":["../../src/hub/node.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport {\n basePull,\n generateModelImportMap,\n generateOptionalImportMap,\n bindOutputSchema,\n} from \"./base.js\";\nimport { load } from \"../load/index.js\";\nimport { getChatModelByClassName } from \"../chat_models/universal.js\";\n\nexport { basePush as push } from \"./base.js\";\n\nfunction _idEquals(a: string[], b: string[]): boolean {\n if (!Array.isArray(a) || !Array.isArray(b)) {\n return false;\n }\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\nfunction isRunnableBinding(a: string[]): boolean {\n const wellKnownIds = [\n [\"langchain_core\", \"runnables\", \"RunnableBinding\"],\n [\"langchain\", \"schema\", \"runnable\", \"RunnableBinding\"],\n ];\n return wellKnownIds.some((id) => _idEquals(a, id));\n}\n\n/**\n * Pull a prompt from the hub.\n * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.\n * @param options.apiKey LangSmith API key to use when pulling the prompt\n * @param options.apiUrl LangSmith API URL to use when pulling the prompt\n * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,\n * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will\n * also invoke the instantiated model. You must have the appropriate LangChain integration package installed.\n * @param options.secrets A map of secrets to use when loading, e.g.\n * {'OPENAI_API_KEY': 'sk-...'}`.\n * If a secret is not found in the map, it will be loaded from the\n * environment if `secrets_from_env` is `True`. Should only be needed when\n * `includeModel` is `true`.\n * @param options.secretsFromEnv Whether to load secrets from environment variables.\n * Use with caution and only with trusted prompts.\n * @returns\n */\nexport async function pull<T extends Runnable>(\n ownerRepoCommit: string,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n }\n) {\n const promptObject = await basePull(ownerRepoCommit, options);\n let modelClass;\n if (options?.includeModel) {\n const chatModelObject = isRunnableBinding(\n promptObject.manifest.kwargs?.last?.id\n )\n ? promptObject.manifest.kwargs?.last?.kwargs?.bound\n : promptObject.manifest.kwargs?.last;\n\n if (Array.isArray(chatModelObject?.id)) {\n const modelName = chatModelObject?.id.at(-1);\n\n if (modelName) {\n modelClass = await getChatModelByClassName(modelName);\n if (!modelClass) {\n console.warn(\n `Received unknown model name from prompt hub: \"${modelName}\"`\n );\n }\n }\n }\n }\n const loadedPrompt = await load<T>(\n JSON.stringify(promptObject.manifest),\n options?.secrets,\n generateOptionalImportMap(modelClass),\n generateModelImportMap(modelClass),\n options?.secretsFromEnv\n );\n return bindOutputSchema(loadedPrompt);\n}\n"],"mappings":";;;;;AAYA,SAAS,UAAUA,GAAaC,GAAsB;AACpD,KAAI,CAAC,MAAM,QAAQ,EAAE,IAAI,CAAC,MAAM,QAAQ,EAAE,CACxC,QAAO;AAET,KAAI,EAAE,WAAW,EAAE,OACjB,QAAO;AAET,MAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,IAC5B,KAAI,EAAE,OAAO,EAAE,GACb,QAAO;AAGX,QAAO;AACR;AAED,SAAS,kBAAkBD,GAAsB;CAC/C,MAAM,eAAe,CACnB;EAAC;EAAkB;EAAa;CAAkB,GAClD;EAAC;EAAa;EAAU;EAAY;CAAkB,CACvD;AACD,QAAO,aAAa,KAAK,CAAC,OAAO,UAAU,GAAG,GAAG,CAAC;AACnD;;;;;;;;;;;;;;;;;;AAmBD,eAAsB,KACpBE,iBACAC,SAOA;CACA,MAAM,eAAe,MAAM,SAAS,iBAAiB,QAAQ;CAC7D,IAAI;AACJ,KAAI,SAAS,cAAc;EACzB,MAAM,kBAAkB,kBACtB,aAAa,SAAS,QAAQ,MAAM,GACrC,GACG,aAAa,SAAS,QAAQ,MAAM,QAAQ,QAC5C,aAAa,SAAS,QAAQ;AAElC,MAAI,MAAM,QAAQ,iBAAiB,GAAG,EAAE;GACtC,MAAM,YAAY,iBAAiB,GAAG,GAAG,GAAG;AAE5C,OAAI,WAAW;IACb,aAAa,MAAM,wBAAwB,UAAU;AACrD,QAAI,CAAC,YACH,QAAQ,KACN,CAAC,8CAA8C,EAAE,UAAU,CAAC,CAAC,CAC9D;GAEJ;EACF;CACF;CACD,MAAM,eAAe,MAAM,KACzB,KAAK,UAAU,aAAa,SAAS,EACrC,SAAS,SACT,0BAA0B,WAAW,EACrC,uBAAuB,WAAW,EAClC,SAAS,eACV;AACD,QAAO,iBAAiB,aAAa;AACtC"}
1
+ {"version":3,"file":"node.js","names":["a: string[]","b: string[]","idArray: string[]","ownerRepoCommit: string","options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n client?: Client;\n skipCache?: boolean;\n }"],"sources":["../../src/hub/node.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport type { Client } from \"langsmith\";\nimport {\n basePull,\n generateModelImportMap,\n generateOptionalImportMap,\n bindOutputSchema,\n} from \"./base.js\";\nimport { load } from \"../load/index.js\";\nimport { getChatModelByClassName } from \"../chat_models/universal.js\";\n\nexport { basePush as push } from \"./base.js\";\n\nfunction _idEquals(a: string[], b: string[]): boolean {\n if (!Array.isArray(a) || !Array.isArray(b)) {\n return false;\n }\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n\nfunction isRunnableBinding(a: string[]): boolean {\n const wellKnownIds = [\n [\"langchain_core\", \"runnables\", \"RunnableBinding\"],\n [\"langchain\", \"schema\", \"runnable\", \"RunnableBinding\"],\n ];\n return wellKnownIds.some((id) => _idEquals(a, id));\n}\n\n/**\n * Infer modelProvider from the id namespace to avoid className collisions.\n * For non-langchain packages, extracts the provider name from the namespace.\n * e.g., [\"langchain\", \"chat_models\", \"vertexai\", \"ChatVertexAI\"] -> \"google-vertexai\"\n * e.g., [\"langchain_deepseek\", \"chat_models\", \"ChatDeepSeek\"] -> \"deepseek\"\n * @param idArray The full id array from the manifest\n * @returns The inferred modelProvider key or undefined\n */\nexport function inferModelProviderFromNamespace(\n idArray: string[]\n): string | undefined {\n if (!Array.isArray(idArray) || idArray.length < 2) {\n return undefined;\n }\n\n // Check namespace parts (excluding the className at the end)\n const namespace = idArray.slice(0, -1);\n\n // Look for a part that looks like a provider package (not langchain/langchain_core)\n for (const part of namespace) {\n // Skip standard langchain packages\n if (\n part === \"langchain\" ||\n part === \"langchain_core\" ||\n part === \"chat_models\" ||\n part === \"runnables\" ||\n part === \"schema\"\n ) {\n continue;\n }\n\n // If it starts with \"langchain_\", extract the provider name\n // e.g., \"langchain_google_genai\" -> \"google-genai\"\n // e.g., \"langchain_deepseek\" -> \"deepseek\"\n if (part.startsWith(\"langchain_\")) {\n const providerName = part.slice(\"langchain_\".length);\n // Convert underscores to hyphens to match MODEL_PROVIDER_CONFIG keys\n return providerName.replace(/_/g, \"-\");\n }\n\n // Handle special cases for Google providers that need prefix\n if (part.includes(\"vertexai_web\")) {\n return \"google-vertexai-web\";\n } else if (part.includes(\"vertexai\")) {\n return \"google-vertexai\";\n } else if (part.includes(\"genai\") || part.includes(\"google_genai\")) {\n return \"google-genai\";\n }\n\n // For other provider-looking parts, use as-is with underscores converted to hyphens\n // e.g., \"openai\" -> \"openai\", \"anthropic\" -> \"anthropic\"\n if (\n !part.includes(\"langchain\") &&\n part !== \"chat_models\" &&\n part !== \"runnables\"\n ) {\n return part.replace(/_/g, \"-\");\n }\n }\n\n return undefined;\n}\n\n/**\n * Pull a prompt from the hub.\n * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.\n * @param options.apiKey LangSmith API key to use when pulling the prompt\n * @param options.apiUrl LangSmith API URL to use when pulling the prompt\n * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,\n * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will\n * also invoke the instantiated model. You must have the appropriate LangChain integration package installed.\n * @param options.secrets A map of secrets to use when loading, e.g.\n * {'OPENAI_API_KEY': 'sk-...'}`.\n * If a secret is not found in the map, it will be loaded from the\n * environment if `secrets_from_env` is `True`. Should only be needed when\n * `includeModel` is `true`.\n * @param options.secretsFromEnv Whether to load secrets from environment variables.\n * Use with caution and only with trusted prompts.\n * @param options.client LangSmith client to use when pulling the prompt\n * @param options.skipCache Whether to skip the global default cache when pulling the prompt\n * @returns\n */\nexport async function pull<T extends Runnable>(\n ownerRepoCommit: string,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n client?: Client;\n skipCache?: boolean;\n }\n) {\n const promptObject = await basePull(ownerRepoCommit, options);\n let modelClass;\n if (options?.includeModel) {\n const chatModelObject = isRunnableBinding(\n promptObject.manifest.kwargs?.last?.id\n )\n ? promptObject.manifest.kwargs?.last?.kwargs?.bound\n : promptObject.manifest.kwargs?.last;\n\n if (Array.isArray(chatModelObject?.id)) {\n const modelName = chatModelObject?.id.at(-1);\n\n if (modelName) {\n const modelProvider = inferModelProviderFromNamespace(\n chatModelObject.id\n );\n modelClass = await getChatModelByClassName(modelName, modelProvider);\n if (!modelClass) {\n console.warn(\n `Received unknown model name from prompt hub: \"${modelName}\"`\n );\n }\n }\n }\n }\n const loadedPrompt = await load<T>(\n JSON.stringify(promptObject.manifest),\n options?.secrets,\n generateOptionalImportMap(modelClass),\n generateModelImportMap(modelClass),\n options?.secretsFromEnv\n );\n return bindOutputSchema(loadedPrompt);\n}\n"],"mappings":";;;;;AAaA,SAAS,UAAUA,GAAaC,GAAsB;AACpD,KAAI,CAAC,MAAM,QAAQ,EAAE,IAAI,CAAC,MAAM,QAAQ,EAAE,CACxC,QAAO;AAET,KAAI,EAAE,WAAW,EAAE,OACjB,QAAO;AAET,MAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,IAC5B,KAAI,EAAE,OAAO,EAAE,GACb,QAAO;AAGX,QAAO;AACR;AAED,SAAS,kBAAkBD,GAAsB;CAC/C,MAAM,eAAe,CACnB;EAAC;EAAkB;EAAa;CAAkB,GAClD;EAAC;EAAa;EAAU;EAAY;CAAkB,CACvD;AACD,QAAO,aAAa,KAAK,CAAC,OAAO,UAAU,GAAG,GAAG,CAAC;AACnD;;;;;;;;;AAUD,SAAgB,gCACdE,SACoB;AACpB,KAAI,CAAC,MAAM,QAAQ,QAAQ,IAAI,QAAQ,SAAS,EAC9C,QAAO;CAIT,MAAM,YAAY,QAAQ,MAAM,GAAG,GAAG;AAGtC,MAAK,MAAM,QAAQ,WAAW;AAE5B,MACE,SAAS,eACT,SAAS,oBACT,SAAS,iBACT,SAAS,eACT,SAAS,SAET;AAMF,MAAI,KAAK,WAAW,aAAa,EAAE;GACjC,MAAM,eAAe,KAAK,MAAM,GAAoB;AAEpD,UAAO,aAAa,QAAQ,MAAM,IAAI;EACvC;AAGD,MAAI,KAAK,SAAS,eAAe,CAC/B,QAAO;WACE,KAAK,SAAS,WAAW,CAClC,QAAO;WACE,KAAK,SAAS,QAAQ,IAAI,KAAK,SAAS,eAAe,CAChE,QAAO;AAKT,MACE,CAAC,KAAK,SAAS,YAAY,IAC3B,SAAS,iBACT,SAAS,YAET,QAAO,KAAK,QAAQ,MAAM,IAAI;CAEjC;AAED,QAAO;AACR;;;;;;;;;;;;;;;;;;;;AAqBD,eAAsB,KACpBC,iBACAC,SASA;CACA,MAAM,eAAe,MAAM,SAAS,iBAAiB,QAAQ;CAC7D,IAAI;AACJ,KAAI,SAAS,cAAc;EACzB,MAAM,kBAAkB,kBACtB,aAAa,SAAS,QAAQ,MAAM,GACrC,GACG,aAAa,SAAS,QAAQ,MAAM,QAAQ,QAC5C,aAAa,SAAS,QAAQ;AAElC,MAAI,MAAM,QAAQ,iBAAiB,GAAG,EAAE;GACtC,MAAM,YAAY,iBAAiB,GAAG,GAAG,GAAG;AAE5C,OAAI,WAAW;IACb,MAAM,gBAAgB,gCACpB,gBAAgB,GACjB;IACD,aAAa,MAAM,wBAAwB,WAAW,cAAc;AACpE,QAAI,CAAC,YACH,QAAQ,KACN,CAAC,8CAA8C,EAAE,UAAU,CAAC,CAAC,CAC9D;GAEJ;EACF;CACF;CACD,MAAM,eAAe,MAAM,KACzB,KAAK,UAAU,aAAa,SAAS,EACrC,SAAS,SACT,0BAA0B,WAAW,EACrC,uBAAuB,WAAW,EAClC,SAAS,eACV;AACD,QAAO,iBAAiB,aAAa;AACtC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "1.2.17",
3
+ "version": "1.2.19",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "author": "LangChain",
6
6
  "license": "MIT",
@@ -48,24 +48,24 @@
48
48
  "reflect-metadata": "^0.2.2",
49
49
  "rimraf": "^5.0.1",
50
50
  "tinybench": "^5.1.0",
51
- "typeorm": "^0.3.26",
51
+ "typeorm": "^0.3.28",
52
52
  "typescript": "~5.8.3",
53
53
  "vitest": "^3.2.4",
54
54
  "yaml": "^2.8.1",
55
- "@langchain/anthropic": "1.3.14",
55
+ "@langchain/anthropic": "1.3.16",
56
56
  "@langchain/cohere": "1.0.2",
57
- "@langchain/core": "1.1.19",
57
+ "@langchain/core": "1.1.20",
58
58
  "@langchain/eslint": "0.1.1",
59
- "@langchain/openai": "1.2.4",
59
+ "@langchain/openai": "1.2.6",
60
60
  "@langchain/tsconfig": "0.0.1"
61
61
  },
62
62
  "peerDependencies": {
63
- "@langchain/core": "1.1.19"
63
+ "@langchain/core": "1.1.20"
64
64
  },
65
65
  "dependencies": {
66
66
  "@langchain/langgraph": "^1.1.2",
67
67
  "@langchain/langgraph-checkpoint": "^1.0.0",
68
- "langsmith": ">=0.4.0 <1.0.0",
68
+ "langsmith": ">=0.5.0 <1.0.0",
69
69
  "uuid": "^10.0.0",
70
70
  "zod": "^3.25.76 || ^4"
71
71
  },