@langchain/classic 1.0.7 → 1.0.8

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 (56) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/agents/chat/outputParser.d.ts +2 -2
  3. package/dist/agents/chat/outputParser.d.ts.map +1 -1
  4. package/dist/agents/mrkl/outputParser.d.ts +1 -1
  5. package/dist/agents/mrkl/outputParser.d.ts.map +1 -1
  6. package/dist/agents/openai_tools/index.d.ts +2 -2
  7. package/dist/agents/openai_tools/index.d.ts.map +1 -1
  8. package/dist/agents/react/index.d.cts +2 -2
  9. package/dist/agents/react/index.d.cts.map +1 -1
  10. package/dist/agents/react/index.d.ts +2 -2
  11. package/dist/agents/react/index.d.ts.map +1 -1
  12. package/dist/agents/structured_chat/index.d.cts +2 -2
  13. package/dist/agents/structured_chat/index.d.cts.map +1 -1
  14. package/dist/agents/structured_chat/index.d.ts +2 -2
  15. package/dist/agents/structured_chat/index.d.ts.map +1 -1
  16. package/dist/agents/tool_calling/index.d.cts +2 -2
  17. package/dist/agents/tool_calling/index.d.cts.map +1 -1
  18. package/dist/agents/tool_calling/index.d.ts +2 -2
  19. package/dist/agents/tool_calling/index.d.ts.map +1 -1
  20. package/dist/chat_models/universal.cjs +3 -2
  21. package/dist/chat_models/universal.cjs.map +1 -1
  22. package/dist/chat_models/universal.js +3 -2
  23. package/dist/chat_models/universal.js.map +1 -1
  24. package/dist/evaluation/agents/trajectory.d.ts +2 -2
  25. package/dist/evaluation/agents/trajectory.d.ts.map +1 -1
  26. package/dist/evaluation/comparison/pairwise.d.ts +3 -3
  27. package/dist/evaluation/comparison/pairwise.d.ts.map +1 -1
  28. package/dist/evaluation/criteria/criteria.d.ts +3 -3
  29. package/dist/evaluation/criteria/criteria.d.ts.map +1 -1
  30. package/dist/experimental/prompts/custom_format.d.cts.map +1 -1
  31. package/dist/experimental/prompts/handlebars.d.cts.map +1 -1
  32. package/dist/hub/index.cjs +8 -1
  33. package/dist/hub/index.cjs.map +1 -1
  34. package/dist/hub/index.d.cts +9 -0
  35. package/dist/hub/index.d.cts.map +1 -1
  36. package/dist/hub/index.d.ts +9 -0
  37. package/dist/hub/index.d.ts.map +1 -1
  38. package/dist/hub/index.js +8 -1
  39. package/dist/hub/index.js.map +1 -1
  40. package/dist/hub/node.cjs +30 -3
  41. package/dist/hub/node.cjs.map +1 -1
  42. package/dist/hub/node.d.cts +9 -0
  43. package/dist/hub/node.d.cts.map +1 -1
  44. package/dist/hub/node.d.ts +9 -0
  45. package/dist/hub/node.d.ts.map +1 -1
  46. package/dist/hub/node.js +30 -3
  47. package/dist/hub/node.js.map +1 -1
  48. package/dist/load/index.cjs +3 -2
  49. package/dist/load/index.cjs.map +1 -1
  50. package/dist/load/index.d.cts +1 -1
  51. package/dist/load/index.d.cts.map +1 -1
  52. package/dist/load/index.d.ts +1 -1
  53. package/dist/load/index.d.ts.map +1 -1
  54. package/dist/load/index.js +3 -2
  55. package/dist/load/index.js.map +1 -1
  56. package/package.json +13 -13
