langchain 1.2.18 → 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 (44) hide show
  1. package/CHANGELOG.md +9 -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/nodes/AgentNode.cjs.map +1 -1
  9. package/dist/agents/nodes/AgentNode.js.map +1 -1
  10. package/dist/agents/responses.cjs.map +1 -1
  11. package/dist/agents/responses.d.cts +9 -0
  12. package/dist/agents/responses.d.cts.map +1 -1
  13. package/dist/agents/responses.d.ts +9 -0
  14. package/dist/agents/responses.d.ts.map +1 -1
  15. package/dist/agents/responses.js.map +1 -1
  16. package/dist/agents/utils.cjs.map +1 -1
  17. package/dist/agents/utils.js.map +1 -1
  18. package/dist/chat_models/universal.cjs.map +1 -1
  19. package/dist/chat_models/universal.js.map +1 -1
  20. package/dist/hub/base.cjs +6 -3
  21. package/dist/hub/base.cjs.map +1 -1
  22. package/dist/hub/base.d.cts +2 -0
  23. package/dist/hub/base.d.cts.map +1 -1
  24. package/dist/hub/base.d.ts +2 -0
  25. package/dist/hub/base.d.ts.map +1 -1
  26. package/dist/hub/base.js +6 -3
  27. package/dist/hub/base.js.map +1 -1
  28. package/dist/hub/index.cjs +2 -0
  29. package/dist/hub/index.cjs.map +1 -1
  30. package/dist/hub/index.d.cts +5 -0
  31. package/dist/hub/index.d.cts.map +1 -1
  32. package/dist/hub/index.d.ts +5 -0
  33. package/dist/hub/index.d.ts.map +1 -1
  34. package/dist/hub/index.js +2 -0
  35. package/dist/hub/index.js.map +1 -1
  36. package/dist/hub/node.cjs +2 -0
  37. package/dist/hub/node.cjs.map +1 -1
  38. package/dist/hub/node.d.cts +5 -0
  39. package/dist/hub/node.d.cts.map +1 -1
  40. package/dist/hub/node.d.ts +5 -0
  41. package/dist/hub/node.d.ts.map +1 -1
  42. package/dist/hub/node.js +2 -0
  43. package/dist/hub/node.js.map +1 -1
  44. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","names":["repoFullName: string","runnable: Runnable","options?: {\n apiKey?: string;\n apiUrl?: string;\n parentCommitHash?: string;\n isPublic?: boolean;\n description?: string;\n readme?: string;\n tags?: string[];\n }","ownerRepoCommit: string","options?: { apiKey?: string; apiUrl?: string; includeModel?: boolean }","varName: string","message: any","modelClass?: new (...args: any[]) => BaseLanguageModel","modelImportMap: Record<string, any>","optionalImportMap: Record<string, any>","loadedSequence: T"],"sources":["../../src/hub/base.ts"],"sourcesContent":["import type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport type { Runnable } from \"@langchain/core/runnables\";\n\nimport { Client } from \"langsmith\";\nimport type { PromptCommit } from \"langsmith/schemas\";\n\n/**\n * Push a prompt to the hub.\n * If the specified repo doesn't already exist, it will be created.\n * @param repoFullName The full name of the repo.\n * @param runnable The prompt to push.\n * @param options\n * @returns The URL of the newly pushed prompt in the hub.\n */\nexport async function basePush(\n repoFullName: string,\n runnable: Runnable,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n parentCommitHash?: string;\n isPublic?: boolean;\n description?: string;\n readme?: string;\n tags?: string[];\n }\n): Promise<string> {\n const client = new Client(options);\n const payloadOptions = {\n object: runnable,\n parentCommitHash: options?.parentCommitHash,\n isPublic: options?.isPublic,\n description: options?.description,\n readme: options?.readme,\n tags: options?.tags,\n };\n return client.pushPrompt(repoFullName, payloadOptions);\n}\n\nexport async function basePull(\n ownerRepoCommit: string,\n options?: { apiKey?: string; apiUrl?: string; includeModel?: boolean }\n): Promise<PromptCommit> {\n const client = new Client(options);\n\n const promptObject = await client.pullPromptCommit(ownerRepoCommit, {\n includeModel: options?.includeModel,\n });\n\n if (promptObject.manifest.kwargs?.metadata === undefined) {\n promptObject.manifest.kwargs = {\n ...promptObject.manifest.kwargs,\n metadata: {},\n };\n }\n\n promptObject.manifest.kwargs.metadata = {\n ...promptObject.manifest.kwargs.metadata,\n lc_hub_owner: promptObject.owner,\n lc_hub_repo: promptObject.repo,\n lc_hub_commit_hash: promptObject.commit_hash,\n };\n\n // Some nested mustache prompts have improperly parsed variables that include a dot.\n if (promptObject.manifest.kwargs.template_format === \"mustache\") {\n const stripDotNotation = (varName: string) => varName.split(\".\")[0];\n\n const { input_variables } = promptObject.manifest.kwargs;\n if (Array.isArray(input_variables)) {\n promptObject.manifest.kwargs.input_variables =\n input_variables.map(stripDotNotation);\n }\n\n const { messages } = promptObject.manifest.kwargs;\n if (Array.isArray(messages)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n promptObject.manifest.kwargs.messages = messages.map((message: any) => {\n const nestedVars = message?.kwargs?.prompt?.kwargs?.input_variables;\n if (Array.isArray(nestedVars)) {\n message.kwargs.prompt.kwargs.input_variables =\n nestedVars.map(stripDotNotation);\n }\n return message;\n });\n }\n }\n return promptObject;\n}\n\nexport function generateModelImportMap(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel\n) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelImportMap: Record<string, any> = {};\n if (modelClass !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelLcName = (modelClass as any)?.lc_name();\n let importMapKey;\n if (modelLcName === \"ChatOpenAI\") {\n importMapKey = \"chat_models__openai\";\n } else if (modelLcName === \"ChatAnthropic\") {\n importMapKey = \"chat_models__anthropic\";\n } else if (modelLcName === \"ChatAzureOpenAI\") {\n importMapKey = \"chat_models__openai\";\n } else if (modelLcName === \"ChatVertexAI\") {\n importMapKey = \"chat_models__vertexai\";\n } else if (modelLcName === \"ChatGoogleGenerativeAI\") {\n importMapKey = \"chat_models__google_genai\";\n } else if (modelLcName === \"ChatBedrockConverse\") {\n importMapKey = \"chat_models__chat_bedrock_converse\";\n } else if (modelLcName === \"ChatMistralAI\") {\n importMapKey = \"chat_models__mistralai\";\n } else if (modelLcName === \"ChatMistral\") {\n importMapKey = \"chat_models__mistralai\";\n } else if (modelLcName === \"ChatFireworks\") {\n importMapKey = \"chat_models__fireworks\";\n } else if (modelLcName === \"ChatGroq\") {\n importMapKey = \"chat_models__groq\";\n } else {\n throw new Error(\"Received unsupported model class when pulling prompt.\");\n }\n modelImportMap[importMapKey] = {\n ...modelImportMap[importMapKey],\n [modelLcName]: modelClass,\n };\n }\n return modelImportMap;\n}\n\nexport function generateOptionalImportMap(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel\n) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const optionalImportMap: Record<string, any> = {};\n if (modelClass !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelLcName = (modelClass as any)?.lc_name();\n let optionalImportMapKey;\n if (modelLcName === \"ChatGoogleGenerativeAI\") {\n optionalImportMapKey = \"langchain_google_genai/chat_models\";\n } else if (modelLcName === \"ChatBedrockConverse\") {\n optionalImportMapKey = \"langchain_aws/chat_models\";\n } else if (modelLcName === \"ChatGroq\") {\n optionalImportMapKey = \"langchain_groq/chat_models\";\n }\n if (optionalImportMapKey !== undefined) {\n optionalImportMap[optionalImportMapKey] = {\n [modelLcName]: modelClass,\n };\n }\n }\n return optionalImportMap;\n}\n\nexport function bindOutputSchema<T extends Runnable>(loadedSequence: T) {\n if (\n \"first\" in loadedSequence &&\n loadedSequence.first !== null &&\n typeof loadedSequence.first === \"object\" &&\n \"schema\" in loadedSequence.first &&\n \"last\" in loadedSequence &&\n loadedSequence.last !== null &&\n typeof loadedSequence.last === \"object\"\n ) {\n if (\n \"bound\" in loadedSequence.last &&\n loadedSequence.last.bound !== null &&\n typeof loadedSequence.last.bound === \"object\" &&\n \"withStructuredOutput\" in loadedSequence.last.bound &&\n typeof loadedSequence.last.bound.withStructuredOutput === \"function\"\n ) {\n loadedSequence.last.bound =\n loadedSequence.last.bound.withStructuredOutput(\n loadedSequence.first.schema\n );\n } else if (\n \"withStructuredOutput\" in loadedSequence.last &&\n typeof loadedSequence.last.withStructuredOutput === \"function\"\n ) {\n loadedSequence.last = loadedSequence.last.withStructuredOutput(\n loadedSequence.first.schema\n );\n }\n }\n return loadedSequence;\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"base.js","names":["repoFullName: string","runnable: Runnable","options?: {\n apiKey?: string;\n apiUrl?: string;\n parentCommitHash?: string;\n isPublic?: boolean;\n description?: string;\n readme?: string;\n tags?: string[];\n client?: Client;\n }","ownerRepoCommit: string","options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n skipCache?: boolean;\n client?: Client;\n }","varName: string","message: any","modelClass?: new (...args: any[]) => BaseLanguageModel","modelImportMap: Record<string, any>","optionalImportMap: Record<string, any>","loadedSequence: T"],"sources":["../../src/hub/base.ts"],"sourcesContent":["import type { BaseLanguageModel } from \"@langchain/core/language_models/base\";\nimport type { Runnable } from \"@langchain/core/runnables\";\n\nimport { Client } from \"langsmith\";\nimport type { PromptCommit } from \"langsmith/schemas\";\n\n/**\n * Push a prompt to the hub.\n * If the specified repo doesn't already exist, it will be created.\n * @param repoFullName The full name of the repo.\n * @param runnable The prompt to push.\n * @param options\n * @returns The URL of the newly pushed prompt in the hub.\n */\nexport async function basePush(\n repoFullName: string,\n runnable: Runnable,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n parentCommitHash?: string;\n isPublic?: boolean;\n description?: string;\n readme?: string;\n tags?: string[];\n client?: Client;\n }\n): Promise<string> {\n const client = options?.client ?? new Client(options);\n const payloadOptions = {\n object: runnable,\n parentCommitHash: options?.parentCommitHash,\n isPublic: options?.isPublic,\n description: options?.description,\n readme: options?.readme,\n tags: options?.tags,\n };\n return client.pushPrompt(repoFullName, payloadOptions);\n}\n\nexport async function basePull(\n ownerRepoCommit: string,\n options?: {\n apiKey?: string;\n apiUrl?: string;\n includeModel?: boolean;\n skipCache?: boolean;\n client?: Client;\n }\n): Promise<PromptCommit> {\n const client = options?.client ?? new Client(options);\n\n const promptObject = await client.pullPromptCommit(ownerRepoCommit, {\n includeModel: options?.includeModel,\n skipCache: options?.skipCache,\n });\n\n if (promptObject.manifest.kwargs?.metadata === undefined) {\n promptObject.manifest.kwargs = {\n ...promptObject.manifest.kwargs,\n metadata: {},\n };\n }\n\n promptObject.manifest.kwargs.metadata = {\n ...promptObject.manifest.kwargs.metadata,\n lc_hub_owner: promptObject.owner,\n lc_hub_repo: promptObject.repo,\n lc_hub_commit_hash: promptObject.commit_hash,\n };\n\n // Some nested mustache prompts have improperly parsed variables that include a dot.\n if (promptObject.manifest.kwargs.template_format === \"mustache\") {\n const stripDotNotation = (varName: string) => varName.split(\".\")[0];\n\n const { input_variables } = promptObject.manifest.kwargs;\n if (Array.isArray(input_variables)) {\n promptObject.manifest.kwargs.input_variables =\n input_variables.map(stripDotNotation);\n }\n\n const { messages } = promptObject.manifest.kwargs;\n if (Array.isArray(messages)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n promptObject.manifest.kwargs.messages = messages.map((message: any) => {\n const nestedVars = message?.kwargs?.prompt?.kwargs?.input_variables;\n if (Array.isArray(nestedVars)) {\n message.kwargs.prompt.kwargs.input_variables =\n nestedVars.map(stripDotNotation);\n }\n return message;\n });\n }\n }\n return promptObject;\n}\n\nexport function generateModelImportMap(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel\n) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelImportMap: Record<string, any> = {};\n if (modelClass !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelLcName = (modelClass as any)?.lc_name();\n let importMapKey;\n if (modelLcName === \"ChatOpenAI\") {\n importMapKey = \"chat_models__openai\";\n } else if (modelLcName === \"ChatAnthropic\") {\n importMapKey = \"chat_models__anthropic\";\n } else if (modelLcName === \"ChatAzureOpenAI\") {\n importMapKey = \"chat_models__openai\";\n } else if (modelLcName === \"ChatVertexAI\") {\n importMapKey = \"chat_models__vertexai\";\n } else if (modelLcName === \"ChatGoogleGenerativeAI\") {\n importMapKey = \"chat_models__google_genai\";\n } else if (modelLcName === \"ChatBedrockConverse\") {\n importMapKey = \"chat_models__chat_bedrock_converse\";\n } else if (modelLcName === \"ChatMistralAI\") {\n importMapKey = \"chat_models__mistralai\";\n } else if (modelLcName === \"ChatMistral\") {\n importMapKey = \"chat_models__mistralai\";\n } else if (modelLcName === \"ChatFireworks\") {\n importMapKey = \"chat_models__fireworks\";\n } else if (modelLcName === \"ChatGroq\") {\n importMapKey = \"chat_models__groq\";\n } else {\n throw new Error(\"Received unsupported model class when pulling prompt.\");\n }\n modelImportMap[importMapKey] = {\n ...modelImportMap[importMapKey],\n [modelLcName]: modelClass,\n };\n }\n return modelImportMap;\n}\n\nexport function generateOptionalImportMap(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n modelClass?: new (...args: any[]) => BaseLanguageModel\n) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const optionalImportMap: Record<string, any> = {};\n if (modelClass !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const modelLcName = (modelClass as any)?.lc_name();\n let optionalImportMapKey;\n if (modelLcName === \"ChatGoogleGenerativeAI\") {\n optionalImportMapKey = \"langchain_google_genai/chat_models\";\n } else if (modelLcName === \"ChatBedrockConverse\") {\n optionalImportMapKey = \"langchain_aws/chat_models\";\n } else if (modelLcName === \"ChatGroq\") {\n optionalImportMapKey = \"langchain_groq/chat_models\";\n }\n if (optionalImportMapKey !== undefined) {\n optionalImportMap[optionalImportMapKey] = {\n [modelLcName]: modelClass,\n };\n }\n }\n return optionalImportMap;\n}\n\nexport function bindOutputSchema<T extends Runnable>(loadedSequence: T) {\n if (\n \"first\" in loadedSequence &&\n loadedSequence.first !== null &&\n typeof loadedSequence.first === \"object\" &&\n \"schema\" in loadedSequence.first &&\n \"last\" in loadedSequence &&\n loadedSequence.last !== null &&\n typeof loadedSequence.last === \"object\"\n ) {\n if (\n \"bound\" in loadedSequence.last &&\n loadedSequence.last.bound !== null &&\n typeof loadedSequence.last.bound === \"object\" &&\n \"withStructuredOutput\" in loadedSequence.last.bound &&\n typeof loadedSequence.last.bound.withStructuredOutput === \"function\"\n ) {\n loadedSequence.last.bound =\n loadedSequence.last.bound.withStructuredOutput(\n loadedSequence.first.schema\n );\n } else if (\n \"withStructuredOutput\" in loadedSequence.last &&\n typeof loadedSequence.last.withStructuredOutput === \"function\"\n ) {\n loadedSequence.last = loadedSequence.last.withStructuredOutput(\n loadedSequence.first.schema\n );\n }\n }\n return loadedSequence;\n}\n"],"mappings":"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"}
