langchain-core 1.0.0a6__py3-none-any.whl → 1.0.3__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.
- langchain_core/__init__.py +1 -1
- langchain_core/_api/__init__.py +3 -4
- langchain_core/_api/beta_decorator.py +23 -26
- langchain_core/_api/deprecation.py +51 -64
- langchain_core/_api/path.py +3 -6
- langchain_core/_import_utils.py +3 -4
- langchain_core/agents.py +20 -22
- langchain_core/caches.py +65 -66
- langchain_core/callbacks/__init__.py +1 -8
- langchain_core/callbacks/base.py +321 -336
- langchain_core/callbacks/file.py +44 -44
- langchain_core/callbacks/manager.py +436 -513
- langchain_core/callbacks/stdout.py +29 -30
- langchain_core/callbacks/streaming_stdout.py +32 -32
- langchain_core/callbacks/usage.py +60 -57
- langchain_core/chat_history.py +53 -68
- langchain_core/document_loaders/base.py +27 -25
- langchain_core/document_loaders/blob_loaders.py +1 -1
- langchain_core/document_loaders/langsmith.py +44 -48
- langchain_core/documents/__init__.py +23 -3
- langchain_core/documents/base.py +98 -90
- langchain_core/documents/compressor.py +10 -10
- langchain_core/documents/transformers.py +34 -35
- langchain_core/embeddings/fake.py +50 -54
- langchain_core/example_selectors/length_based.py +1 -1
- langchain_core/example_selectors/semantic_similarity.py +28 -32
- langchain_core/exceptions.py +21 -20
- langchain_core/globals.py +3 -151
- langchain_core/indexing/__init__.py +1 -1
- langchain_core/indexing/api.py +121 -126
- langchain_core/indexing/base.py +73 -75
- langchain_core/indexing/in_memory.py +4 -6
- langchain_core/language_models/__init__.py +14 -29
- langchain_core/language_models/_utils.py +58 -61
- langchain_core/language_models/base.py +53 -162
- langchain_core/language_models/chat_models.py +298 -387
- langchain_core/language_models/fake.py +11 -11
- langchain_core/language_models/fake_chat_models.py +42 -36
- langchain_core/language_models/llms.py +125 -235
- langchain_core/load/dump.py +9 -12
- langchain_core/load/load.py +18 -28
- langchain_core/load/mapping.py +2 -4
- langchain_core/load/serializable.py +42 -40
- langchain_core/messages/__init__.py +10 -16
- langchain_core/messages/ai.py +148 -148
- langchain_core/messages/base.py +53 -51
- langchain_core/messages/block_translators/__init__.py +19 -22
- langchain_core/messages/block_translators/anthropic.py +6 -6
- langchain_core/messages/block_translators/bedrock_converse.py +5 -5
- langchain_core/messages/block_translators/google_genai.py +10 -7
- langchain_core/messages/block_translators/google_vertexai.py +4 -32
- langchain_core/messages/block_translators/groq.py +117 -21
- langchain_core/messages/block_translators/langchain_v0.py +5 -5
- langchain_core/messages/block_translators/openai.py +11 -11
- langchain_core/messages/chat.py +2 -6
- langchain_core/messages/content.py +337 -328
- langchain_core/messages/function.py +6 -10
- langchain_core/messages/human.py +24 -31
- langchain_core/messages/modifier.py +2 -2
- langchain_core/messages/system.py +19 -29
- langchain_core/messages/tool.py +74 -90
- langchain_core/messages/utils.py +474 -504
- langchain_core/output_parsers/__init__.py +13 -10
- langchain_core/output_parsers/base.py +61 -61
- langchain_core/output_parsers/format_instructions.py +9 -4
- langchain_core/output_parsers/json.py +12 -10
- langchain_core/output_parsers/list.py +21 -23
- langchain_core/output_parsers/openai_functions.py +49 -47
- langchain_core/output_parsers/openai_tools.py +16 -21
- langchain_core/output_parsers/pydantic.py +13 -14
- langchain_core/output_parsers/string.py +5 -5
- langchain_core/output_parsers/transform.py +15 -17
- langchain_core/output_parsers/xml.py +35 -34
- langchain_core/outputs/__init__.py +1 -1
- langchain_core/outputs/chat_generation.py +18 -18
- langchain_core/outputs/chat_result.py +1 -3
- langchain_core/outputs/generation.py +10 -11
- langchain_core/outputs/llm_result.py +10 -10
- langchain_core/prompt_values.py +11 -17
- langchain_core/prompts/__init__.py +3 -27
- langchain_core/prompts/base.py +48 -56
- langchain_core/prompts/chat.py +275 -325
- langchain_core/prompts/dict.py +5 -5
- langchain_core/prompts/few_shot.py +81 -88
- langchain_core/prompts/few_shot_with_templates.py +11 -13
- langchain_core/prompts/image.py +12 -14
- langchain_core/prompts/loading.py +4 -6
- langchain_core/prompts/message.py +3 -3
- langchain_core/prompts/prompt.py +24 -39
- langchain_core/prompts/string.py +26 -10
- langchain_core/prompts/structured.py +49 -53
- langchain_core/rate_limiters.py +51 -60
- langchain_core/retrievers.py +61 -198
- langchain_core/runnables/base.py +1476 -1626
- langchain_core/runnables/branch.py +53 -57
- langchain_core/runnables/config.py +72 -89
- langchain_core/runnables/configurable.py +120 -137
- langchain_core/runnables/fallbacks.py +83 -79
- langchain_core/runnables/graph.py +91 -97
- langchain_core/runnables/graph_ascii.py +27 -28
- langchain_core/runnables/graph_mermaid.py +38 -50
- langchain_core/runnables/graph_png.py +15 -16
- langchain_core/runnables/history.py +135 -148
- langchain_core/runnables/passthrough.py +124 -150
- langchain_core/runnables/retry.py +46 -51
- langchain_core/runnables/router.py +25 -30
- langchain_core/runnables/schema.py +75 -80
- langchain_core/runnables/utils.py +60 -67
- langchain_core/stores.py +85 -121
- langchain_core/structured_query.py +8 -8
- langchain_core/sys_info.py +27 -29
- langchain_core/tools/__init__.py +1 -14
- langchain_core/tools/base.py +284 -229
- langchain_core/tools/convert.py +160 -155
- langchain_core/tools/render.py +10 -10
- langchain_core/tools/retriever.py +12 -11
- langchain_core/tools/simple.py +19 -24
- langchain_core/tools/structured.py +32 -39
- langchain_core/tracers/__init__.py +1 -9
- langchain_core/tracers/base.py +97 -99
- langchain_core/tracers/context.py +29 -52
- langchain_core/tracers/core.py +49 -53
- langchain_core/tracers/evaluation.py +11 -11
- langchain_core/tracers/event_stream.py +65 -64
- langchain_core/tracers/langchain.py +21 -21
- langchain_core/tracers/log_stream.py +45 -45
- langchain_core/tracers/memory_stream.py +3 -3
- langchain_core/tracers/root_listeners.py +16 -16
- langchain_core/tracers/run_collector.py +2 -4
- langchain_core/tracers/schemas.py +0 -129
- langchain_core/tracers/stdout.py +3 -3
- langchain_core/utils/__init__.py +1 -4
- langchain_core/utils/_merge.py +2 -2
- langchain_core/utils/aiter.py +57 -61
- langchain_core/utils/env.py +9 -9
- langchain_core/utils/function_calling.py +89 -186
- langchain_core/utils/html.py +7 -8
- langchain_core/utils/input.py +6 -6
- langchain_core/utils/interactive_env.py +1 -1
- langchain_core/utils/iter.py +36 -40
- langchain_core/utils/json.py +4 -3
- langchain_core/utils/json_schema.py +9 -9
- langchain_core/utils/mustache.py +8 -10
- langchain_core/utils/pydantic.py +33 -35
- langchain_core/utils/strings.py +6 -9
- langchain_core/utils/usage.py +1 -1
- langchain_core/utils/utils.py +66 -62
- langchain_core/vectorstores/base.py +182 -216
- langchain_core/vectorstores/in_memory.py +101 -176
- langchain_core/vectorstores/utils.py +5 -5
- langchain_core/version.py +1 -1
- langchain_core-1.0.3.dist-info/METADATA +69 -0
- langchain_core-1.0.3.dist-info/RECORD +172 -0
- {langchain_core-1.0.0a6.dist-info → langchain_core-1.0.3.dist-info}/WHEEL +1 -1
- langchain_core/memory.py +0 -120
- langchain_core/messages/block_translators/ollama.py +0 -47
- langchain_core/prompts/pipeline.py +0 -138
- 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/tracers/langchain_v1.py +0 -31
- langchain_core/utils/loading.py +0 -35
- langchain_core-1.0.0a6.dist-info/METADATA +0 -67
- langchain_core-1.0.0a6.dist-info/RECORD +0 -181
- langchain_core-1.0.0a6.dist-info/entry_points.txt +0 -4
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from abc import ABC, abstractmethod
|
|
6
6
|
from enum import Enum
|
|
7
|
-
from typing import TYPE_CHECKING, Any
|
|
7
|
+
from typing import TYPE_CHECKING, Any
|
|
8
8
|
|
|
9
9
|
from pydantic import BaseModel
|
|
10
10
|
|
|
@@ -15,12 +15,12 @@ if TYPE_CHECKING:
|
|
|
15
15
|
class Visitor(ABC):
|
|
16
16
|
"""Defines interface for IR translation using a visitor pattern."""
|
|
17
17
|
|
|
18
|
-
allowed_comparators:
|
|
18
|
+
allowed_comparators: Sequence[Comparator] | None = None
|
|
19
19
|
"""Allowed comparators for the visitor."""
|
|
20
|
-
allowed_operators:
|
|
20
|
+
allowed_operators: Sequence[Operator] | None = None
|
|
21
21
|
"""Allowed operators for the visitor."""
|
|
22
22
|
|
|
23
|
-
def _validate_func(self, func:
|
|
23
|
+
def _validate_func(self, func: Operator | Comparator) -> None:
|
|
24
24
|
if (
|
|
25
25
|
isinstance(func, Operator)
|
|
26
26
|
and self.allowed_operators is not None
|
|
@@ -174,16 +174,16 @@ class StructuredQuery(Expr):
|
|
|
174
174
|
|
|
175
175
|
query: str
|
|
176
176
|
"""Query string."""
|
|
177
|
-
filter:
|
|
177
|
+
filter: FilterDirective | None
|
|
178
178
|
"""Filtering expression."""
|
|
179
|
-
limit:
|
|
179
|
+
limit: int | None
|
|
180
180
|
"""Limit on the number of results."""
|
|
181
181
|
|
|
182
182
|
def __init__(
|
|
183
183
|
self,
|
|
184
184
|
query: str,
|
|
185
|
-
filter:
|
|
186
|
-
limit:
|
|
185
|
+
filter: FilterDirective | None, # noqa: A002
|
|
186
|
+
limit: int | None = None,
|
|
187
187
|
**kwargs: Any,
|
|
188
188
|
) -> None:
|
|
189
189
|
"""Create a StructuredQuery.
|
langchain_core/sys_info.py
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"""
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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()
|
|
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"])
|
|
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()
|
|
87
|
-
print("Package Information")
|
|
88
|
-
print("-------------------")
|
|
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}")
|
|
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()
|
|
115
|
-
print("Optional packages not installed")
|
|
116
|
-
print("-------------------------------")
|
|
112
|
+
print()
|
|
113
|
+
print("Optional packages not installed")
|
|
114
|
+
print("-------------------------------")
|
|
117
115
|
for pkg in not_installed:
|
|
118
|
-
print(f"> {pkg}")
|
|
116
|
+
print(f"> {pkg}")
|
|
119
117
|
|
|
120
118
|
sub_dependencies = _get_sub_deps(all_packages)
|
|
121
119
|
|
|
122
120
|
if sub_dependencies:
|
|
123
|
-
print()
|
|
124
|
-
print("Other Dependencies")
|
|
125
|
-
print("------------------")
|
|
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}")
|
|
128
|
+
print(f"> {dep}: {dep_version}")
|
|
131
129
|
except Exception:
|
|
132
|
-
print(f"> {dep}: Installed. No version info available.")
|
|
130
|
+
print(f"> {dep}: Installed. No version info available.")
|
|
133
131
|
|
|
134
132
|
|
|
135
133
|
if __name__ == "__main__":
|
langchain_core/tools/__init__.py
CHANGED
|
@@ -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
|
|