langchain 1.2.3__py3-none-any.whl → 1.2.4__py3-none-any.whl

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.
@@ -84,11 +84,12 @@ Each entry maps a provider key to a tuple of:
84
84
  """
85
85
 
86
86
 
87
- def _import_module(module: str) -> ModuleType:
87
+ def _import_module(module: str, class_name: str) -> ModuleType:
88
88
  """Import a module by name.
89
89
 
90
90
  Args:
91
91
  module: The fully qualified module name to import (e.g., `'langchain_openai'`).
92
+ class_name: The name of the class being imported, used for error messages.
92
93
 
93
94
  Returns:
94
95
  The imported module.
@@ -103,7 +104,10 @@ def _import_module(module: str) -> ModuleType:
103
104
  # Extract package name from module path (e.g., "langchain_azure_ai.chat_models"
104
105
  # becomes "langchain-azure-ai")
105
106
  pkg = module.split(".", maxsplit=1)[0].replace("_", "-")
106
- msg = f"Could not import {pkg} python package. Please install it with `pip install {pkg}`"
107
+ msg = (
108
+ f"Initializing {class_name} requires the {pkg} package. Please install it "
109
+ f"with `pip install {pkg}`"
110
+ )
107
111
  raise ImportError(msg) from e
108
112
 
109
113
 
