langchain 1.0.1__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.
Potentially problematic release.
This version of langchain might be problematic. Click here for more details.
- langchain/__init__.py +1 -1
- langchain/agents/factory.py +62 -31
- langchain/agents/middleware/context_editing.py +1 -1
- langchain/agents/middleware/model_call_limit.py +1 -1
- langchain/agents/middleware/model_fallback.py +1 -1
- langchain/agents/middleware/shell_tool.py +1 -1
- langchain/agents/middleware/summarization.py +1 -1
- langchain/agents/middleware/tool_call_limit.py +2 -49
- langchain/agents/middleware/tool_emulator.py +5 -7
- langchain/agents/middleware/tool_retry.py +1 -1
- langchain/agents/middleware/types.py +3 -2
- langchain/agents/structured_output.py +8 -2
- langchain/chat_models/base.py +60 -33
- langchain/embeddings/__init__.py +1 -1
- langchain/embeddings/base.py +21 -15
- langchain/messages/__init__.py +7 -1
- langchain/tools/tool_node.py +15 -1697
- {langchain-1.0.1.dist-info → langchain-1.0.3.dist-info}/METADATA +3 -3
- langchain-1.0.3.dist-info/RECORD +34 -0
- langchain-1.0.1.dist-info/RECORD +0 -34
- {langchain-1.0.1.dist-info → langchain-1.0.3.dist-info}/WHEEL +0 -0
- {langchain-1.0.1.dist-info → langchain-1.0.3.dist-info}/licenses/LICENSE +0 -0
langchain/embeddings/__init__.py
CHANGED
langchain/embeddings/base.py
CHANGED
|
@@ -126,26 +126,27 @@ def init_embeddings(
|
|
|
126
126
|
provider: str | None = None,
|
|
127
127
|
**kwargs: Any,
|
|
128
128
|
) -> Embeddings:
|
|
129
|
-
"""Initialize an
|
|
129
|
+
"""Initialize an embedding model from a model name and optional provider.
|
|
130
130
|
|
|
131
131
|
!!! note
|
|
132
|
-
|
|
133
|
-
installed.
|
|
132
|
+
Requires the integration package for the chosen model provider to be installed.
|
|
134
133
|
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
See the `model_provider` parameter below for specific package names
|
|
135
|
+
(e.g., `pip install langchain-openai`).
|
|
137
136
|
|
|
138
|
-
|
|
137
|
+
Refer to the [provider integration's API reference](https://docs.langchain.com/oss/python/integrations/providers)
|
|
138
|
+
for supported model parameters to use as `**kwargs`.
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
inferred.
|
|
140
|
+
Args:
|
|
141
|
+
model: The name of the model, e.g. `'openai:text-embedding-3-small'`.
|
|
143
142
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
You can also specify model and model provider in a single argument using
|
|
144
|
+
`'{model_provider}:{model}'` format, e.g. `'openai:text-embedding-3-small'`.
|
|
145
|
+
provider: The model provider if not specified as part of the model arg
|
|
146
|
+
(see above).
|
|
147
147
|
|
|
148
|
-
Supported
|
|
148
|
+
Supported `provider` values and the corresponding integration package
|
|
149
|
+
are:
|
|
149
150
|
|
|
150
151
|
- `openai` -> [`langchain-openai`](https://docs.langchain.com/oss/python/integrations/providers/openai)
|
|
151
152
|
- `azure_openai` -> [`langchain-openai`](https://docs.langchain.com/oss/python/integrations/providers/openai)
|
|
@@ -157,7 +158,10 @@ def init_embeddings(
|
|
|
157
158
|
- `ollama` -> [`langchain-ollama`](https://docs.langchain.com/oss/python/integrations/providers/ollama)
|
|
158
159
|
|
|
159
160
|
**kwargs: Additional model-specific parameters passed to the embedding model.
|
|
160
|
-
|
|
161
|
+
|
|
162
|
+
These vary by provider. Refer to the specific model provider's
|
|
163
|
+
[integration reference](https://reference.langchain.com/python/integrations/)
|
|
164
|
+
for all available parameters.
|
|
161
165
|
|
|
162
166
|
Returns:
|
|
163
167
|
An `Embeddings` instance that can generate embeddings for text.
|
|
@@ -166,9 +170,11 @@ def init_embeddings(
|
|
|
166
170
|
ValueError: If the model provider is not supported or cannot be determined
|
|
167
171
|
ImportError: If the required provider package is not installed
|
|
168
172
|
|
|
169
|
-
???+
|
|
173
|
+
???+ example
|
|
170
174
|
|
|
171
175
|
```python
|
|
176
|
+
# pip install langchain langchain-openai
|
|
177
|
+
|
|
172
178
|
# Using a model string
|
|
173
179
|
model = init_embeddings("openai:text-embedding-3-small")
|
|
174
180
|
model.embed_query("Hello, world!")
|
langchain/messages/__init__.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Message types.
|
|
1
|
+
"""Message and message content types.
|
|
2
2
|
|
|
3
3
|
Includes message types for different roles (e.g., human, AI, system), as well as types
|
|
4
4
|
for message content blocks (e.g., text, image, audio) and tool calls.
|
|
@@ -21,10 +21,12 @@ from langchain_core.messages import (
|
|
|
21
21
|
FileContentBlock,
|
|
22
22
|
HumanMessage,
|
|
23
23
|
ImageContentBlock,
|
|
24
|
+
InputTokenDetails,
|
|
24
25
|
InvalidToolCall,
|
|
25
26
|
MessageLikeRepresentation,
|
|
26
27
|
NonStandardAnnotation,
|
|
27
28
|
NonStandardContentBlock,
|
|
29
|
+
OutputTokenDetails,
|
|
28
30
|
PlainTextContentBlock,
|
|
29
31
|
ReasoningContentBlock,
|
|
30
32
|
RemoveMessage,
|
|
@@ -36,6 +38,7 @@ from langchain_core.messages import (
|
|
|
36
38
|
ToolCall,
|
|
37
39
|
ToolCallChunk,
|
|
38
40
|
ToolMessage,
|
|
41
|
+
UsageMetadata,
|
|
39
42
|
VideoContentBlock,
|
|
40
43
|
trim_messages,
|
|
41
44
|
)
|
|
@@ -52,10 +55,12 @@ __all__ = [
|
|
|
52
55
|
"FileContentBlock",
|
|
53
56
|
"HumanMessage",
|
|
54
57
|
"ImageContentBlock",
|
|
58
|
+
"InputTokenDetails",
|
|
55
59
|
"InvalidToolCall",
|
|
56
60
|
"MessageLikeRepresentation",
|
|
57
61
|
"NonStandardAnnotation",
|
|
58
62
|
"NonStandardContentBlock",
|
|
63
|
+
"OutputTokenDetails",
|
|
59
64
|
"PlainTextContentBlock",
|
|
60
65
|
"ReasoningContentBlock",
|
|
61
66
|
"RemoveMessage",
|
|
@@ -67,6 +72,7 @@ __all__ = [
|
|
|
67
72
|
"ToolCall",
|
|
68
73
|
"ToolCallChunk",
|
|
69
74
|
"ToolMessage",
|
|
75
|
+
"UsageMetadata",
|
|
70
76
|
"VideoContentBlock",
|
|
71
77
|
"trim_messages",
|
|
72
78
|
]
|