@@ -23,6 +23,8 @@ const require_base = require('./base.cjs');
23
23
  * `includeModel` is `true`.
24
24
  * @param options.secretsFromEnv Whether to load secrets from environment variables.
25
25
  * Use with caution and only with trusted prompts.
26
+ * @param options.client LangSmith client to use when pulling the prompt
27
+ * @param options.skipCache Whether to skip the global default cache when pulling the prompt
26
28
  * @returns
27
29
  */
28
30
  async function pull(ownerRepoCommit, options) {
@@ -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 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"}
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 client?: Client;\n skipCache?: boolean;\n }","basePull","load","generateOptionalImportMap","generateModelImportMap","bindOutputSchema","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,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"}
@@ -1,6 +1,7 @@
1
1
  import { basePush } from "./base.cjs";
2
2
  import { BaseLanguageModel } from "@langchain/core/language_models/base";
3
3
  import { Runnable } from "@langchain/core/runnables";
4
+ import { Client } from "langsmith";
4
5
 
5
6
  //#region src/hub/index.d.ts
6
7
 
@@ -25,6 +26,8 @@ import { Runnable } from "@langchain/core/runnables";
25
26
  * `includeModel` is `true`.
26
27
  * @param options.secretsFromEnv Whether to load secrets from environment variables.