@@ -1 +1 @@
1
- {"version":3,"file":"handlebars.d.cts","names":["InputValues","CustomFormatPromptTemplate","CustomFormatPromptTemplateInput","parseHandlebars","_langchain_core_prompts0","ParsedTemplateNode","interpolateHandlebars","HandlebarsPromptTemplateInput","RunInput","HandlebarsPromptTemplate","Record","Omit","Symbol"],"sources":["../../../src/experimental/prompts/handlebars.d.ts"],"sourcesContent":["import type { InputValues } from \"@langchain/core/utils/types\";\nimport { CustomFormatPromptTemplate, CustomFormatPromptTemplateInput } from \"./custom_format.js\";\nexport declare const parseHandlebars: (template: string) => import(\"@langchain/core/prompts\").ParsedTemplateNode[];\nexport declare const interpolateHandlebars: (template: string, values: InputValues) => string;\nexport type HandlebarsPromptTemplateInput<RunInput extends InputValues> = CustomFormatPromptTemplateInput<RunInput>;\nexport declare class HandlebarsPromptTemplate<RunInput extends InputValues = any> extends CustomFormatPromptTemplate<RunInput> {\n static lc_name(): string;\n /**\n * Load prompt template from a template\n */\n static fromTemplate<RunInput extends InputValues = Record<string, any>>(template: string, params?: Omit<HandlebarsPromptTemplateInput<RunInput>, \"template\" | \"inputVariables\" | \"customParser\" | \"templateValidator\" | \"renderer\">): CustomFormatPromptTemplate<RunInput extends Symbol ? never : RunInput, any>;\n}\n//# sourceMappingURL=handlebars.d.ts.map"],"mappings":";;;;;cAEqBG,uCAA6FC,wBAAAA,CAApBC,kBAAkB;cAC3FC,kDAAkDN;KAC3DO,+CAA+CP,eAAeE,gCAAgCM;AAFrFL,cAGAM,wBAH6FL,CAAAA,iBAGnDJ,WAH+BK,GAAkB,GAAA,CAAA,SAGtBJ,0BAHsB,CAGKO,QAHL,CAAA,CAAA;EAC3FF,OAAAA,OAAAA,CAAAA,CAAAA,EAAAA,MAAwE;EACjFC;;;EAA8DL,OAAAA,YAAAA,CAAAA,iBAMjCF,WANiCE,GAMnBQ,MANmBR,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CAAAA,CAAAA,QAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAM6BS,IAN7BT,CAMkCK,6BANlCL,CAMgEM,QANhEN,CAAAA,EAAAA,UAAAA,GAAAA,gBAAAA,GAAAA,cAAAA,GAAAA,mBAAAA,GAAAA,UAAAA,CAAAA,CAAAA,EAMgKD,0BANhKC,CAM2LM,QAN3LN,SAM4MU,MAN5MV,GAAAA,KAAAA,GAM6NM,QAN7NN,EAAAA,GAAAA,CAAAA;AAA+B"}
1
+ {"version":3,"file":"handlebars.d.cts","names":["InputValues","CustomFormatPromptTemplate","CustomFormatPromptTemplateInput","parseHandlebars","_langchain_core_prompts0","ParsedTemplateNode","interpolateHandlebars","HandlebarsPromptTemplateInput","RunInput","HandlebarsPromptTemplate","Record","Omit","Symbol"],"sources":["../../../src/experimental/prompts/handlebars.d.ts"],"sourcesContent":["import type { InputValues } from \"@langchain/core/utils/types\";\nimport { CustomFormatPromptTemplate, CustomFormatPromptTemplateInput } from \"./custom_format.js\";\nexport declare const parseHandlebars: (template: string) => import(\"@langchain/core/prompts\").ParsedTemplateNode[];\nexport declare const interpolateHandlebars: (template: string, values: InputValues) => string;\nexport type HandlebarsPromptTemplateInput<RunInput extends InputValues> = CustomFormatPromptTemplateInput<RunInput>;\nexport declare class HandlebarsPromptTemplate<RunInput extends InputValues = any> extends CustomFormatPromptTemplate<RunInput> {\n static lc_name(): string;\n /**\n * Load prompt template from a template\n */\n static fromTemplate<RunInput extends InputValues = Record<string, any>>(template: string, params?: Omit<HandlebarsPromptTemplateInput<RunInput>, \"template\" | \"inputVariables\" | \"customParser\" | \"templateValidator\" | \"renderer\">): CustomFormatPromptTemplate<RunInput extends Symbol ? never : RunInput, any>;\n}\n//# sourceMappingURL=handlebars.d.ts.map"],"mappings":";;;;;cAEqBG,uCAA6FC,wBAAAA,CAApBC,kBAAkB;cAC3FC,kDAAkDN;KAC3DO,+CAA+CP,eAAeE,gCAAgCM;AAFrFL,cAGAM,wBAH6FL,CAAAA,iBAGnDJ,WAH+BK,GAAAA,GAAkB,CAAA,SAGtBJ,0BAHsB,CAGKO,QAHL,CAAA,CAAA;EAC3FF,OAAAA,OAAAA,CAAAA,CAAAA,EAAAA,MAAwE;EACjFC;;;EAA8DL,OAAAA,YAAAA,CAAAA,iBAMjCF,WANiCE,GAMnBQ,MANmBR,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CAAAA,CAAAA,QAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAM6BS,IAN7BT,CAMkCK,6BANlCL,CAMgEM,QANhEN,CAAAA,EAAAA,UAAAA,GAAAA,gBAAAA,GAAAA,cAAAA,GAAAA,mBAAAA,GAAAA,UAAAA,CAAAA,CAAAA,EAMgKD,0BANhKC,CAM2LM,QAN3LN,SAM4MU,MAN5MV,GAAAA,KAAAA,GAM6NM,QAN7NN,EAAAA,GAAAA,CAAAA;AAA+B"}
@@ -16,12 +16,19 @@ const require_base = require('./base.cjs');
16
16
  * for non-OpenAI models. If you are running in Node or another environment that supports dynamic imports,
17
17
  * you may instead import this function from "langchain/hub/node" and pass "includeModel: true" instead
18
18
  * of specifying this parameter.
19
+ * @param options.secrets A map of secrets to use when loading, e.g.
20
+ * {'OPENAI_API_KEY': 'sk-...'}`.
21
+ * If a secret is not found in the map, it will be loaded from the
22
+ * environment if `secrets_from_env` is `True`. Should only be needed when
23
+ * `includeModel` is `true`.
24
+ * @param options.secretsFromEnv Whether to load secrets from environment variables.
25
+ * Use with caution and only with trusted prompts.
19
26
  * @returns
20
27
  */
21
28
  async function pull(ownerRepoCommit, options) {
22
29
  const promptObject = await require_base.basePull(ownerRepoCommit, options);
23
30
  try {
24
- const loadedPrompt = await require_load_index.load(JSON.stringify(promptObject.manifest), void 0, require_base.generateOptionalImportMap(options?.modelClass), require_base.generateModelImportMap(options?.modelClass));
31
+ const loadedPrompt = await require_load_index.load(JSON.stringify(promptObject.manifest), options?.secrets, require_base.generateOptionalImportMap(options?.modelClass), require_base.generateModelImportMap(options?.modelClass), options?.secretsFromEnv);
25
32
  return require_base.bindOutputSchema(loadedPrompt);
26
33
  } catch (e) {
27
34
  if (options?.includeModel) throw new Error([
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","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 }","basePull","load","generateOptionalImportMap","generateModelImportMap","bindOutputSchema","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 * @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 }\n) {\n const promptObject = await basePull(ownerRepoCommit, options);\n try {\n const loadedPrompt = await load<T>(\n JSON.stringify(promptObject.manifest),\n undefined,\n generateOptionalImportMap(options?.modelClass),\n generateModelImportMap(options?.modelClass)\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":";;;;;;;;;;;;;;;;;;;;AA6BA,eAAsB,KACpBA,iBACAC,SAOA;CACA,MAAM,eAAe,MAAMC,sBAAS,iBAAiB,QAAQ;AAC7D,KAAI;EACF,MAAM,eAAe,MAAMC,wBACzB,KAAK,UAAU,aAAa,SAAS,EACrC,QACAC,uCAA0B,SAAS,WAAW,EAC9CC,oCAAuB,SAAS,WAAW,CAC5C;AACD,SAAOC,8BAAiB,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.cjs","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 }","basePull","load","generateOptionalImportMap","generateModelImportMap","bindOutputSchema","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,MAAMC,sBAAS,iBAAiB,QAAQ;AAC7D,KAAI;EACF,MAAM,eAAe,MAAMC,wBACzB,KAAK,UAAU,aAAa,SAAS,EACrC,SAAS,SACTC,uCAA0B,SAAS,WAAW,EAC9CC,oCAAuB,SAAS,WAAW,EAC3C,SAAS,eACV;AACD,SAAOC,8BAAiB,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"}
@@ -18,6 +18,13 @@ import { BaseLanguageModel } from "@langchain/core/language_models/base";
18
18
  * for non-OpenAI models. If you are running in Node or another environment that supports dynamic imports,
19
19
  * you may instead import this function from "langchain/hub/node" and pass "includeModel: true" instead
20
20
  * of specifying this parameter.
21
+ * @param options.secrets A map of secrets to use when loading, e.g.
22
+ * {'OPENAI_API_KEY': 'sk-...'}`.
23
+ * If a secret is not found in the map, it will be loaded from the
24
+ * environment if `secrets_from_env` is `True`. Should only be needed when
25
+ * `includeModel` is `true`.
26
+ * @param options.secretsFromEnv Whether to load secrets from environment variables.
27
+ * Use with caution and only with trusted prompts.
21
28
  * @returns
