langchain-core 1.0.0a7__py3-none-any.whl → 1.0.0rc1__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.

Potentially problematic release.


This version of langchain-core might be problematic. Click here for more details.

Files changed (135) hide show
  1. langchain_core/__init__.py +1 -1
  2. langchain_core/_api/__init__.py +0 -1
  3. langchain_core/_api/beta_decorator.py +17 -20
  4. langchain_core/_api/deprecation.py +30 -35
  5. langchain_core/_import_utils.py +1 -1
  6. langchain_core/agents.py +7 -6
  7. langchain_core/caches.py +4 -10
  8. langchain_core/callbacks/__init__.py +1 -8
  9. langchain_core/callbacks/base.py +232 -243
  10. langchain_core/callbacks/file.py +33 -33
  11. langchain_core/callbacks/manager.py +353 -416
  12. langchain_core/callbacks/stdout.py +21 -22
  13. langchain_core/callbacks/streaming_stdout.py +32 -32
  14. langchain_core/callbacks/usage.py +54 -51
  15. langchain_core/chat_history.py +76 -55
  16. langchain_core/document_loaders/langsmith.py +21 -21
  17. langchain_core/documents/__init__.py +0 -1
  18. langchain_core/documents/base.py +37 -40
  19. langchain_core/documents/transformers.py +28 -29
  20. langchain_core/embeddings/fake.py +46 -52
  21. langchain_core/exceptions.py +5 -5
  22. langchain_core/indexing/api.py +11 -11
  23. langchain_core/indexing/base.py +24 -24
  24. langchain_core/language_models/__init__.py +0 -2
  25. langchain_core/language_models/_utils.py +51 -53
  26. langchain_core/language_models/base.py +23 -24
  27. langchain_core/language_models/chat_models.py +121 -144
  28. langchain_core/language_models/fake_chat_models.py +5 -5
  29. langchain_core/language_models/llms.py +10 -12
  30. langchain_core/load/dump.py +1 -1
  31. langchain_core/load/load.py +16 -16
  32. langchain_core/load/serializable.py +35 -34
  33. langchain_core/messages/__init__.py +1 -16
  34. langchain_core/messages/ai.py +105 -104
  35. langchain_core/messages/base.py +26 -26
  36. langchain_core/messages/block_translators/__init__.py +17 -17
  37. langchain_core/messages/block_translators/anthropic.py +2 -2
  38. langchain_core/messages/block_translators/bedrock_converse.py +2 -2
  39. langchain_core/messages/block_translators/google_genai.py +2 -2
  40. langchain_core/messages/block_translators/groq.py +117 -21
  41. langchain_core/messages/block_translators/langchain_v0.py +2 -2
  42. langchain_core/messages/block_translators/openai.py +4 -4
  43. langchain_core/messages/chat.py +1 -1
  44. langchain_core/messages/content.py +189 -193
  45. langchain_core/messages/function.py +5 -5
  46. langchain_core/messages/human.py +15 -17
  47. langchain_core/messages/modifier.py +1 -1
  48. langchain_core/messages/system.py +12 -14
  49. langchain_core/messages/tool.py +45 -49
  50. langchain_core/messages/utils.py +384 -396
  51. langchain_core/output_parsers/__init__.py +1 -14
  52. langchain_core/output_parsers/base.py +22 -23
  53. langchain_core/output_parsers/json.py +3 -3
  54. langchain_core/output_parsers/list.py +1 -1
  55. langchain_core/output_parsers/openai_functions.py +46 -44
  56. langchain_core/output_parsers/openai_tools.py +7 -7
  57. langchain_core/output_parsers/pydantic.py +10 -11
  58. langchain_core/output_parsers/string.py +1 -1
  59. langchain_core/output_parsers/transform.py +2 -2
  60. langchain_core/output_parsers/xml.py +1 -1
  61. langchain_core/outputs/__init__.py +1 -1
  62. langchain_core/outputs/chat_generation.py +14 -14
  63. langchain_core/outputs/generation.py +5 -5
  64. langchain_core/outputs/llm_result.py +5 -5
  65. langchain_core/prompt_values.py +5 -5
  66. langchain_core/prompts/__init__.py +3 -23
  67. langchain_core/prompts/base.py +32 -37
  68. langchain_core/prompts/chat.py +216 -222
  69. langchain_core/prompts/dict.py +2 -2
  70. langchain_core/prompts/few_shot.py +76 -83
  71. langchain_core/prompts/few_shot_with_templates.py +6 -8
  72. langchain_core/prompts/image.py +11 -13
  73. langchain_core/prompts/loading.py +1 -1
  74. langchain_core/prompts/message.py +2 -2
  75. langchain_core/prompts/prompt.py +14 -16
  76. langchain_core/prompts/string.py +19 -7
  77. langchain_core/prompts/structured.py +24 -25
  78. langchain_core/rate_limiters.py +36 -38
  79. langchain_core/retrievers.py +41 -182
  80. langchain_core/runnables/base.py +565 -590
  81. langchain_core/runnables/branch.py +7 -7
  82. langchain_core/runnables/config.py +37 -44
  83. langchain_core/runnables/configurable.py +8 -9
  84. langchain_core/runnables/fallbacks.py +8 -8
  85. langchain_core/runnables/graph.py +28 -27
  86. langchain_core/runnables/graph_ascii.py +19 -18
  87. langchain_core/runnables/graph_mermaid.py +20 -31
  88. langchain_core/runnables/graph_png.py +7 -7
  89. langchain_core/runnables/history.py +20 -20
  90. langchain_core/runnables/passthrough.py +8 -8
  91. langchain_core/runnables/retry.py +3 -3
  92. langchain_core/runnables/router.py +1 -1
  93. langchain_core/runnables/schema.py +33 -33
  94. langchain_core/runnables/utils.py +30 -34
  95. langchain_core/stores.py +72 -102
  96. langchain_core/sys_info.py +27 -29
  97. langchain_core/tools/__init__.py +1 -14
  98. langchain_core/tools/base.py +63 -63
  99. langchain_core/tools/convert.py +92 -92
  100. langchain_core/tools/render.py +9 -9
  101. langchain_core/tools/retriever.py +1 -1
  102. langchain_core/tools/simple.py +6 -7
  103. langchain_core/tools/structured.py +17 -18
  104. langchain_core/tracers/__init__.py +1 -9
  105. langchain_core/tracers/base.py +35 -35
  106. langchain_core/tracers/context.py +12 -17
  107. langchain_core/tracers/event_stream.py +3 -3
  108. langchain_core/tracers/langchain.py +8 -8
  109. langchain_core/tracers/log_stream.py +17 -18
  110. langchain_core/tracers/memory_stream.py +2 -2
  111. langchain_core/tracers/schemas.py +0 -129
  112. langchain_core/utils/aiter.py +31 -31
  113. langchain_core/utils/env.py +5 -5
  114. langchain_core/utils/function_calling.py +48 -120
  115. langchain_core/utils/html.py +4 -4
  116. langchain_core/utils/input.py +2 -2
  117. langchain_core/utils/interactive_env.py +1 -1
  118. langchain_core/utils/iter.py +19 -19
  119. langchain_core/utils/json.py +1 -1
  120. langchain_core/utils/json_schema.py +2 -2
  121. langchain_core/utils/mustache.py +5 -5
  122. langchain_core/utils/pydantic.py +17 -17
  123. langchain_core/utils/strings.py +4 -4
  124. langchain_core/utils/utils.py +25 -28
  125. langchain_core/vectorstores/base.py +43 -64
  126. langchain_core/vectorstores/in_memory.py +83 -85
  127. langchain_core/version.py +1 -1
  128. {langchain_core-1.0.0a7.dist-info → langchain_core-1.0.0rc1.dist-info}/METADATA +23 -11
  129. langchain_core-1.0.0rc1.dist-info/RECORD +172 -0
  130. langchain_core/memory.py +0 -120
  131. langchain_core/pydantic_v1/__init__.py +0 -30
  132. langchain_core/pydantic_v1/dataclasses.py +0 -23
  133. langchain_core/pydantic_v1/main.py +0 -23
  134. langchain_core-1.0.0a7.dist-info/RECORD +0 -176
  135. {langchain_core-1.0.0a7.dist-info → langchain_core-1.0.0rc1.dist-info}/WHEEL +0 -0