27
28
  * Use with caution and only with trusted prompts.
29
+ * @param options.client LangSmith client to use when pulling the prompt
30
+ * @param options.skipCache Whether to skip the global default cache when pulling the prompt
28
31
  * @returns
29
32
  */
30
33
  declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
@@ -34,6 +37,8 @@ declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
34
37
  modelClass?: new (...args: any[]) => BaseLanguageModel;
35
38
  secrets?: Record<string, string>;
36
39
  secretsFromEnv?: boolean;
40
+ client?: Client;
41
+ skipCache?: boolean;
37
42
  }): Promise<T>;
38
43
  //#endregion
39
44
  export { pull, basePush as push };
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"index.d.cts","names":["Runnable","Client","BaseLanguageModel","basePush","push","pull","T","Record","Promise"],"sources":["../../src/hub/index.d.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport type { Client } from \"langsmith\";\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 * @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 modelClass?: new (...args: any[]) => BaseLanguageModel;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n client?: Client;\n skipCache?: boolean;\n}): Promise<T>;\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;;AA8BA;;;;;;;AASW;;;;;;;;;;;;;;;;;iBATaK,eAAeL;;;;uCAIEE;YAC3BK;;WAEDN;;IAETO,QAAQF"}
@@ -1,6 +1,7 @@
1
1
  import { basePush } from "./base.js";
