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.
- langchain_core/__init__.py +1 -1
- langchain_core/_api/__init__.py +0 -1
- langchain_core/_api/beta_decorator.py +17 -20
- langchain_core/_api/deprecation.py +30 -35
- langchain_core/_import_utils.py +1 -1
- langchain_core/agents.py +7 -6
- langchain_core/caches.py +4 -10
- langchain_core/callbacks/__init__.py +1 -8
- langchain_core/callbacks/base.py +232 -243
- langchain_core/callbacks/file.py +33 -33
- langchain_core/callbacks/manager.py +353 -416
- langchain_core/callbacks/stdout.py +21 -22
- langchain_core/callbacks/streaming_stdout.py +32 -32
- langchain_core/callbacks/usage.py +54 -51
- langchain_core/chat_history.py +76 -55
- langchain_core/document_loaders/langsmith.py +21 -21
- langchain_core/documents/__init__.py +0 -1
- langchain_core/documents/base.py +37 -40
- langchain_core/documents/transformers.py +28 -29
- langchain_core/embeddings/fake.py +46 -52
- langchain_core/exceptions.py +5 -5
- langchain_core/indexing/api.py +11 -11
- langchain_core/indexing/base.py +24 -24
- langchain_core/language_models/__init__.py +0 -2
- langchain_core/language_models/_utils.py +51 -53
- langchain_core/language_models/base.py +23 -24
- langchain_core/language_models/chat_models.py +121 -144
- langchain_core/language_models/fake_chat_models.py +5 -5
- langchain_core/language_models/llms.py +10 -12
- langchain_core/load/dump.py +1 -1
- langchain_core/load/load.py +16 -16
- langchain_core/load/serializable.py +35 -34
- langchain_core/messages/__init__.py +1 -16
- langchain_core/messages/ai.py +105 -104
- langchain_core/messages/base.py +26 -26
- langchain_core/messages/block_translators/__init__.py +17 -17
- langchain_core/messages/block_translators/anthropic.py +2 -2
- langchain_core/messages/block_translators/bedrock_converse.py +2 -2
- langchain_core/messages/block_translators/google_genai.py +2 -2
- langchain_core/messages/block_translators/groq.py +117 -21
- langchain_core/messages/block_translators/langchain_v0.py +2 -2
- langchain_core/messages/block_translators/openai.py +4 -4
- langchain_core/messages/chat.py +1 -1
- langchain_core/messages/content.py +189 -193
- langchain_core/messages/function.py +5 -5
- langchain_core/messages/human.py +15 -17
- langchain_core/messages/modifier.py +1 -1
- langchain_core/messages/system.py +12 -14
- langchain_core/messages/tool.py +45 -49
- langchain_core/messages/utils.py +384 -396
- langchain_core/output_parsers/__init__.py +1 -14
- langchain_core/output_parsers/base.py +22 -23
- langchain_core/output_parsers/json.py +3 -3
- langchain_core/output_parsers/list.py +1 -1
- langchain_core/output_parsers/openai_functions.py +46 -44
- langchain_core/output_parsers/openai_tools.py +7 -7
- langchain_core/output_parsers/pydantic.py +10 -11
- langchain_core/output_parsers/string.py +1 -1
- langchain_core/output_parsers/transform.py +2 -2
- langchain_core/output_parsers/xml.py +1 -1
- langchain_core/outputs/__init__.py +1 -1
- langchain_core/outputs/chat_generation.py +14 -14
- langchain_core/outputs/generation.py +5 -5
- langchain_core/outputs/llm_result.py +5 -5
- langchain_core/prompt_values.py +5 -5
- langchain_core/prompts/__init__.py +3 -23
- langchain_core/prompts/base.py +32 -37
- langchain_core/prompts/chat.py +216 -222
- langchain_core/prompts/dict.py +2 -2
- langchain_core/prompts/few_shot.py +76 -83
- langchain_core/prompts/few_shot_with_templates.py +6 -8
- langchain_core/prompts/image.py +11 -13
- langchain_core/prompts/loading.py +1 -1
- langchain_core/prompts/message.py +2 -2
- langchain_core/prompts/prompt.py +14 -16
- langchain_core/prompts/string.py +19 -7
- langchain_core/prompts/structured.py +24 -25
- langchain_core/rate_limiters.py +36 -38
- langchain_core/retrievers.py +41 -182
- langchain_core/runnables/base.py +565 -590
- langchain_core/runnables/branch.py +7 -7
- langchain_core/runnables/config.py +37 -44
- langchain_core/runnables/configurable.py +8 -9
- langchain_core/runnables/fallbacks.py +8 -8
- langchain_core/runnables/graph.py +28 -27
- langchain_core/runnables/graph_ascii.py +19 -18
- langchain_core/runnables/graph_mermaid.py +20 -31
- langchain_core/runnables/graph_png.py +7 -7
- langchain_core/runnables/history.py +20 -20
- langchain_core/runnables/passthrough.py +8 -8
- langchain_core/runnables/retry.py +3 -3
- langchain_core/runnables/router.py +1 -1
- langchain_core/runnables/schema.py +33 -33
- langchain_core/runnables/utils.py +30 -34
- langchain_core/stores.py +72 -102
- langchain_core/sys_info.py +27 -29
- langchain_core/tools/__init__.py +1 -14
- langchain_core/tools/base.py +63 -63
- langchain_core/tools/convert.py +92 -92
- langchain_core/tools/render.py +9 -9
- langchain_core/tools/retriever.py +1 -1
- langchain_core/tools/simple.py +6 -7
- langchain_core/tools/structured.py +17 -18
- langchain_core/tracers/__init__.py +1 -9
- langchain_core/tracers/base.py +35 -35
- langchain_core/tracers/context.py +12 -17
- langchain_core/tracers/event_stream.py +3 -3
- langchain_core/tracers/langchain.py +8 -8
- langchain_core/tracers/log_stream.py +17 -18
- langchain_core/tracers/memory_stream.py +2 -2
- langchain_core/tracers/schemas.py +0 -129
- langchain_core/utils/aiter.py +31 -31
- langchain_core/utils/env.py +5 -5
- langchain_core/utils/function_calling.py +48 -120
- langchain_core/utils/html.py +4 -4
- langchain_core/utils/input.py +2 -2
- langchain_core/utils/interactive_env.py +1 -1
- langchain_core/utils/iter.py +19 -19
- langchain_core/utils/json.py +1 -1
- langchain_core/utils/json_schema.py +2 -2
- langchain_core/utils/mustache.py +5 -5
- langchain_core/utils/pydantic.py +17 -17
- langchain_core/utils/strings.py +4 -4
- langchain_core/utils/utils.py +25 -28
- langchain_core/vectorstores/base.py +43 -64
- langchain_core/vectorstores/in_memory.py +83 -85
- langchain_core/version.py +1 -1
- {langchain_core-1.0.0a7.dist-info → langchain_core-1.0.0rc1.dist-info}/METADATA +23 -11
- langchain_core-1.0.0rc1.dist-info/RECORD +172 -0
- langchain_core/memory.py +0 -120
- langchain_core/pydantic_v1/__init__.py +0 -30
- langchain_core/pydantic_v1/dataclasses.py +0 -23
- langchain_core/pydantic_v1/main.py +0 -23
- langchain_core-1.0.0a7.dist-info/RECORD +0 -176
- {langchain_core-1.0.0a7.dist-info → langchain_core-1.0.0rc1.dist-info}/WHEEL +0 -0
langchain_core/callbacks/file.py
CHANGED
|
@@ -27,32 +27,32 @@ class FileCallbackHandler(BaseCallbackHandler):
|
|
|
27
27
|
Examples:
|
|
28
28
|
Using as a context manager (recommended):
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
with
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
```python
|
|
31
|
+
with FileCallbackHandler("output.txt") as handler:
|
|
32
|
+
# Use handler with your chain/agent
|
|
33
|
+
chain.invoke(inputs, config={"callbacks": [handler]})
|
|
34
|
+
```
|
|
35
35
|
|
|
36
36
|
Direct instantiation (deprecated):
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
```python
|
|
39
|
+
handler = FileCallbackHandler("output.txt")
|
|
40
|
+
# File remains open until handler is garbage collected
|
|
41
|
+
try:
|
|
42
|
+
chain.invoke(inputs, config={"callbacks": [handler]})
|
|
43
|
+
finally:
|
|
44
|
+
handler.close() # Explicit cleanup recommended
|
|
45
|
+
```
|
|
46
46
|
|
|
47
47
|
Args:
|
|
48
48
|
filename: The file path to write to.
|
|
49
|
-
mode: The file open mode. Defaults to
|
|
50
|
-
color: Default color for text output.
|
|
49
|
+
mode: The file open mode. Defaults to `'a'` (append).
|
|
50
|
+
color: Default color for text output.
|
|
51
51
|
|
|
52
52
|
!!! note
|
|
53
53
|
When not used as a context manager, a deprecation warning will be issued
|
|
54
|
-
on first use. The file will be opened immediately in
|
|
55
|
-
in
|
|
54
|
+
on first use. The file will be opened immediately in `__init__` and closed
|
|
55
|
+
in `__del__` or when `close()` is called explicitly.
|
|
56
56
|
|
|
57
57
|
"""
|
|
58
58
|
|
|
@@ -63,8 +63,8 @@ class FileCallbackHandler(BaseCallbackHandler):
|
|
|
63
63
|
|
|
64
64
|
Args:
|
|
65
65
|
filename: Path to the output file.
|
|
66
|
-
mode: File open mode (e.g.,
|
|
67
|
-
color: Default text color for output.
|
|
66
|
+
mode: File open mode (e.g., `'w'`, `'a'`, `'x'`). Defaults to `'a'`.
|
|
67
|
+
color: Default text color for output.
|
|
68
68
|
|
|
69
69
|
"""
|
|
70
70
|
self.filename = filename
|
|
@@ -84,7 +84,7 @@ class FileCallbackHandler(BaseCallbackHandler):
|
|
|
84
84
|
The FileCallbackHandler instance.
|
|
85
85
|
|
|
86
86
|
!!! note
|
|
87
|
-
The file is already opened in
|
|
87
|
+
The file is already opened in `__init__`, so this just marks that
|
|
88
88
|
the handler is being used as a context manager.
|
|
89
89
|
|
|
90
90
|
"""
|
|
@@ -131,9 +131,9 @@ class FileCallbackHandler(BaseCallbackHandler):
|
|
|
131
131
|
|
|
132
132
|
Args:
|
|
133
133
|
text: The text to write to the file.
|
|
134
|
-
color: Optional color for the text. Defaults to
|
|
135
|
-
end: String appended after the text. Defaults to
|
|
136
|
-
file: Optional file to write to. Defaults to
|
|
134
|
+
color: Optional color for the text. Defaults to `self.color`.
|
|
135
|
+
end: String appended after the text. Defaults to `""`.
|
|
136
|
+
file: Optional file to write to. Defaults to `self.file`.
|
|
137
137
|
|
|
138
138
|
Raises:
|
|
139
139
|
RuntimeError: If the file is closed or not available.
|
|
@@ -167,7 +167,7 @@ class FileCallbackHandler(BaseCallbackHandler):
|
|
|
167
167
|
Args:
|
|
168
168
|
serialized: The serialized chain information.
|
|
169
169
|
inputs: The inputs to the chain.
|
|
170
|
-
**kwargs: Additional keyword arguments that may contain
|
|
170
|
+
**kwargs: Additional keyword arguments that may contain `'name'`.
|
|
171
171
|
|
|
172
172
|
"""
|
|
173
173
|
name = (
|
|
@@ -196,8 +196,8 @@ class FileCallbackHandler(BaseCallbackHandler):
|
|
|
196
196
|
|
|
197
197
|
Args:
|
|
198
198
|
action: The agent action containing the log to write.
|
|
199
|
-
color: Color override for this specific output. If
|
|
200
|
-
|
|
199
|
+
color: Color override for this specific output. If `None`, uses
|
|
200
|
+
`self.color`.
|
|
201
201
|
**kwargs: Additional keyword arguments.
|
|
202
202
|
|
|
203
203
|
"""
|
|
@@ -216,8 +216,8 @@ class FileCallbackHandler(BaseCallbackHandler):
|
|
|
216
216
|
|
|
217
217
|
Args:
|
|
218
218
|
output: The tool output to write.
|
|
219
|
-
color: Color override for this specific output. If
|
|
220
|
-
|
|
219
|
+
color: Color override for this specific output. If `None`, uses
|
|
220
|
+
`self.color`.
|
|
221
221
|
observation_prefix: Optional prefix to write before the output.
|
|
222
222
|
llm_prefix: Optional prefix to write after the output.
|
|
223
223
|
**kwargs: Additional keyword arguments.
|
|
@@ -237,9 +237,9 @@ class FileCallbackHandler(BaseCallbackHandler):
|
|
|
237
237
|
|
|
238
238
|
Args:
|
|
239
239
|
text: The text to write.
|
|
240
|
-
color: Color override for this specific output. If
|
|
241
|
-
|
|
242
|
-
end: String appended after the text. Defaults to
|
|
240
|
+
color: Color override for this specific output. If `None`, uses
|
|
241
|
+
`self.color`.
|
|
242
|
+
end: String appended after the text. Defaults to `""`.
|
|
243
243
|
**kwargs: Additional keyword arguments.
|
|
244
244
|
|
|
245
245
|
"""
|
|
@@ -253,8 +253,8 @@ class FileCallbackHandler(BaseCallbackHandler):
|
|
|
253
253
|
|
|
254
254
|
Args:
|
|
255
255
|
finish: The agent finish object containing the log to write.
|
|
256
|
-
color: Color override for this specific output. If
|
|
257
|
-
|
|
256
|
+
color: Color override for this specific output. If `None`, uses
|
|
257
|
+
`self.color`.
|
|
258
258
|
**kwargs: Additional keyword arguments.
|
|
259
259
|
|
|
260
260
|
"""
|