@@ -80,7 +80,7 @@ def accepts_run_manager(callable: Callable[..., Any]) -> bool: # noqa: A002
80
80
  callable: The callable to check.
81
81
 
82
82
  Returns:
83
- bool: True if the callable accepts a run_manager argument, False otherwise.
83
+ `True` if the callable accepts a run_manager argument, `False` otherwise.
84
84
  """
85
85
  try:
86
86
  return signature(callable).parameters.get("run_manager") is not None
@@ -95,7 +95,7 @@ def accepts_config(callable: Callable[..., Any]) -> bool: # noqa: A002
95
95
  callable: The callable to check.
96
96
 
97
97
  Returns:
98
- bool: True if the callable accepts a config argument, False otherwise.
98
+ `True` if the callable accepts a config argument, `False` otherwise.
99
99
  """
100
100
  try:
101
101
  return signature(callable).parameters.get("config") is not None
@@ -110,7 +110,7 @@ def accepts_context(callable: Callable[..., Any]) -> bool: # noqa: A002
110
110
  callable: The callable to check.
111
111
 
112
112
  Returns:
113
- bool: True if the callable accepts a context argument, False otherwise.
113
+ `True` if the callable accepts a context argument, `False` otherwise.
114
114
  """
115
115
  try:
116
116
  return signature(callable).parameters.get("context") is not None
@@ -120,11 +120,10 @@ def accepts_context(callable: Callable[..., Any]) -> bool: # noqa: A002
120
120
 
121
121
  @lru_cache(maxsize=1)
122
122
  def asyncio_accepts_context() -> bool:
123
- """Cache the result of checking if asyncio.create_task accepts a ``context`` arg.
123
+ """Cache the result of checking if asyncio.create_task accepts a `context` arg.
124
124
 
125
125
  Returns:
126
- bool: True if ``asyncio.create_task`` accepts a context argument, False
127
- otherwise.
126
+ True if `asyncio.create_task` accepts a context argument, `False` otherwise.
128
127
  """