@@ -135,13 +139,13 @@ def _get_chat_model_creator(
135
139
 
136
140
  pkg, class_name, creator_func = _SUPPORTED_PROVIDERS[provider]
137
141
  try:
138
- module = _import_module(pkg)
142
+ module = _import_module(pkg, class_name)
139
143
  except ImportError as e:
140
144
  if provider != "ollama":
141
145
  raise
142
146
  # For backwards compatibility
143
147
  try:
144
- module = _import_module("langchain_community.chat_models")
148
+ module = _import_module("langchain_community.chat_models", class_name)
145
149
  except ImportError:
146
150
  # If both langchain-ollama and langchain-community aren't available,
147
151
  # raise an error related to langchain-ollama
@@ -216,6 +220,9 @@ def init_chat_model(
216
220
  Args:
217
221
  model: The model name, optionally prefixed with provider (e.g., `'openai:gpt-4o'`).
218
222
 
223
+ Prefer exact model IDs from provider docs over aliases for reliable behavior
224
+ (e.g., dated versions like `'...-20250514'` instead of `'...-latest'`).
225
+
219
226
  Will attempt to infer `model_provider` from model if not specified.
220
227
 
221
228
  The following providers will be inferred based on these model prefixes:
@@ -501,7 +508,7 @@ def _attempt_infer_model_provider(model_name: str) -> str | None:
501
508
  return "cohere"
502
509
 
503
510
  # Fireworks models
504
- if model_name.startswith("accounts/fireworks"):
511
+ if model_lower.startswith("accounts/fireworks"):
505
512
  return "fireworks"
506
513
 
507
514
  # Google models
@@ -509,7 +516,7 @@ def _attempt_infer_model_provider(model_name: str) -> str | None:
509
516
  return "google_vertexai"
510
517
 
511
518
  # AWS Bedrock models
512
- if model_name.startswith("amazon.") or model_lower.startswith(("anthropic.", "meta.")):
519
+ if model_lower.startswith(("amazon.", "anthropic.", "meta.")):
513
520
  return "bedrock"
514
521
 
515
522
  # Mistral models
@@ -577,12 +584,12 @@ class _ConfigurableModel(Runnable[LanguageModelInput, Any]):
577
584
  def __init__(
578
585
  self,
579
586
  *,
580
- default_config: dict | None = None,
587
+ default_config: dict[str, Any] | None = None,
581
588
  configurable_fields: Literal["any"] | list[str] | tuple[str, ...] = "any",
582
589
  config_prefix: str = "",
583
- queued_declarative_operations: Sequence[tuple[str, tuple, dict]] = (),
590
+ queued_declarative_operations: Sequence[tuple[str, tuple[Any, ...], dict[str, Any]]] = (),
584
591
  ) -> None:
585
- self._default_config: dict = default_config or {}
592
+ self._default_config: dict[str, Any] = default_config or {}
586
593
  self._configurable_fields: Literal["any"] | list[str] = (
587
594
  "any" if configurable_fields == "any" else list(configurable_fields)
588
595
  )
@@ -591,8 +598,10 @@ class _ConfigurableModel(Runnable[LanguageModelInput, Any]):
591
598
  if config_prefix and not config_prefix.endswith("_")
592
599
  else config_prefix
593
600
  )
594
- self._queued_declarative_operations: list[tuple[str, tuple, dict]] = list(
595
- queued_declarative_operations,
601
+ self._queued_declarative_operations: list[tuple[str, tuple[Any, ...], dict[str, Any]]] = (
602
+ list(
603
+ queued_declarative_operations,
604
+ )
596
605
  )
597
606
 
598
607
  def __getattr__(self, name: str) -> Any:
@@ -625,14 +634,14 @@ class _ConfigurableModel(Runnable[LanguageModelInput, Any]):
625
634
  msg += "."
626
635
  raise AttributeError(msg)
627
636
 
628
- def _model(self, config: RunnableConfig | None = None) -> Runnable:
637
+ def _model(self, config: RunnableConfig | None = None) -> Runnable[Any, Any]:
629
638
  params = {**self._default_config, **self._model_params(config)}
630
639
  model = _init_chat_model_helper(**params)
631
640
  for name, args, kwargs in self._queued_declarative_operations:
632
641
  model = getattr(model, name)(*args, **kwargs)
633
642
  return model
634
643
 
635
- def _model_params(self, config: RunnableConfig | None) -> dict:
644
+ def _model_params(self, config: RunnableConfig | None) -> dict[str, Any]:
636
645
  config = ensure_config(config)
637
646
  model_params = {
638
647
  _remove_prefix(k, self._config_prefix): v
@@ -648,7 +657,6 @@ class _ConfigurableModel(Runnable[LanguageModelInput, Any]):
648
657
  config: RunnableConfig | None = None,
649
658
  **kwargs: Any,
650
659
  ) -> _ConfigurableModel:
651
- """Bind config to a `Runnable`, returning a new `Runnable`."""
652
660
  config = RunnableConfig(**(config or {}), **cast("RunnableConfig", kwargs))
653
661
  # Ensure config is not None after creation
654
662
  config = ensure_config(config)
@@ -959,7 +967,7 @@ class _ConfigurableModel(Runnable[LanguageModelInput, Any]):
959
967
  # Explicitly added to satisfy downstream linters.
960
968
  def bind_tools(
961
969
  self,
962
- tools: Sequence[dict[str, Any] | type[BaseModel] | Callable | BaseTool],
970
+ tools: Sequence[dict[str, Any] | type[BaseModel] | Callable[..., Any] | BaseTool],
963
971
  **kwargs: Any,
964
972
  ) -> Runnable[LanguageModelInput, AIMessage]:
965
973
  return self.__getattr__("bind_tools")(tools, **kwargs)
@@ -967,7 +975,7 @@ class _ConfigurableModel(Runnable[LanguageModelInput, Any]):
967
975
  # Explicitly added to satisfy downstream linters.
968
976
  def with_structured_output(
969
977
  self,
970
- schema: dict | type[BaseModel],
978
+ schema: dict[str, Any] | type[BaseModel],
971
979
  **kwargs: Any,
972
- ) -> Runnable[LanguageModelInput, dict | BaseModel]:
980
+ ) -> Runnable[LanguageModelInput, dict[str, Any] | BaseModel]:
973
981
  return self.__getattr__("with_structured_output")(schema, **kwargs)
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langchain
3
- Version: 1.2.3
3
+ Version: 1.2.4
4
4
  Summary: Building applications with LLMs through composability
5
5
  Project-URL: Homepage, https://docs.langchain.com/
6
6
  Project-URL: Documentation, https://reference.langchain.com/python/langchain/langchain/
7
7
  Project-URL: Source, https://github.com/langchain-ai/langchain/tree/master/libs/langchain
8
8
  Project-URL: Changelog, https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain%3D%3D1%22
9
- Project-URL: Twitter, https://x.com/LangChainAI
9
+ Project-URL: Twitter, https://x.com/LangChain
10
10
  Project-URL: Slack, https://www.langchain.com/join-community
11
11
  Project-URL: Reddit, https://www.reddit.com/r/LangChain/
12
12
  License: MIT
@@ -54,7 +54,7 @@ Description-Content-Type: text/markdown
54
54
  [![PyPI - Version](https://img.shields.io/pypi/v/langchain?label=%20)](https://pypi.org/project/langchain/#history)
55
55
  [![PyPI - License](https://img.shields.io/pypi/l/langchain)](https://opensource.org/licenses/MIT)
56
56
  [![PyPI - Downloads](https://img.shields.io/pepy/dt/langchain)](https://pypistats.org/packages/langchain)
57
- [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchainai.svg?style=social&label=Follow%20%40LangChainAI)](https://twitter.com/langchainai)
57
+ [![Twitter](https://img.shields.io/twitter/url/https/twitter.com/langchain.svg?style=social&label=Follow%20%40LangChain)](https://x.com/langchain)
58
58
 
59
59
  Looking for the JS/TS version? Check out [LangChain.js](https://github.com/langchain-ai/langchainjs).
60
60
 
@@ -0,0 +1,36 @@
1
+ langchain/__init__.py,sha256=Dzd7fEXRUbCds_r8o7PANdu3DgCuFYWyVIhdKrE5dEY,61
2
+ langchain/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ langchain/agents/__init__.py,sha256=xSMzY_PXzKmfOUVPkmL8JcXaOIq55xtP2DDeb_sDSoI,285
4
+ langchain/agents/factory.py,sha256=OmeSR5ncqh3EzxrrT-U7aPPFFdFhR_2dOzJd2OutEmY,66353
5
+ langchain/agents/structured_output.py,sha256=x55dFamXsaWRqNrl9ccah2R685oR9AbaGe6yEbzbWs4,15033
6
+ langchain/agents/middleware/__init__.py,sha256=SR4WQ71hhSIO-Q3OZeZ8y77G943pUzDWgNtTAvI0h9Y,2562
7
+ langchain/agents/middleware/_execution.py,sha256=utihTKOZ2zcfPteGnH1zELq_n49_6EENpt3Dh3XPn7Q,14198
8
+ langchain/agents/middleware/_redaction.py,sha256=IX1oKmxBwrunC_EO5o9UGYKXcZpO7UrtjXsNYGNK9v0,13295
9
+ langchain/agents/middleware/_retry.py,sha256=nZSUXbvgBXP5nS28X3iBuoSYYh7EG2oLNXcAs0XbRPM,3832
10
+ langchain/agents/middleware/context_editing.py,sha256=fXZFgedEDpQH7qMdqu259wkUAjWHRVM-oyFp1H3LPGg,9515
11
+ langchain/agents/middleware/file_search.py,sha256=LnUt7UeXIRkdRP8wWa0pXi5uOMYlWe60nQ4hFlZoIko,12777
12
+ langchain/agents/middleware/human_in_the_loop.py,sha256=q7xb-O7duM-E9GZJU_YNocwsjIlv5agN3x5zFyu_tgs,13476
13
+ langchain/agents/middleware/model_call_limit.py,sha256=vdPM3M7-diFd-SFcKyN9p4k7cqLaYpETj2T83idZimw,9010
14
+ langchain/agents/middleware/model_fallback.py,sha256=QZez99BxIW4RVUuLFeBvYWD1IzEbjX9nzg_cLId8khU,4018
15
+ langchain/agents/middleware/model_retry.py,sha256=PsjjSFFUrH8YmQj0NkvsfrYbHtGkFMltUI7QM7nSFr4,10844
16
+ langchain/agents/middleware/pii.py,sha256=WtwzxB5oW1Ql4S1DDqklykD-mutKc6BnEH-gQOUS1AA,12466
17
+ langchain/agents/middleware/shell_tool.py,sha256=Wv3eGG-gVwQ8yTrHobWttLDsxURtGEwwiMU3JcGGp2s,31702
18
+ langchain/agents/middleware/summarization.py,sha256=fvwkeiRdW8WVzu7bXrAGV79mndryMVNLjyMO9sdYEcg,24213
19
+ langchain/agents/middleware/todo.py,sha256=JLfBA3s6FhtSnTqhFwXAgZbV1n8Yt65RyRPjdwXURFc,14156
20
+ langchain/agents/middleware/tool_call_limit.py,sha256=iYElI38iiNHBCpKDLMEMsxGHyYVpAjlYP7u_nVGBr2Y,18834
21
+ langchain/agents/middleware/tool_emulator.py,sha256=0cGEFUi5a69TwZdf_qlvVg2IpeNkhzv0rRelJVSTW8I,7389
22
+ langchain/agents/middleware/tool_retry.py,sha256=_GIkvYabD_xguTt-JkrQSIzb7Qfrcz3kte0mvZlYRKA,14446
23
+ langchain/agents/middleware/tool_selection.py,sha256=4I0wC1197cF2LpLbBgfTzNFqoMze7ZJbpzUrIigRFaM,12847
24
+ langchain/agents/middleware/types.py,sha256=UvoG5iI28mAObk5y-CVLcxMWKqdU_bx3C7M1swpt1Dk,69747
25
+ langchain/chat_models/__init__.py,sha256=j1XZBNMC81eRac5eLs52ayQB8aTXBk0P78Z-nG_YGN4,286
26
+ langchain/chat_models/base.py,sha256=dRX3PkCddMNEWJ6Hh1eTKUjPZ_emZ3u8KfoTaNFm9S8,38050
27
+ langchain/embeddings/__init__.py,sha256=xvVT9JTCjEngvuayIyQJyopEZUlve8acGJnyq34nAbs,586
28
+ langchain/embeddings/base.py,sha256=gLR2Pvo3m7YsjzwaXzAWVJOkZ8JLI-mS2oA7MtYSaro,9643
29
+ langchain/messages/__init__.py,sha256=gA-2eKFWxgf97lRTWrR28e3QMiBjuPXqaNd16jkF9p0,1626
30
+ langchain/rate_limiters/__init__.py,sha256=5490xUNhet37N2nX6kbJlDgf8u1DX-C1Cs_r7etXn8A,351
31
+ langchain/tools/__init__.py,sha256=A6K6Rz8FSTADGwR713fn1PaMcqLTzeQHfbHHBmK2HLY,394
32
+ langchain/tools/tool_node.py,sha256=1DRMsm5tc31T76rtqtqJkGINw7ny1zqVCF-ViGUymFs,477
33
+ langchain-1.2.4.dist-info/METADATA,sha256=RofY52UgkjAaQg9SIfoMBhTcnnor_qrhnpR-RU7ktGE,4929
34
+ langchain-1.2.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
35
+ langchain-1.2.4.dist-info/licenses/LICENSE,sha256=TsZ-TKbmch26hJssqCJhWXyGph7iFLvyFBYAa3stBHg,1067
36
+ langchain-1.2.4.dist-info/RECORD,,
@@ -1,36 +0,0 @@
1
- langchain/__init__.py,sha256=wtF0x4NyA6HZMSrvdCbMsf8ISWPrh4fNuwFODnwlDEE,61
2
- langchain/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- langchain/agents/__init__.py,sha256=xSMzY_PXzKmfOUVPkmL8JcXaOIq55xtP2DDeb_sDSoI,285
4
- langchain/agents/factory.py,sha256=XL9-YiqSzyDWiSjZ4yVx9Ua9Xh1w2eGeAq3AM_eXDbg,65862
5
- langchain/agents/structured_output.py,sha256=FVJ7bRJDDy4JJ9vb95VmwijoTMIWaHfxrkHydk6W_t4,14467
6
- langchain/agents/middleware/__init__.py,sha256=aVlbP2z5bkxgKjWqhck94M7XAR9D0HM9R3boohVO9Js,2170
7
- langchain/agents/middleware/_execution.py,sha256=KtLnQZBVN8yW-Pn2TC8klXxL_RB42kO84NWgELgsZSk,14202
8
- langchain/agents/middleware/_redaction.py,sha256=Q_Q9N2QZYa5L3ZNOFcTCpGOb1KLO594xRB2LS0CCCnk,11642
9
- langchain/agents/middleware/_retry.py,sha256=nZSUXbvgBXP5nS28X3iBuoSYYh7EG2oLNXcAs0XbRPM,3832
10
- langchain/agents/middleware/context_editing.py,sha256=l_JN5U-orfRxbDoLKMiPiQbQWtgBKzoNLa0U2ZjQe6w,8903
11
- langchain/agents/middleware/file_search.py,sha256=ilhly8E5AcZbmXM-XdmgzooWO93yQLpTC8r11NZ6bzM,12773
12
- langchain/agents/middleware/human_in_the_loop.py,sha256=OaY_ae8Hnavj0CeJcRN1AIQ6nWZkG_7Yn82oNr9qm-g,12911
13
- langchain/agents/middleware/model_call_limit.py,sha256=GR6fktGB5keibVVT_3zGI-qNHdHYXly-Lj61fQfLhfY,9005
14
- langchain/agents/middleware/model_fallback.py,sha256=QZez99BxIW4RVUuLFeBvYWD1IzEbjX9nzg_cLId8khU,4018
15
- langchain/agents/middleware/model_retry.py,sha256=fHPL2tFOw8FbsgV1zCYez6kd-MQ9fMKsHjSQ34m2mT8,10600
16
- langchain/agents/middleware/pii.py,sha256=aNOCSousmz1AhKnwTCitBS9egAUjBog0_iRvhcyTEMg,12446
17
- langchain/agents/middleware/shell_tool.py,sha256=uhg_Y5g_FvIgZEw1S2B_X8phNAV1fiOt75_dNGtZgCQ,31146
18
- langchain/agents/middleware/summarization.py,sha256=EDsRakbhqhm__-9Akf2-rxAI5_v9sFK5zOqZem3nb7U,23620
19
- langchain/agents/middleware/todo.py,sha256=6DKvRtSgDxMiJzdsqNDD3wNLYfZESuIws2EE0aJ-gdw,13649
20
- langchain/agents/middleware/tool_call_limit.py,sha256=iYElI38iiNHBCpKDLMEMsxGHyYVpAjlYP7u_nVGBr2Y,18834
21
- langchain/agents/middleware/tool_emulator.py,sha256=KIayn1izRrAdKvkQQfqB9Os7AktihUU5Cov0H77i3js,7364
22
- langchain/agents/middleware/tool_retry.py,sha256=LH0WEUma9n2icEn3zaDBUI3gJiblmFuhoxEXpJ1b6WE,14123
23
- langchain/agents/middleware/tool_selection.py,sha256=TmLPejZQfIE10r5l-dcz41nUv4SF0FeAHRgpfPfaAVk,11821
24
- langchain/agents/middleware/types.py,sha256=clgJXyr35kHxJx1BfL5tgn7WSKacZUproExdREj8pPg,67809
25
- langchain/chat_models/__init__.py,sha256=j1XZBNMC81eRac5eLs52ayQB8aTXBk0P78Z-nG_YGN4,286
26
- langchain/chat_models/base.py,sha256=t4E-JY1pzY1HYE4fdEkuVQzy3GOejrq9edM420MAN5M,37650
27
- langchain/embeddings/__init__.py,sha256=xvVT9JTCjEngvuayIyQJyopEZUlve8acGJnyq34nAbs,586
28
- langchain/embeddings/base.py,sha256=gLR2Pvo3m7YsjzwaXzAWVJOkZ8JLI-mS2oA7MtYSaro,9643
29
- langchain/messages/__init__.py,sha256=gA-2eKFWxgf97lRTWrR28e3QMiBjuPXqaNd16jkF9p0,1626
30
- langchain/rate_limiters/__init__.py,sha256=5490xUNhet37N2nX6kbJlDgf8u1DX-C1Cs_r7etXn8A,351
31
- langchain/tools/__init__.py,sha256=A6K6Rz8FSTADGwR713fn1PaMcqLTzeQHfbHHBmK2HLY,394
32
- langchain/tools/tool_node.py,sha256=1DRMsm5tc31T76rtqtqJkGINw7ny1zqVCF-ViGUymFs,477
33
- langchain-1.2.3.dist-info/METADATA,sha256=xhPEB_NdTUxmXyVIHFcr-nBYw7BS9sOgxJIPOqolqu8,4943
34
- langchain-1.2.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
35
- langchain-1.2.3.dist-info/licenses/LICENSE,sha256=TsZ-TKbmch26hJssqCJhWXyGph7iFLvyFBYAa3stBHg,1067
36
- langchain-1.2.3.dist-info/RECORD,,