22
29
  */
23
30
  declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
@@ -25,6 +32,8 @@ declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
25
32
  apiUrl?: string;
26
33
  includeModel?: boolean;
27
34
  modelClass?: new (...args: any[]) => BaseLanguageModel;
35
+ secrets?: Record<string, string>;
36
+ secretsFromEnv?: boolean;
28
37
  }): Promise<T>;
29
38
  //#endregion
30
39
  export { pull, basePush as push };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":["Runnable","BaseLanguageModel","basePush","push","pull","T","Promise"],"sources":["../../src/hub/index.d.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport { basePush } from \"./base.js\";\nexport { basePush as push };\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 * @returns\n */\nexport declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n modelClass?: new (...args: any[]) => BaseLanguageModel;\n}): Promise<T>;\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;AAoBA;;;;;AAKW;;;;;;;;;;iBALaI,eAAeJ;;;;uCAIEC;IACrCK,QAAQD"}
1
+ {"version":3,"file":"index.d.cts","names":["Runnable","BaseLanguageModel","basePush","push","pull","T","Record","Promise"],"sources":["../../src/hub/index.d.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport { basePush } from \"./base.js\";\nexport { basePush as push };\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 declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n modelClass?: new (...args: any[]) => BaseLanguageModel;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n}): Promise<T>;\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;AA2BA;;;;;;AAOW;;;;;;;;;;;;;;;;iBAPaI,eAAeJ;;;;uCAIEC;YAC3BK;;IAEVC,QAAQF"}
@@ -18,6 +18,13 @@ import { BaseLanguageModel } from "@langchain/core/language_models/base";
18
18
  * for non-OpenAI models. If you are running in Node or another environment that supports dynamic imports,
19
19
  * you may instead import this function from "langchain/hub/node" and pass "includeModel: true" instead
20
20
  * of specifying this parameter.
21
+ * @param options.secrets A map of secrets to use when loading, e.g.
22
+ * {'OPENAI_API_KEY': 'sk-...'}`.
23
+ * If a secret is not found in the map, it will be loaded from the
24
+ * environment if `secrets_from_env` is `True`. Should only be needed when
25
+ * `includeModel` is `true`.
26
+ * @param options.secretsFromEnv Whether to load secrets from environment variables.
27
+ * Use with caution and only with trusted prompts.
21
28
  * @returns
22
29
  */
23
30
  declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
@@ -25,6 +32,8 @@ declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
25
32
  apiUrl?: string;
26
33
  includeModel?: boolean;
27
34
  modelClass?: new (...args: any[]) => BaseLanguageModel;
35
+ secrets?: Record<string, string>;
36
+ secretsFromEnv?: boolean;
28
37
  }): Promise<T>;
29
38
  //#endregion
30
39
  export { pull, basePush as push };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["Runnable","BaseLanguageModel","basePush","push","pull","T","Promise"],"sources":["../../src/hub/index.d.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport { basePush } from \"./base.js\";\nexport { basePush as push };\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 * @returns\n */\nexport declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n modelClass?: new (...args: any[]) => BaseLanguageModel;\n}): Promise<T>;\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;AAoBA;;;;;AAKW;;;;;;;;;;iBALaI,eAAeJ;;;;uCAIEC;IACrCK,QAAQD"}
1
+ {"version":3,"file":"index.d.ts","names":["Runnable","BaseLanguageModel","basePush","push","pull","T","Record","Promise"],"sources":["../../src/hub/index.d.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport { basePush } from \"./base.js\";\nexport { basePush as push };\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 declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n modelClass?: new (...args: any[]) => BaseLanguageModel;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n}): Promise<T>;\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;AA2BA;;;;;;AAOW;;;;;;;;;;;;;;;;iBAPaI,eAAeJ;;;;uCAIEC;YAC3BK;;IAEVC,QAAQF"}
package/dist/hub/index.js CHANGED
@@ -16,12 +16,19 @@ import { basePull, basePush, bindOutputSchema, generateModelImportMap, generateO
16
16
  * for non-OpenAI models. If you are running in Node or another environment that supports dynamic imports,
17
17
  * you may instead import this function from "langchain/hub/node" and pass "includeModel: true" instead
18
18
  * of specifying this parameter.
19
+ * @param options.secrets A map of secrets to use when loading, e.g.
20
+ * {'OPENAI_API_KEY': 'sk-...'}`.
21
+ * If a secret is not found in the map, it will be loaded from the
22
+ * environment if `secrets_from_env` is `True`. Should only be needed when
23
+ * `includeModel` is `true`.
24
+ * @param options.secretsFromEnv Whether to load secrets from environment variables.
25
+ * Use with caution and only with trusted prompts.
19
26
  * @returns
20
27
  */
21
28
  async function pull(ownerRepoCommit, options) {
22
29
  const promptObject = await basePull(ownerRepoCommit, options);
23
30
  try {
24
- const loadedPrompt = await load(JSON.stringify(promptObject.manifest), void 0, generateOptionalImportMap(options?.modelClass), generateModelImportMap(options?.modelClass));
31
+ const loadedPrompt = await load(JSON.stringify(promptObject.manifest), options?.secrets, generateOptionalImportMap(options?.modelClass), generateModelImportMap(options?.modelClass), options?.secretsFromEnv);
25
32
  return bindOutputSchema(loadedPrompt);
26
33
  } catch (e) {
27
34
  if (options?.includeModel) throw new Error([
@@ -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 }","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 * @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 }\n) {\n const promptObject = await basePull(ownerRepoCommit, options);\n try {\n const loadedPrompt = await load<T>(\n JSON.stringify(promptObject.manifest),\n undefined,\n generateOptionalImportMap(options?.modelClass),\n generateModelImportMap(options?.modelClass)\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":";;;;;;;;;;;;;;;;;;;;AA6BA,eAAsB,KACpBA,iBACAC,SAOA;CACA,MAAM,eAAe,MAAM,SAAS,iBAAiB,QAAQ;AAC7D,KAAI;EACF,MAAM,eAAe,MAAM,KACzB,KAAK,UAAU,aAAa,SAAS,EACrC,QACA,0BAA0B,SAAS,WAAW,EAC9C,uBAAuB,SAAS,WAAW,CAC5C;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 }","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"}
package/dist/hub/node.cjs CHANGED
@@ -3,6 +3,25 @@ const require_load_index = require('../load/index.cjs');
3
3
  const require_base = require('./base.cjs');
4
4
 
5
5
  //#region src/hub/node.ts
6
+ function _idEquals(a, b) {
7
+ if (!Array.isArray(a) || !Array.isArray(b)) return false;
8
+ if (a.length !== b.length) return false;
9
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
10
+ return true;
11
+ }
12
+ function isRunnableBinding(a) {
13
+ const wellKnownIds = [[
14
+ "langchain_core",
15
+ "runnables",
16
+ "RunnableBinding"
17
+ ], [
18
+ "langchain",
19
+ "schema",
20
+ "runnable",
21
+ "RunnableBinding"
22
+ ]];
23
+ return wellKnownIds.some((id) => _idEquals(a, id));
24
+ }
6
25
  /**
7
26
  * Pull a prompt from the hub.
8
27
  * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.
@@ -11,21 +30,29 @@ const require_base = require('./base.cjs');
11
30
  * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,
12
31
  * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will
13
32
  * also invoke the instantiated model. You must have the appropriate LangChain integration package installed.
33
+ * @param options.secrets A map of secrets to use when loading, e.g.
34
+ * {'OPENAI_API_KEY': 'sk-...'}`.
35
+ * If a secret is not found in the map, it will be loaded from the
36
+ * environment if `secrets_from_env` is `True`. Should only be needed when
37
+ * `includeModel` is `true`.
38
+ * @param options.secretsFromEnv Whether to load secrets from environment variables.
39
+ * Use with caution and only with trusted prompts.
14
40
  * @returns
15
41
  */
16
42
  async function pull(ownerRepoCommit, options) {
17
43
  const promptObject = await require_base.basePull(ownerRepoCommit, options);
18
44
  let modelClass;
19
45
  if (options?.includeModel) {
20
- if (Array.isArray(promptObject.manifest.kwargs?.last?.kwargs?.bound?.id)) {
21
- const modelName = promptObject.manifest.kwargs?.last?.kwargs?.bound?.id.at(-1);
46
+ const chatModelObject = isRunnableBinding(promptObject.manifest.kwargs?.last?.id) ? promptObject.manifest.kwargs?.last?.kwargs?.bound : promptObject.manifest.kwargs?.last;
47
+ if (Array.isArray(chatModelObject?.id)) {
48
+ const modelName = chatModelObject?.id.at(-1);
22
49
  if (modelName) {
23
50
  modelClass = await require_chat_models_universal.getChatModelByClassName(modelName);
24
51
  if (!modelClass) console.warn(`Received unknown model name from prompt hub: "${modelName}"`);
25
52
  }
26
53
  }
27
54
  }
28
- const loadedPrompt = await require_load_index.load(JSON.stringify(promptObject.manifest), void 0, require_base.generateOptionalImportMap(modelClass), require_base.generateModelImportMap(modelClass));
55
+ const loadedPrompt = await require_load_index.load(JSON.stringify(promptObject.manifest), options?.secrets, require_base.generateOptionalImportMap(modelClass), require_base.generateModelImportMap(modelClass), options?.secretsFromEnv);
29
56
  return require_base.bindOutputSchema(loadedPrompt);
30
57
  }
31
58
 
@@ -1 +1 @@
1
- {"version":3,"file":"node.cjs","names":["ownerRepoCommit: string","options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: 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\n// TODO: Make this the default, add web entrypoint in next breaking release\n\nexport { basePush as push } from \"./base.js\";\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 * @returns\n */\nexport async function pull<T extends Runnable>(\n ownerRepoCommit: string,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n }\n) {\n const promptObject = await basePull(ownerRepoCommit, options);\n let modelClass;\n if (options?.includeModel) {\n if (Array.isArray(promptObject.manifest.kwargs?.last?.kwargs?.bound?.id)) {\n const modelName =\n promptObject.manifest.kwargs?.last?.kwargs?.bound?.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 undefined,\n generateOptionalImportMap(modelClass),\n generateModelImportMap(modelClass)\n );\n return bindOutputSchema(loadedPrompt);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,eAAsB,KACpBA,iBACAC,SAKA;CACA,MAAM,eAAe,MAAMC,sBAAS,iBAAiB,QAAQ;CAC7D,IAAI;AACJ,KAAI,SAAS,cACX;MAAI,MAAM,QAAQ,aAAa,SAAS,QAAQ,MAAM,QAAQ,OAAO,GAAG,EAAE;GACxE,MAAM,YACJ,aAAa,SAAS,QAAQ,MAAM,QAAQ,OAAO,GAAG,GAAG,GAAG;AAE9D,OAAI,WAAW;IACb,aAAa,MAAMC,sDAAwB,UAAU;AACrD,QAAI,CAAC,YACH,QAAQ,KACN,CAAC,8CAA8C,EAAE,UAAU,CAAC,CAAC,CAC9D;GAEJ;EACF;;CAEH,MAAM,eAAe,MAAMC,wBACzB,KAAK,UAAU,aAAa,SAAS,EACrC,QACAC,uCAA0B,WAAW,EACrCC,oCAAuB,WAAW,CACnC;AACD,QAAOC,8BAAiB,aAAa;AACtC"}
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"}
@@ -11,12 +11,21 @@ import { Runnable } from "@langchain/core/runnables";
11
11
  * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,
12
12
  * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will
13
13
  * also invoke the instantiated model. You must have the appropriate LangChain integration package installed.
14
+ * @param options.secrets A map of secrets to use when loading, e.g.
15
+ * {'OPENAI_API_KEY': 'sk-...'}`.
16
+ * If a secret is not found in the map, it will be loaded from the
17
+ * environment if `secrets_from_env` is `True`. Should only be needed when
18
+ * `includeModel` is `true`.
19
+ * @param options.secretsFromEnv Whether to load secrets from environment variables.
20
+ * Use with caution and only with trusted prompts.
14
21
  * @returns
15
22
  */
16
23
  declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
17
24
  apiKey?: string;
18
25
  apiUrl?: string;
19
26
  includeModel?: boolean;
27
+ secrets?: Record<string, string>;
28
+ secretsFromEnv?: boolean;
20
29
  }): Promise<T>;
21
30
  //#endregion
22
31
  export { pull, basePush as push };
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.cts","names":["Runnable","basePush","push","pull","T","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 * @returns\n */\nexport declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n}): Promise<T>;\n//# sourceMappingURL=node.d.ts.map"],"mappings":";;;;;;;AAYA;;;;AAIW;;;;iBAJaG,eAAeH;;;;IAInCK,QAAQD"}
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"}
@@ -11,12 +11,21 @@ import { Runnable } from "@langchain/core/runnables";
11
11
  * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,
12
12
  * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will
13
13
  * also invoke the instantiated model. You must have the appropriate LangChain integration package installed.
14
+ * @param options.secrets A map of secrets to use when loading, e.g.
15
+ * {'OPENAI_API_KEY': 'sk-...'}`.
16
+ * If a secret is not found in the map, it will be loaded from the
17
+ * environment if `secrets_from_env` is `True`. Should only be needed when
18
+ * `includeModel` is `true`.
19
+ * @param options.secretsFromEnv Whether to load secrets from environment variables.
20
+ * Use with caution and only with trusted prompts.
14
21
  * @returns
15
22
  */
16
23
  declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
17
24
  apiKey?: string;
18
25
  apiUrl?: string;
19
26
  includeModel?: boolean;
27
+ secrets?: Record<string, string>;
28
+ secretsFromEnv?: boolean;
20
29
  }): Promise<T>;
21
30
  //#endregion
22
31
  export { pull, basePush as push };
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","names":["Runnable","basePush","push","pull","T","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 * @returns\n */\nexport declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n}): Promise<T>;\n//# sourceMappingURL=node.d.ts.map"],"mappings":";;;;;;;AAYA;;;;AAIW;;;;iBAJaG,eAAeH;;;;IAInCK,QAAQD"}
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"}
package/dist/hub/node.js CHANGED
@@ -3,6 +3,25 @@ import { load } from "../load/index.js";
3
3
  import { basePull, basePush, bindOutputSchema, generateModelImportMap, generateOptionalImportMap } from "./base.js";
4
4
 
5
5
  //#region src/hub/node.ts
6
+ function _idEquals(a, b) {
7
+ if (!Array.isArray(a) || !Array.isArray(b)) return false;
8
+ if (a.length !== b.length) return false;
9
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
10
+ return true;
11
+ }
12
+ function isRunnableBinding(a) {
13
+ const wellKnownIds = [[
14
+ "langchain_core",
15
+ "runnables",
16
+ "RunnableBinding"
17
+ ], [
18
+ "langchain",
19
+ "schema",
20
+ "runnable",
21
+ "RunnableBinding"
22
+ ]];
23
+ return wellKnownIds.some((id) => _idEquals(a, id));
24
+ }
6
25
  /**
7
26
  * Pull a prompt from the hub.
8
27
  * @param ownerRepoCommit The name of the repo containing the prompt, as well as an optional commit hash separated by a slash.
@@ -11,21 +30,29 @@ import { basePull, basePush, bindOutputSchema, generateModelImportMap, generateO
11
30
  * @param options.includeModel Whether to also instantiate and attach a model instance to the prompt,
12
31
  * if the prompt has associated model metadata. If set to true, invoking the resulting pulled prompt will
13
32
  * also invoke the instantiated model. You must have the appropriate LangChain integration package installed.
33
+ * @param options.secrets A map of secrets to use when loading, e.g.
34
+ * {'OPENAI_API_KEY': 'sk-...'}`.
35
+ * If a secret is not found in the map, it will be loaded from the
36
+ * environment if `secrets_from_env` is `True`. Should only be needed when
37
+ * `includeModel` is `true`.
38
+ * @param options.secretsFromEnv Whether to load secrets from environment variables.
39
+ * Use with caution and only with trusted prompts.
14
40
  * @returns
15
41
  */
16
42
  async function pull(ownerRepoCommit, options) {
17
43
  const promptObject = await basePull(ownerRepoCommit, options);
18
44
  let modelClass;
19
45
  if (options?.includeModel) {
20
- if (Array.isArray(promptObject.manifest.kwargs?.last?.kwargs?.bound?.id)) {
21
- const modelName = promptObject.manifest.kwargs?.last?.kwargs?.bound?.id.at(-1);
46
+ const chatModelObject = isRunnableBinding(promptObject.manifest.kwargs?.last?.id) ? promptObject.manifest.kwargs?.last?.kwargs?.bound : promptObject.manifest.kwargs?.last;
47
+ if (Array.isArray(chatModelObject?.id)) {
48
+ const modelName = chatModelObject?.id.at(-1);
22
49
  if (modelName) {
23
50
  modelClass = await getChatModelByClassName(modelName);
24
51
  if (!modelClass) console.warn(`Received unknown model name from prompt hub: "${modelName}"`);
25
52
  }
26
53
  }
27
54
  }
28
- const loadedPrompt = await load(JSON.stringify(promptObject.manifest), void 0, generateOptionalImportMap(modelClass), generateModelImportMap(modelClass));
55
+ const loadedPrompt = await load(JSON.stringify(promptObject.manifest), options?.secrets, generateOptionalImportMap(modelClass), generateModelImportMap(modelClass), options?.secretsFromEnv);
29
56
  return bindOutputSchema(loadedPrompt);
30
57
  }
31
58
 
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","names":["ownerRepoCommit: string","options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: 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\n// TODO: Make this the default, add web entrypoint in next breaking release\n\nexport { basePush as push } from \"./base.js\";\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 * @returns\n */\nexport async function pull<T extends Runnable>(\n ownerRepoCommit: string,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n }\n) {\n const promptObject = await basePull(ownerRepoCommit, options);\n let modelClass;\n if (options?.includeModel) {\n if (Array.isArray(promptObject.manifest.kwargs?.last?.kwargs?.bound?.id)) {\n const modelName =\n promptObject.manifest.kwargs?.last?.kwargs?.bound?.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 undefined,\n generateOptionalImportMap(modelClass),\n generateModelImportMap(modelClass)\n );\n return bindOutputSchema(loadedPrompt);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,eAAsB,KACpBA,iBACAC,SAKA;CACA,MAAM,eAAe,MAAM,SAAS,iBAAiB,QAAQ;CAC7D,IAAI;AACJ,KAAI,SAAS,cACX;MAAI,MAAM,QAAQ,aAAa,SAAS,QAAQ,MAAM,QAAQ,OAAO,GAAG,EAAE;GACxE,MAAM,YACJ,aAAa,SAAS,QAAQ,MAAM,QAAQ,OAAO,GAAG,GAAG,GAAG;AAE9D,OAAI,WAAW;IACb,aAAa,MAAM,wBAAwB,UAAU;AACrD,QAAI,CAAC,YACH,QAAQ,KACN,CAAC,8CAA8C,EAAE,UAAU,CAAC,CAAC,CAC9D;GAEJ;EACF;;CAEH,MAAM,eAAe,MAAM,KACzB,KAAK,UAAU,aAAa,SAAS,EACrC,QACA,0BAA0B,WAAW,EACrC,uBAAuB,WAAW,CACnC;AACD,QAAO,iBAAiB,aAAa;AACtC"}
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"}
@@ -13,7 +13,7 @@ const __langchain_core_load = require_rolldown_runtime.__toESM(require("@langcha
13
13
  * @param optionalImportsMap
14
14
  * @returns A loaded instance of a LangChain module.
15
15
  */
16
- async function load(text, secretsMap = {}, optionalImportsMap = {}, additionalImportsMap = {}) {
16
+ async function load(text, secretsMap = {}, optionalImportsMap = {}, additionalImportsMap = {}, secretsFromEnv) {
17
17
  return (0, __langchain_core_load.load)(text, {
18
18
  secretsMap,
19
19
  optionalImportsMap,
@@ -21,7 +21,8 @@ async function load(text, secretsMap = {}, optionalImportsMap = {}, additionalIm
21
21
  importMap: {
22
22
  ...require_import_map.import_map_exports,
23
23
  ...additionalImportsMap
24
- }
24
+ },
25
+ secretsFromEnv
25
26
  });
26
27
  }
27
28
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["text: string","secretsMap: Record<string, any>","optionalImportsMap: OptionalImportMap & Record<string, any>","additionalImportsMap: Record<string, any>","importMap"],"sources":["../../src/load/index.ts"],"sourcesContent":["import { load as coreLoad } from \"@langchain/core/load\";\nimport { optionalImportEntrypoints } from \"./import_constants.js\";\nimport * as importMap from \"./import_map.js\";\nimport { OptionalImportMap } from \"./import_type.js\";\n\n/**\n * Load a LangChain module from a serialized text representation.\n * NOTE: This functionality is currently in beta.\n * Loaded classes may change independently of semver.\n * @param text Serialized text representation of the module.\n * @param secretsMap\n * @param optionalImportsMap\n * @returns A loaded instance of a LangChain module.\n */\nexport async function load<T>(\n text: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n secretsMap: Record<string, any> = {},\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n optionalImportsMap: OptionalImportMap & Record<string, any> = {},\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n additionalImportsMap: Record<string, any> = {}\n): Promise<T> {\n return coreLoad(text, {\n secretsMap,\n optionalImportsMap,\n optionalImportEntrypoints,\n importMap: { ...importMap, ...additionalImportsMap },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,eAAsB,KACpBA,MAEAC,aAAkC,CAAE,GAEpCC,qBAA8D,CAAE,GAEhEC,uBAA4C,CAAE,GAClC;AACZ,wCAAgB,MAAM;EACpB;EACA;EACA;EACA,WAAW;GAAE,GAAGC;GAAW,GAAG;EAAsB;CACrD,EAAC;AACH"}
1
+ {"version":3,"file":"index.cjs","names":["text: string","secretsMap: Record<string, any>","optionalImportsMap: OptionalImportMap & Record<string, any>","additionalImportsMap: Record<string, any>","secretsFromEnv?: boolean","importMap"],"sources":["../../src/load/index.ts"],"sourcesContent":["import { load as coreLoad } from \"@langchain/core/load\";\nimport { optionalImportEntrypoints } from \"./import_constants.js\";\nimport * as importMap from \"./import_map.js\";\nimport { OptionalImportMap } from \"./import_type.js\";\n\n/**\n * Load a LangChain module from a serialized text representation.\n * NOTE: This functionality is currently in beta.\n * Loaded classes may change independently of semver.\n * @param text Serialized text representation of the module.\n * @param secretsMap\n * @param optionalImportsMap\n * @returns A loaded instance of a LangChain module.\n */\nexport async function load<T>(\n text: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n secretsMap: Record<string, any> = {},\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n optionalImportsMap: OptionalImportMap & Record<string, any> = {},\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n additionalImportsMap: Record<string, any> = {},\n secretsFromEnv?: boolean\n): Promise<T> {\n return coreLoad(text, {\n secretsMap,\n optionalImportsMap,\n optionalImportEntrypoints,\n importMap: { ...importMap, ...additionalImportsMap },\n secretsFromEnv,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,eAAsB,KACpBA,MAEAC,aAAkC,CAAE,GAEpCC,qBAA8D,CAAE,GAEhEC,uBAA4C,CAAE,GAC9CC,gBACY;AACZ,wCAAgB,MAAM;EACpB;EACA;EACA;EACA,WAAW;GAAE,GAAGC;GAAW,GAAG;EAAsB;EACpD;CACD,EAAC;AACH"}
@@ -11,7 +11,7 @@ import { OptionalImportMap } from "./import_type.cjs";
11
11
  * @param optionalImportsMap
12
12
  * @returns A loaded instance of a LangChain module.
13
13
  */
14
- declare function load<T>(text: string, secretsMap?: Record<string, any>, optionalImportsMap?: OptionalImportMap & Record<string, any>, additionalImportsMap?: Record<string, any>): Promise<T>;
14
+ declare function load<T>(text: string, secretsMap?: Record<string, any>, optionalImportsMap?: OptionalImportMap & Record<string, any>, additionalImportsMap?: Record<string, any>, secretsFromEnv?: boolean): Promise<T>;
15
15
  //#endregion
16
16
  export { load };
17
17
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":["OptionalImportMap","load","T","Record","Promise"],"sources":["../../src/load/index.d.ts"],"sourcesContent":["import { OptionalImportMap } from \"./import_type.js\";\n/**\n * Load a LangChain module from a serialized text representation.\n * NOTE: This functionality is currently in beta.\n * Loaded classes may change independently of semver.\n * @param text Serialized text representation of the module.\n * @param secretsMap\n * @param optionalImportsMap\n * @returns A loaded instance of a LangChain module.\n */\nexport declare function load<T>(text: string, secretsMap?: Record<string, any>, optionalImportsMap?: OptionalImportMap & Record<string, any>, additionalImportsMap?: Record<string, any>): Promise<T>;\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;AAUA;;;;;;;AAAkM,iBAA1KC,IAA0K,CAAA,CAAA,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,UAAA,CAAA,EAAvIE,MAAuI,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,kBAAA,CAAA,EAA7FH,iBAA6F,GAAzEG,MAAyE,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,oBAAA,CAAA,EAA7BA,MAA6B,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,EAAPC,OAAO,CAACF,CAAD,CAAA"}
1
+ {"version":3,"file":"index.d.cts","names":["OptionalImportMap","load","T","Record","Promise"],"sources":["../../src/load/index.d.ts"],"sourcesContent":["import { OptionalImportMap } from \"./import_type.js\";\n/**\n * Load a LangChain module from a serialized text representation.\n * NOTE: This functionality is currently in beta.\n * Loaded classes may change independently of semver.\n * @param text Serialized text representation of the module.\n * @param secretsMap\n * @param optionalImportsMap\n * @returns A loaded instance of a LangChain module.\n */\nexport declare function load<T>(text: string, secretsMap?: Record<string, any>, optionalImportsMap?: OptionalImportMap & Record<string, any>, additionalImportsMap?: Record<string, any>, secretsFromEnv?: boolean): Promise<T>;\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;AAUA;;;;;;;AAA4N,iBAApMC,IAAoM,CAAA,CAAA,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,UAAA,CAAA,EAAjKE,MAAiK,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,kBAAA,CAAA,EAAvHH,iBAAuH,GAAnGG,MAAmG,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,oBAAA,CAAA,EAAvDA,MAAuD,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,cAAA,CAAA,EAAA,OAAA,CAAA,EAAPC,OAAO,CAACF,CAAD,CAAA"}
@@ -11,7 +11,7 @@ import { OptionalImportMap } from "./import_type.js";
11
11
  * @param optionalImportsMap
12
12
  * @returns A loaded instance of a LangChain module.
13
13
  */
14
- declare function load<T>(text: string, secretsMap?: Record<string, any>, optionalImportsMap?: OptionalImportMap & Record<string, any>, additionalImportsMap?: Record<string, any>): Promise<T>;
14
+ declare function load<T>(text: string, secretsMap?: Record<string, any>, optionalImportsMap?: OptionalImportMap & Record<string, any>, additionalImportsMap?: Record<string, any>, secretsFromEnv?: boolean): Promise<T>;
15
15
  //#endregion
16
16
  export { load };
17
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["OptionalImportMap","load","T","Record","Promise"],"sources":["../../src/load/index.d.ts"],"sourcesContent":["import { OptionalImportMap } from \"./import_type.js\";\n/**\n * Load a LangChain module from a serialized text representation.\n * NOTE: This functionality is currently in beta.\n * Loaded classes may change independently of semver.\n * @param text Serialized text representation of the module.\n * @param secretsMap\n * @param optionalImportsMap\n * @returns A loaded instance of a LangChain module.\n */\nexport declare function load<T>(text: string, secretsMap?: Record<string, any>, optionalImportsMap?: OptionalImportMap & Record<string, any>, additionalImportsMap?: Record<string, any>): Promise<T>;\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;AAUA;;;;;;;AAAkM,iBAA1KC,IAA0K,CAAA,CAAA,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,UAAA,CAAA,EAAvIE,MAAuI,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,kBAAA,CAAA,EAA7FH,iBAA6F,GAAzEG,MAAyE,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,oBAAA,CAAA,EAA7BA,MAA6B,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,EAAPC,OAAO,CAACF,CAAD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","names":["OptionalImportMap","load","T","Record","Promise"],"sources":["../../src/load/index.d.ts"],"sourcesContent":["import { OptionalImportMap } from \"./import_type.js\";\n/**\n * Load a LangChain module from a serialized text representation.\n * NOTE: This functionality is currently in beta.\n * Loaded classes may change independently of semver.\n * @param text Serialized text representation of the module.\n * @param secretsMap\n * @param optionalImportsMap\n * @returns A loaded instance of a LangChain module.\n */\nexport declare function load<T>(text: string, secretsMap?: Record<string, any>, optionalImportsMap?: OptionalImportMap & Record<string, any>, additionalImportsMap?: Record<string, any>, secretsFromEnv?: boolean): Promise<T>;\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;AAUA;;;;;;;AAA4N,iBAApMC,IAAoM,CAAA,CAAA,CAAA,CAAA,IAAA,EAAA,MAAA,EAAA,UAAA,CAAA,EAAjKE,MAAiK,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,kBAAA,CAAA,EAAvHH,iBAAuH,GAAnGG,MAAmG,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,oBAAA,CAAA,EAAvDA,MAAuD,CAAA,MAAA,EAAA,GAAA,CAAA,EAAA,cAAA,CAAA,EAAA,OAAA,CAAA,EAAPC,OAAO,CAACF,CAAD,CAAA"}
@@ -12,7 +12,7 @@ import { load as load$1 } from "@langchain/core/load";
12
12
  * @param optionalImportsMap
13
13
  * @returns A loaded instance of a LangChain module.
14
14
  */
15
- async function load(text, secretsMap = {}, optionalImportsMap = {}, additionalImportsMap = {}) {
15
+ async function load(text, secretsMap = {}, optionalImportsMap = {}, additionalImportsMap = {}, secretsFromEnv) {
16
16
  return load$1(text, {
17
17
  secretsMap,
18
18
  optionalImportsMap,
@@ -20,7 +20,8 @@ async function load(text, secretsMap = {}, optionalImportsMap = {}, additionalIm
20
20
  importMap: {
21
21
  ...import_map_exports,
22
22
  ...additionalImportsMap
23
- }
23
+ },
24
+ secretsFromEnv
24
25
  });
25
26
  }
26
27
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["text: string","secretsMap: Record<string, any>","optionalImportsMap: OptionalImportMap & Record<string, any>","additionalImportsMap: Record<string, any>","coreLoad","importMap"],"sources":["../../src/load/index.ts"],"sourcesContent":["import { load as coreLoad } from \"@langchain/core/load\";\nimport { optionalImportEntrypoints } from \"./import_constants.js\";\nimport * as importMap from \"./import_map.js\";\nimport { OptionalImportMap } from \"./import_type.js\";\n\n/**\n * Load a LangChain module from a serialized text representation.\n * NOTE: This functionality is currently in beta.\n * Loaded classes may change independently of semver.\n * @param text Serialized text representation of the module.\n * @param secretsMap\n * @param optionalImportsMap\n * @returns A loaded instance of a LangChain module.\n */\nexport async function load<T>(\n text: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n secretsMap: Record<string, any> = {},\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n optionalImportsMap: OptionalImportMap & Record<string, any> = {},\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n additionalImportsMap: Record<string, any> = {}\n): Promise<T> {\n return coreLoad(text, {\n secretsMap,\n optionalImportsMap,\n optionalImportEntrypoints,\n importMap: { ...importMap, ...additionalImportsMap },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,eAAsB,KACpBA,MAEAC,aAAkC,CAAE,GAEpCC,qBAA8D,CAAE,GAEhEC,uBAA4C,CAAE,GAClC;AACZ,QAAOC,OAAS,MAAM;EACpB;EACA;EACA;EACA,WAAW;GAAE,GAAGC;GAAW,GAAG;EAAsB;CACrD,EAAC;AACH"}
1
+ {"version":3,"file":"index.js","names":["text: string","secretsMap: Record<string, any>","optionalImportsMap: OptionalImportMap & Record<string, any>","additionalImportsMap: Record<string, any>","secretsFromEnv?: boolean","coreLoad","importMap"],"sources":["../../src/load/index.ts"],"sourcesContent":["import { load as coreLoad } from \"@langchain/core/load\";\nimport { optionalImportEntrypoints } from \"./import_constants.js\";\nimport * as importMap from \"./import_map.js\";\nimport { OptionalImportMap } from \"./import_type.js\";\n\n/**\n * Load a LangChain module from a serialized text representation.\n * NOTE: This functionality is currently in beta.\n * Loaded classes may change independently of semver.\n * @param text Serialized text representation of the module.\n * @param secretsMap\n * @param optionalImportsMap\n * @returns A loaded instance of a LangChain module.\n */\nexport async function load<T>(\n text: string,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n secretsMap: Record<string, any> = {},\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n optionalImportsMap: OptionalImportMap & Record<string, any> = {},\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n additionalImportsMap: Record<string, any> = {},\n secretsFromEnv?: boolean\n): Promise<T> {\n return coreLoad(text, {\n secretsMap,\n optionalImportsMap,\n optionalImportEntrypoints,\n importMap: { ...importMap, ...additionalImportsMap },\n secretsFromEnv,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,eAAsB,KACpBA,MAEAC,aAAkC,CAAE,GAEpCC,qBAA8D,CAAE,GAEhEC,uBAA4C,CAAE,GAC9CC,gBACY;AACZ,QAAOC,OAAS,MAAM;EACpB;EACA;EACA;EACA,WAAW;GAAE,GAAGC;GAAW,GAAG;EAAsB;EACpD;CACD,EAAC;AACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/classic",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Old abstractions form LangChain.js",
5
5
  "author": "LangChain",
6
6
  "license": "MIT",
@@ -171,22 +171,22 @@
171
171
  "voy-search": "0.6.2",
172
172
  "weaviate-client": "^3.8.0",
173
173
  "zod-to-json-schema": "^3.24.6",
174
- "@langchain/anthropic": "1.3.2",
175
- "@langchain/aws": "1.1.0",
174
+ "@langchain/anthropic": "1.3.4",
175
+ "@langchain/aws": "1.1.1",
176
176
  "@langchain/azure-cosmosdb": "1.1.0",
177
177
  "@langchain/azure-dynamic-sessions": "1.0.1",
178
178
  "@langchain/baidu-qianfan": "1.0.1",
179
179
  "@langchain/cloudflare": "1.0.1",
180
180
  "@langchain/cohere": "1.0.1",
181
- "@langchain/core": "1.1.7",
182
- "@langchain/deepseek": "1.0.3",
181
+ "@langchain/core": "1.1.9",
182
+ "@langchain/deepseek": "1.0.4",
183
183
  "@langchain/eslint": "0.1.1",
184
184
  "@langchain/exa": "1.0.1",
185
- "@langchain/google-cloud-sql-pg": "1.0.8",
186
- "@langchain/google-common": "2.1.2",
187
- "@langchain/google-genai": "2.1.2",
188
- "@langchain/google-vertexai": "2.1.2",
189
- "@langchain/google-vertexai-web": "2.1.2",
185
+ "@langchain/google-cloud-sql-pg": "1.0.10",
186
+ "@langchain/google-common": "2.1.4",
187
+ "@langchain/google-genai": "2.1.4",
188
+ "@langchain/google-vertexai": "2.1.4",
189
+ "@langchain/google-vertexai-web": "2.1.4",
190
190
  "@langchain/groq": "1.0.2",
191
191
  "@langchain/mistralai": "1.0.2",
192
192
  "@langchain/mongodb": "1.1.0",
@@ -198,10 +198,10 @@
198
198
  "@langchain/tavily": "1.2.0",
199
199
  "@langchain/textsplitters": "1.0.1",
200
200
  "@langchain/weaviate": "1.0.1",
201
- "@langchain/xai": "1.1.0",
201
+ "@langchain/xai": "1.1.1",
202
202
  "@langchain/yandex": "1.0.1",
203
203
  "@langchain/tsconfig": "0.0.1",
204
- "langchain": "1.2.2"
204
+ "langchain": "1.2.4"
205
205
  },
206
206
  "peerDependencies": {
207
207
  "@langchain/core": "^1.0.0",
@@ -228,7 +228,7 @@
228
228
  "uuid": "^10.0.0",
229
229
  "yaml": "^2.2.1",
230
230
  "zod": "^3.25.76 || ^4",
231
- "@langchain/openai": "1.2.0",
231
+ "@langchain/openai": "1.2.1",
232
232
  "@langchain/textsplitters": "1.0.1"
233
233
  },
234
234
  "optionalDependencies": {