129
128
  return accepts_context(asyncio.create_task)
130
129
 
@@ -137,7 +136,7 @@ def coro_with_context(
137
136
  Args:
138
137
  coro: The coroutine to await.
139
138
  context: The context to use.
140
- create_task: Whether to create a task. Defaults to False.
139
+ create_task: Whether to create a task. Defaults to `False`.
141
140
 
142
141
  Returns:
143
142
  The coroutine with the context.
@@ -363,8 +362,7 @@ def get_function_first_arg_dict_keys(func: Callable) -> list[str] | None:
363
362
  func: The function to check.
364
363
 
365
364
  Returns:
366
- Optional[list[str]]: The keys of the first argument if it is a dict,
367
- None otherwise.
365
+ The keys of the first argument if it is a dict, None otherwise.
368
366
  """
369
367
  try:
370
368
  code = inspect.getsource(func)
@@ -383,7 +381,7 @@ def get_lambda_source(func: Callable) -> str | None:
383
381
  func: a Callable that can be a lambda function.
384
382
 
385
383
  Returns:
386
- str: the source code of the lambda function.
384
+ the source code of the lambda function.
387
385
  """
388
386
  try:
389
387
  name = func.__name__ if func.__name__ != "<lambda>" else None
@@ -407,7 +405,7 @@ def get_function_nonlocals(func: Callable) -> list[Any]:
407
405
  func: The function to check.
408
406
 
409
407
  Returns:
410
- list[Any]: The nonlocal variables accessed by the function.
408
+ The nonlocal variables accessed by the function.
411
409
  """
412
410
  try:
413
411
  code = inspect.getsource(func)
@@ -450,7 +448,7 @@ def indent_lines_after_first(text: str, prefix: str) -> str:
450
448
  prefix: Used to determine the number of spaces to indent.
451
449
 
452
450
  Returns:
453
- str: The indented text.
451
+ The indented text.
454
452
  """
455
453
  n_spaces = len(prefix)
456
454
  spaces = " " * n_spaces
@@ -525,7 +523,7 @@ def add(addables: Iterable[Addable]) -> Addable | None:
525
523
  addables: The addable objects to add.
526
524
 
527
525
  Returns:
528
- Optional[Addable]: The result of adding the addable objects.
526
+ The result of adding the addable objects.
529
527
  """
530
528
  final: Addable | None = None
531
529
  for chunk in addables:
@@ -540,7 +538,7 @@ async def aadd(addables: AsyncIterable[Addable]) -> Addable | None:
540
538
  addables: The addable objects to add.
541
539
 
542
540
  Returns:
543
- Optional[Addable]: The result of adding the addable objects.
541
+ The result of adding the addable objects.
544
542
  """
545
543
  final: Addable | None = None
546
544
  async for chunk in addables:
@@ -554,13 +552,13 @@ class ConfigurableField(NamedTuple):
554
552
  id: str
555
553
  """The unique identifier of the field."""
556
554
  name: str | None = None
557
- """The name of the field. Defaults to None."""
555
+ """The name of the field. """
558
556
  description: str | None = None
559
- """The description of the field. Defaults to None."""
557
+ """The description of the field. """
560
558
  annotation: Any | None = None
561
- """The annotation of the field. Defaults to None."""
559
+ """The annotation of the field. """
562
560
  is_shared: bool = False
563
- """Whether the field is shared. Defaults to False."""
561
+ """Whether the field is shared. Defaults to `False`."""
564
562
 
565
563
  @override
566
564
  def __hash__(self) -> int:
@@ -577,11 +575,11 @@ class ConfigurableFieldSingleOption(NamedTuple):
577
575
  default: str
578
576
  """The default value for the field."""
579
577
  name: str | None = None
580
- """The name of the field. Defaults to None."""
578
+ """The name of the field. """
581
579
  description: str | None = None
582
- """The description of the field. Defaults to None."""
580
+ """The description of the field. """
583
581
  is_shared: bool = False
584
- """Whether the field is shared. Defaults to False."""
582
+ """Whether the field is shared. Defaults to `False`."""
585
583
 
586
584
  @override
587
585
  def __hash__(self) -> int:
@@ -598,11 +596,11 @@ class ConfigurableFieldMultiOption(NamedTuple):
598
596
  default: Sequence[str]
599
597
  """The default values for the field."""
600
598
  name: str | None = None
601
- """The name of the field. Defaults to None."""
599
+ """The name of the field. """
602
600
  description: str | None = None
603
- """The description of the field. Defaults to None."""
601
+ """The description of the field. """
604
602
  is_shared: bool = False
605
- """Whether the field is shared. Defaults to False."""
603
+ """Whether the field is shared. Defaults to `False`."""
606
604
 
607
605
  @override
608
606
  def __hash__(self) -> int:
@@ -622,15 +620,15 @@ class ConfigurableFieldSpec(NamedTuple):
622
620
  annotation: Any
623
621
  """The annotation of the field."""
624
622
  name: str | None = None
625
- """The name of the field. Defaults to None."""
623
+ """The name of the field. """
626
624
  description: str | None = None
627
- """The description of the field. Defaults to None."""
625
+ """The description of the field. """
628
626
  default: Any = None
629
- """The default value for the field. Defaults to None."""
627
+ """The default value for the field. """
630
628
  is_shared: bool = False
631
- """Whether the field is shared. Defaults to False."""
629
+ """Whether the field is shared. Defaults to `False`."""
632
630
  dependencies: list[str] | None = None
633
- """The dependencies of the field. Defaults to None."""
631
+ """The dependencies of the field. """
634
632
 
635
633
 
636
634
  def get_unique_config_specs(
@@ -642,7 +640,7 @@ def get_unique_config_specs(
642
640
  specs: The config specs.
643
641
 
644
642
  Returns:
645
- list[ConfigurableFieldSpec]: The unique config specs.
643
+ The unique config specs.
646
644
 
647
645
  Raises:
648
646
  ValueError: If the runnable sequence contains conflicting config specs.
@@ -729,8 +727,7 @@ def is_async_generator(
729
727
  func: The function to check.
730
728
 
731
729
  Returns:
732
- TypeGuard[Callable[..., AsyncIterator]: True if the function is
733
- an async generator, False otherwise.
730
+ `True` if the function is an async generator, `False` otherwise.
734
731
  """
735
732
  return inspect.isasyncgenfunction(func) or (
736
733
  hasattr(func, "__call__") # noqa: B004
@@ -747,8 +744,7 @@ def is_async_callable(
747
744
  func: The function to check.
748
745
 
749
746
  Returns:
750
- TypeGuard[Callable[..., Awaitable]: True if the function is async,
751
- False otherwise.
747
+ `True` if the function is async, `False` otherwise.
752
748
  """
753
749
  return asyncio.iscoroutinefunction(func) or (
754
750
  hasattr(func, "__call__") # noqa: B004
langchain_core/stores.py CHANGED
@@ -47,36 +47,34 @@ class BaseStore(ABC, Generic[K, V]):
47
47
  which will usually be more efficient by saving on round trips to the store.
48
48
 
49
49
  Examples:
50
-
51
- .. code-block:: python
52
-
53
- from langchain.storage import BaseStore
54
-
55
-
56
- class MyInMemoryStore(BaseStore[str, int]):
57
- def __init__(self) -> None:
58
- self.store: dict[str, int] = {}
59
-
60
- def mget(self, keys: Sequence[str]) -> list[int | None]:
61
- return [self.store.get(key) for key in keys]
62
-
63
- def mset(self, key_value_pairs: Sequence[tuple[str, int]]) -> None:
64
- for key, value in key_value_pairs:
65
- self.store[key] = value
66
-
67
- def mdelete(self, keys: Sequence[str]) -> None:
68
- for key in keys:
69
- if key in self.store:
70
- del self.store[key]
71
-
72
- def yield_keys(self, prefix: str | None = None) -> Iterator[str]:
73
- if prefix is None:
74
- yield from self.store.keys()
75
- else:
76
- for key in self.store.keys():
77
- if key.startswith(prefix):
78
- yield key
79
-
50
+ ```python
51
+ from langchain.storage import BaseStore
52
+
53
+
54
+ class MyInMemoryStore(BaseStore[str, int]):
55
+ def __init__(self) -> None:
56
+ self.store: dict[str, int] = {}
57
+
58
+ def mget(self, keys: Sequence[str]) -> list[int | None]:
59
+ return [self.store.get(key) for key in keys]
60
+
61
+ def mset(self, key_value_pairs: Sequence[tuple[str, int]]) -> None:
62
+ for key, value in key_value_pairs:
63
+ self.store[key] = value
64
+
65
+ def mdelete(self, keys: Sequence[str]) -> None:
66
+ for key in keys:
67
+ if key in self.store:
68
+ del self.store[key]
69
+
70
+ def yield_keys(self, prefix: str | None = None) -> Iterator[str]:
71
+ if prefix is None:
72
+ yield from self.store.keys()
73
+ else:
74
+ for key in self.store.keys():
75
+ if key.startswith(prefix):
76
+ yield key
77
+ ```
80
78
  """
81
79
 
82
80
  @abstractmethod
@@ -84,7 +82,7 @@ class BaseStore(ABC, Generic[K, V]):
84
82
  """Get the values associated with the given keys.
85
83
 
86
84
  Args:
87
- keys (Sequence[K]): A sequence of keys.
85
+ keys: A sequence of keys.
88
86
 
89
87
  Returns:
90
88
  A sequence of optional values associated with the keys.
@@ -95,7 +93,7 @@ class BaseStore(ABC, Generic[K, V]):
95
93
  """Async get the values associated with the given keys.
96
94
 
97
95
  Args:
98
- keys (Sequence[K]): A sequence of keys.
96
+ keys: A sequence of keys.
99
97
 
100
98
  Returns:
101
99
  A sequence of optional values associated with the keys.
@@ -108,14 +106,14 @@ class BaseStore(ABC, Generic[K, V]):
108
106
  """Set the values for the given keys.
109
107
 
110
108
  Args:
111
- key_value_pairs (Sequence[tuple[K, V]]): A sequence of key-value pairs.
109
+ key_value_pairs: A sequence of key-value pairs.
112
110
  """
113
111
 
114
112
  async def amset(self, key_value_pairs: Sequence[tuple[K, V]]) -> None:
115
113
  """Async set the values for the given keys.
116
114
 
117
115
  Args:
118
- key_value_pairs (Sequence[tuple[K, V]]): A sequence of key-value pairs.
116
+ key_value_pairs: A sequence of key-value pairs.
119
117
  """
120
118
  return await run_in_executor(None, self.mset, key_value_pairs)
121
119
 
@@ -124,14 +122,14 @@ class BaseStore(ABC, Generic[K, V]):
124
122
  """Delete the given keys and their associated values.
125
123
 
126
124
  Args:
127
- keys (Sequence[K]): A sequence of keys to delete.
125
+ keys: A sequence of keys to delete.
128
126
  """
129
127
 
130
128
  async def amdelete(self, keys: Sequence[K]) -> None:
131
129
  """Async delete the given keys and their associated values.
132
130
 
133
131
  Args:
134
- keys (Sequence[K]): A sequence of keys to delete.
132
+ keys: A sequence of keys to delete.
135
133
  """
136
134
  return await run_in_executor(None, self.mdelete, keys)
137
135
 
@@ -140,10 +138,10 @@ class BaseStore(ABC, Generic[K, V]):
140
138
  """Get an iterator over keys that match the given prefix.
141
139
 
142
140
  Args:
143
- prefix (str): The prefix to match.
141
+ prefix: The prefix to match.
144
142
 
145
143
  Yields:
146
- Iterator[K | str]: An iterator over keys that match the given prefix.
144
+ An iterator over keys that match the given prefix.
147
145
  This method is allowed to return an iterator over either K or str
148
146
  depending on what makes more sense for the given store.
149
147
  """
@@ -154,10 +152,10 @@ class BaseStore(ABC, Generic[K, V]):
154
152
  """Async get an iterator over keys that match the given prefix.
155
153
 
156
154
  Args:
157
- prefix (str): The prefix to match.
155
+ prefix: The prefix to match.
158
156
 
159
157
  Yields:
160
- Iterator[K | str]: An iterator over keys that match the given prefix.
158
+ The keys that match the given prefix.
161
159
  This method is allowed to return an iterator over either K or str
162
160
  depending on what makes more sense for the given store.
163
161
  """
@@ -180,28 +178,12 @@ class InMemoryBaseStore(BaseStore[str, V], Generic[V]):
180
178
  """Initialize an empty store."""
181
179
  self.store: dict[str, V] = {}
182
180
 
181
+ @override
183
182
  def mget(self, keys: Sequence[str]) -> list[V | None]:
184
- """Get the values associated with the given keys.
185
-
186
- Args:
187
- keys (Sequence[str]): A sequence of keys.
188
-
189
- Returns:
190
- A sequence of optional values associated with the keys.
191
- If a key is not found, the corresponding value will be None.
192
- """
193
183
  return [self.store.get(key) for key in keys]
194
184
 
185
+ @override
195
186
  async def amget(self, keys: Sequence[str]) -> list[V | None]:
196
- """Async get the values associated with the given keys.
197
-
198
- Args:
199
- keys (Sequence[str]): A sequence of keys.
200
-
201
- Returns:
202
- A sequence of optional values associated with the keys.
203
- If a key is not found, the corresponding value will be None.
204
- """
205
187
  return self.mget(keys)
206
188
 
207
189
  @override
@@ -213,32 +195,24 @@ class InMemoryBaseStore(BaseStore[str, V], Generic[V]):
213
195
  async def amset(self, key_value_pairs: Sequence[tuple[str, V]]) -> None:
214
196
  return self.mset(key_value_pairs)
215
197
 
198
+ @override
216
199
  def mdelete(self, keys: Sequence[str]) -> None:
217
- """Delete the given keys and their associated values.
218
-
219
- Args:
220
- keys (Sequence[str]): A sequence of keys to delete.
221
- """
222
200
  for key in keys:
223
201
  if key in self.store:
224
202
  del self.store[key]
225
203
 
204
+ @override
226
205
  async def amdelete(self, keys: Sequence[str]) -> None:
227
- """Async delete the given keys and their associated values.
228
-
229
- Args:
230
- keys (Sequence[str]): A sequence of keys to delete.
231
- """
232
206
  self.mdelete(keys)
233
207
 
234
208
  def yield_keys(self, prefix: str | None = None) -> Iterator[str]:
235
209
  """Get an iterator over keys that match the given prefix.
236
210
 
237
211
  Args:
238
- prefix (str, optional): The prefix to match. Defaults to None.
212
+ prefix: The prefix to match.
239
213
 
240
214
  Yields:
241
- Iterator[str]: An iterator over keys that match the given prefix.
215
+ The keys that match the given prefix.
242
216
  """
243
217
  if prefix is None:
244
218
  yield from self.store.keys()
@@ -251,10 +225,10 @@ class InMemoryBaseStore(BaseStore[str, V], Generic[V]):
251
225
  """Async get an async iterator over keys that match the given prefix.
252
226
 
253
227
  Args:
254
- prefix (str, optional): The prefix to match. Defaults to None.
228
+ prefix: The prefix to match.
255
229
 
256
230
  Yields:
257
- AsyncIterator[str]: An async iterator over keys that match the given prefix.
231
+ The keys that match the given prefix.
258
232
  """
259
233
  if prefix is None:
260
234
  for key in self.store:
@@ -273,21 +247,19 @@ class InMemoryStore(InMemoryBaseStore[Any]):
273
247
  the key-value pairs.
274
248
 
275
249
  Examples:
276
-
277
- .. code-block:: python
278
-
279
- from langchain.storage import InMemoryStore
280
-
281
- store = InMemoryStore()
282
- store.mset([("key1", "value1"), ("key2", "value2")])
283
- store.mget(["key1", "key2"])
284
- # ['value1', 'value2']
285
- store.mdelete(["key1"])
286
- list(store.yield_keys())
287
- # ['key2']
288
- list(store.yield_keys(prefix="k"))
289
- # ['key2']
290
-
250
+ ```python
251
+ from langchain.storage import InMemoryStore
252
+
253
+ store = InMemoryStore()
254
+ store.mset([("key1", "value1"), ("key2", "value2")])
255
+ store.mget(["key1", "key2"])
256
+ # ['value1', 'value2']
257
+ store.mdelete(["key1"])
258
+ list(store.yield_keys())
259
+ # ['key2']
260
+ list(store.yield_keys(prefix="k"))
261
+ # ['key2']
262
+ ```
291
263
  """
292
264
 
293
265
 
@@ -299,21 +271,19 @@ class InMemoryByteStore(InMemoryBaseStore[bytes]):
299
271
  the key-value pairs.
300
272
 
301
273
  Examples:
302
-
303
- .. code-block:: python
304
-
305
- from langchain.storage import InMemoryByteStore
306
-
307
- store = InMemoryByteStore()
308
- store.mset([("key1", b"value1"), ("key2", b"value2")])
309
- store.mget(["key1", "key2"])
310
- # [b'value1', b'value2']
311
- store.mdelete(["key1"])
312
- list(store.yield_keys())
313
- # ['key2']
314
- list(store.yield_keys(prefix="k"))
315
- # ['key2']
316
-
274
+ ```python
275
+ from langchain.storage import InMemoryByteStore
276
+
277
+ store = InMemoryByteStore()
278
+ store.mset([("key1", b"value1"), ("key2", b"value2")])
279
+ store.mget(["key1", "key2"])
280
+ # [b'value1', b'value2']
281
+ store.mdelete(["key1"])
282
+ list(store.yield_keys())
283
+ # ['key2']
284
+ list(store.yield_keys(prefix="k"))
285
+ # ['key2']
286
+ ```
317
287
  """
318
288
 
319
289
 
@@ -1,11 +1,8 @@
1
- """**sys_info** implementation.
2
-
3
- sys_info prints information about the system and langchain packages for
4
- debugging purposes.
5
- """
1
+ """Print information about the system and langchain packages for debugging purposes."""
6
2
 
7
3
  import pkgutil
8
4
  import platform
5
+ import re
9
6
  import sys
10
7
  from collections.abc import Sequence
11
8
  from importlib import metadata, util
@@ -26,9 +23,12 @@ def _get_sub_deps(packages: Sequence[str]) -> list[str]:
26
23
  continue
27
24
 
28
25
  for req in required:
29
- cleaned_req = req.split(" ")[0]
30
- if cleaned_req.replace("-", "_") not in underscored_packages:
31
- sub_deps.add(cleaned_req)
26
+ # Extract package name (e.g., "httpx<1,>=0.23.0" -> "httpx")
27
+ match = re.match(r"^([a-zA-Z0-9_.-]+)", req)
28
+ if match:
29
+ pkg_name = match.group(1)
30
+ if pkg_name.replace("-", "_") not in underscored_packages:
31
+ sub_deps.add(pkg_name)
32
32
 
33
33
  return sorted(sub_deps, key=lambda x: x.lower())
34
34
 
@@ -75,17 +75,17 @@ def print_sys_info(*, additional_pkgs: Sequence[str] = ()) -> None:
75
75
  "OS Version": platform.version(),
76
76
  "Python Version": sys.version,
77
77
  }
78
- print() # noqa: T201
79
- print("System Information") # noqa: T201
80
- print("------------------") # noqa: T201
81
- print("> OS: ", system_info["OS"]) # noqa: T201
82
- print("> OS Version: ", system_info["OS Version"]) # noqa: T201
83
- print("> Python Version: ", system_info["Python Version"]) # noqa: T201
78
+ print()
79
+ print("System Information")
80
+ print("------------------")
81
+ print("> OS: ", system_info["OS"])
82
+ print("> OS Version: ", system_info["OS Version"])
83
+ print("> Python Version: ", system_info["Python Version"])
84
84
 
85
85
  # Print out only langchain packages
86
- print() # noqa: T201
87
- print("Package Information") # noqa: T201
88
- print("-------------------") # noqa: T201
86
+ print()
87
+ print("Package Information")
88
+ print("-------------------")
89
89
 
90
90
  not_installed = []
91
91
 
@@ -106,30 +106,28 @@ def print_sys_info(*, additional_pkgs: Sequence[str] = ()) -> None:
106
106
 
107
107
  # Print package with version
108
108
  if package_version is not None:
109
- print(f"> {pkg}: {package_version}") # noqa: T201
110
- else:
111
- print(f"> {pkg}: Installed. No version info available.") # noqa: T201
109
+ print(f"> {pkg}: {package_version}")
112
110
 
113
111
  if not_installed:
114
- print() # noqa: T201
115
- print("Optional packages not installed") # noqa: T201
116
- print("-------------------------------") # noqa: T201
112
+ print()
113
+ print("Optional packages not installed")
114
+ print("-------------------------------")
117
115
  for pkg in not_installed:
118
- print(f"> {pkg}") # noqa: T201
116
+ print(f"> {pkg}")
119
117
 
120
118
  sub_dependencies = _get_sub_deps(all_packages)
121
119
 
122
120
  if sub_dependencies:
123
- print() # noqa: T201
124
- print("Other Dependencies") # noqa: T201
125
- print("------------------") # noqa: T201
121
+ print()
122
+ print("Other Dependencies")
123
+ print("------------------")
126
124
 
127
125
  for dep in sub_dependencies:
128
126
  try:
129
127
  dep_version = metadata.version(dep)
130
- print(f"> {dep}: {dep_version}") # noqa: T201
128
+ print(f"> {dep}: {dep_version}")
131
129
  except Exception:
132
- print(f"> {dep}: Installed. No version info available.") # noqa: T201
130
+ print(f"> {dep}: Installed. No version info available.")
133
131
 
134
132
 
135
133
  if __name__ == "__main__":
@@ -2,20 +2,7 @@
2
2
 
3
3
  Each tool has a **description**. Agent uses the description to choose the right
4
4
  tool for the job.
5
-
6
- **Class hierarchy:**
7
-
8
- .. code-block::
9
-
10
- RunnableSerializable --> BaseTool --> <name>Tool # Examples: AIPluginTool, BaseGraphQLTool
11
- <name> # Examples: BraveSearch, HumanInputRun
12
-
13
- **Main helpers:**
14
-
15
- .. code-block::
16
-
17
- CallbackManagerForToolRun, AsyncCallbackManagerForToolRun
18
- """ # noqa: E501
5
+ """
19
6
 
20
7
  from __future__ import annotations
21
8