langchain-core 1.0.0a8__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 +42 -57
  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.0a8.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.0a8.dist-info/RECORD +0 -176
  135. {langchain_core-1.0.0a8.dist-info → langchain_core-1.0.0rc1.dist-info}/WHEEL +0 -0
@@ -99,7 +99,7 @@ class BasePromptTemplate(
99
99
  """Get the namespace of the langchain object.
100
100
 
101
101
  Returns:
102
- ``["langchain", "schema", "prompt_template"]``
102
+ `["langchain", "schema", "prompt_template"]`
103
103
  """
104
104
  return ["langchain", "schema", "prompt_template"]
105
105
 
@@ -127,10 +127,10 @@ class BasePromptTemplate(
127
127
  """Get the input schema for the prompt.
128
128
 
129
129
  Args:
130
- config: RunnableConfig, configuration for the prompt.
130
+ config: configuration for the prompt.
131
131
 
132
132
  Returns:
133
- Type[BaseModel]: The input schema for the prompt.
133
+ The input schema for the prompt.
134
134
  """
135
135
  # This is correct, but pydantic typings/mypy don't think so.
136
136
  required_input_variables = {
@@ -199,7 +199,7 @@ class BasePromptTemplate(
199
199
  config: RunnableConfig, configuration for the prompt.
200
200
 
201
201
  Returns:
202
- PromptValue: The output of the prompt.
202
+ The output of the prompt.
203
203
  """
204
204
  config = ensure_config(config)
205
205
  if self.metadata:
@@ -225,7 +225,7 @@ class BasePromptTemplate(
225
225
  config: RunnableConfig, configuration for the prompt.
226
226
 
227
227
  Returns:
228
- PromptValue: The output of the prompt.
228
+ The output of the prompt.
229
229
  """
230
230
  config = ensure_config(config)
231
231
  if self.metadata:
@@ -245,20 +245,20 @@ class BasePromptTemplate(
245
245
  """Create Prompt Value.
246
246
 
247
247
  Args:
248
- kwargs: Any arguments to be passed to the prompt template.
248
+ **kwargs: Any arguments to be passed to the prompt template.
249
249
 
250
250
  Returns:
251
- PromptValue: The output of the prompt.
251
+ The output of the prompt.
252
252
  """
253
253
 
254
254
  async def aformat_prompt(self, **kwargs: Any) -> PromptValue:
255
255
  """Async create Prompt Value.
256
256
 
257
257
  Args:
258
- kwargs: Any arguments to be passed to the prompt template.
258
+ **kwargs: Any arguments to be passed to the prompt template.
259
259
 
260
260
  Returns:
261
- PromptValue: The output of the prompt.
261
+ The output of the prompt.
262
262
  """
263
263
  return self.format_prompt(**kwargs)
264
264
 
@@ -266,10 +266,10 @@ class BasePromptTemplate(
266
266
  """Return a partial of the prompt template.
267
267
 
268
268
  Args:
269
- kwargs: Union[str, Callable[[], str]], partial variables to set.
269
+ **kwargs: partial variables to set.
270
270
 
271
271
  Returns:
272
- BasePromptTemplate: A partial of the prompt template.
272
+ A partial of the prompt template.
273
273
  """
274
274
  prompt_dict = self.__dict__.copy()
275
275
  prompt_dict["input_variables"] = list(
@@ -290,34 +290,30 @@ class BasePromptTemplate(
290
290
  """Format the prompt with the inputs.
291
291
 
292
292
  Args:
293
- kwargs: Any arguments to be passed to the prompt template.
293
+ **kwargs: Any arguments to be passed to the prompt template.
294
294
 
295
295
  Returns:
296
296
  A formatted string.
297
297
 
298
298
  Example:
299
-
300
- .. code-block:: python
301
-
302
- prompt.format(variable1="foo")
303
-
299
+ ```python
300
+ prompt.format(variable1="foo")
301
+ ```
304
302
  """
305
303
 
306
304
  async def aformat(self, **kwargs: Any) -> FormatOutputType:
307
305
  """Async format the prompt with the inputs.
308
306
 
309
307
  Args:
310
- kwargs: Any arguments to be passed to the prompt template.
308
+ **kwargs: Any arguments to be passed to the prompt template.
311
309
 
312
310
  Returns:
313
311
  A formatted string.
314
312
 
315
313
  Example:
316
-
317
- .. code-block:: python
318
-
319
- await prompt.aformat(variable1="foo")
320
-
314
+ ```python
315
+ await prompt.aformat(variable1="foo")
316
+ ```
321
317
  """
322
318
  return self.format(**kwargs)
323
319
 
@@ -330,10 +326,10 @@ class BasePromptTemplate(
330
326
  """Return dictionary representation of prompt.
331
327
 
332
328
  Args:
333
- kwargs: Any additional arguments to pass to the dictionary.
329
+ **kwargs: Any additional arguments to pass to the dictionary.
334
330
 
335
331
  Returns:
336
- Dict: Dictionary representation of the prompt.
332
+ Dictionary representation of the prompt.
337
333
  """
338
334
  prompt_dict = super().model_dump(**kwargs)
339
335
  with contextlib.suppress(NotImplementedError):
@@ -352,10 +348,9 @@ class BasePromptTemplate(
352
348
  NotImplementedError: If the prompt type is not implemented.
353
349
 
354
350
  Example:
355
- .. code-block:: python
356
-
357
- prompt.save(file_path="path/prompt.yaml")
358
-
351
+ ```python
352
+ prompt.save(file_path="path/prompt.yaml")
353
+ ```
359
354
  """
360
355
  if self.partial_variables:
361
356
  msg = "Cannot save prompt with partial variables."
@@ -426,16 +421,16 @@ def format_document(doc: Document, prompt: BasePromptTemplate[str]) -> str:
426
421
  string of the document formatted.
427
422
 
428
423
  Example:
429
- .. code-block:: python
430
-
431
- from langchain_core.documents import Document
432
- from langchain_core.prompts import PromptTemplate
424
+ ```python
425
+ from langchain_core.documents import Document
426
+ from langchain_core.prompts import PromptTemplate
433
427
 
434
- doc = Document(page_content="This is a joke", metadata={"page": "1"})
435
- prompt = PromptTemplate.from_template("Page {page}: {page_content}")
436
- format_document(doc, prompt)
437
- >>> "Page 1: This is a joke"
428
+ doc = Document(page_content="This is a joke", metadata={"page": "1"})
429
+ prompt = PromptTemplate.from_template("Page {page}: {page_content}")
430
+ format_document(doc, prompt)
431
+ >>> "Page 1: This is a joke"
438
432
 
433
+ ```
439
434
  """
440
435
  return prompt.format(**_get_document_info(doc, prompt))
441
436