2
2
  import { Runnable } from "@langchain/core/runnables";
3
3
  import { BaseLanguageModel } from "@langchain/core/language_models/base";
4
+ import { Client } from "langsmith";
4
5
 
5
6
  //#region src/hub/index.d.ts
6
7
 
@@ -25,6 +26,8 @@ import { BaseLanguageModel } from "@langchain/core/language_models/base";
25
26
  * `includeModel` is `true`.
26
27
  * @param options.secretsFromEnv Whether to load secrets from environment variables.
27
28
  * Use with caution and only with trusted prompts.
29
+ * @param options.client LangSmith client to use when pulling the prompt
30
+ * @param options.skipCache Whether to skip the global default cache when pulling the prompt
28
31
  * @returns
29
32
  */
30
33
  declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
@@ -34,6 +37,8 @@ declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
34
37
  modelClass?: new (...args: any[]) => BaseLanguageModel;
35
38
  secrets?: Record<string, string>;
36
39
  secretsFromEnv?: boolean;
40
+ client?: Client;
41
+ skipCache?: boolean;
37
42
  }): Promise<T>;
38
43
  //#endregion
39
44
  export { pull, basePush as push };
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"index.d.ts","names":["Runnable","Client","BaseLanguageModel","basePush","push","pull","T","Record","Promise"],"sources":["../../src/hub/index.d.ts"],"sourcesContent":["import { Runnable } from \"@langchain/core/runnables\";\nimport type { Client } from \"langsmith\";\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 * @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 modelClass?: new (...args: any[]) => BaseLanguageModel;\n secrets?: Record<string, string>;\n secretsFromEnv?: boolean;\n client?: Client;\n skipCache?: boolean;\n}): Promise<T>;\n//# sourceMappingURL=index.d.ts.map"],"mappings":";;;;;;;;AA8BA;;;;;;;AASW;;;;;;;;;;;;;;;;;iBATaK,eAAeL;;;;uCAIEE;YAC3BK;;WAEDN;;IAETO,QAAQF"}
package/dist/hub/index.js CHANGED
@@ -23,6 +23,8 @@ import { basePull, basePush, bindOutputSchema, generateModelImportMap, generateO
23
23
  * `includeModel` is `true`.
24
24
  * @param options.secretsFromEnv Whether to load secrets from environment variables.
25
25
  * Use with caution and only with trusted prompts.
26
+ * @param options.client LangSmith client to use when pulling the prompt
27
+ * @param options.skipCache Whether to skip the global default cache when pulling the prompt
26
28
  * @returns
27
29
  */
28
30
  async function pull(ownerRepoCommit, options) {
@@ -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
@@ -61,6 +61,8 @@ function inferModelProviderFromNamespace(idArray) {
61
61
  * `includeModel` is `true`.
62
62
  * @param options.secretsFromEnv Whether to load secrets from environment variables.
63
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
64
66
  * @returns
65
67
  */
66
68
  async function pull(ownerRepoCommit, options) {
@@ -1 +1 @@
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 }","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 * 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 * @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 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":";;;;;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;;;;;;;;;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;;;;;;;;;;;;;;;;;;AAmBD,eAAsB,KACpBC,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,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
+ {"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,5 +1,6 @@
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
 
@@ -27,6 +28,8 @@ declare function inferModelProviderFromNamespace(idArray: string[]): string | un
27
28
  * `includeModel` is `true`.
28
29
  * @param options.secretsFromEnv Whether to load secrets from environment variables.
29
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
30
33
  * @returns
31
34
  */
32
35
  declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
@@ -35,6 +38,8 @@ declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
35
38
  includeModel?: boolean;
36
39
  secrets?: Record<string, string>;
37
40
  secretsFromEnv?: boolean;
41
+ client?: Client;
42
+ skipCache?: boolean;
38
43
  }): Promise<T>;
39
44
  //#endregion
40
45
  export { inferModelProviderFromNamespace, pull, basePush as push };
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.cts","names":["Runnable","basePush","push","inferModelProviderFromNamespace","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 * 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 * @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":";;;;;;;AAUA;AAkBA;;;;;AAMW,iBAxBaG,+BAAAA,CAwBb,OAAA,EAAA,MAAA,EAAA,CAAA,EAAA,MAAA,GAAA,SAAA;;;;;;;;;;;;;;;;;;iBANaC,eAAeJ;;;;YAIzBM;;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,5 +1,6 @@
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
 
@@ -27,6 +28,8 @@ declare function inferModelProviderFromNamespace(idArray: string[]): string | un
27
28
  * `includeModel` is `true`.
28
29
  * @param options.secretsFromEnv Whether to load secrets from environment variables.
29
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
30
33
  * @returns
31
34
  */
32
35
  declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
@@ -35,6 +38,8 @@ declare function pull<T extends Runnable>(ownerRepoCommit: string, options?: {
35
38
  includeModel?: boolean;
36
39
  secrets?: Record<string, string>;
37
40
  secretsFromEnv?: boolean;
41
+ client?: Client;
42
+ skipCache?: boolean;
38
43
  }): Promise<T>;
39
44
  //#endregion
40
45
  export { inferModelProviderFromNamespace, pull, basePush as push };
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","names":["Runnable","basePush","push","inferModelProviderFromNamespace","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 * 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 * @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":";;;;;;;AAUA;AAkBA;;;;;AAMW,iBAxBaG,+BAAAA,CAwBb,OAAA,EAAA,MAAA,EAAA,CAAA,EAAA,MAAA,GAAA,SAAA;;;;;;;;;;;;;;;;;;iBANaC,eAAeJ;;;;YAIzBM;;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
@@ -61,6 +61,8 @@ function inferModelProviderFromNamespace(idArray) {
61
61
  * `includeModel` is `true`.
62
62
  * @param options.secretsFromEnv Whether to load secrets from environment variables.
63
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
64
66
  * @returns
65
67
  */
66
68
  async function pull(ownerRepoCommit, options) {
@@ -1 +1 @@
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 }"],"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 * 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 * @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 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":";;;;;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;;;;;;;;;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;;;;;;;;;;;;;;;;;;AAmBD,eAAsB,KACpBC,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,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"}
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.18",
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.15",
55
+ "@langchain/anthropic": "1.3.16",
56
56
  "@langchain/cohere": "1.0.2",
57
+ "@langchain/core": "1.1.20",
57
58
  "@langchain/eslint": "0.1.1",
58
- "@langchain/core": "1.1.19",
59
- "@langchain/openai": "1.2.5",
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
  },