langchain-dev-utils 1.2.2__py3-none-any.whl → 1.2.4__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_dev_utils/__init__.py +1 -1
- langchain_dev_utils/agents/middleware/model_fallback.py +1 -1
- langchain_dev_utils/agents/middleware/plan.py +5 -1
- langchain_dev_utils/chat_models/base.py +26 -2
- {langchain_dev_utils-1.2.2.dist-info → langchain_dev_utils-1.2.4.dist-info}/METADATA +6 -5
- {langchain_dev_utils-1.2.2.dist-info → langchain_dev_utils-1.2.4.dist-info}/RECORD +8 -8
- {langchain_dev_utils-1.2.2.dist-info → langchain_dev_utils-1.2.4.dist-info}/WHEEL +1 -1
- {langchain_dev_utils-1.2.2.dist-info → langchain_dev_utils-1.2.4.dist-info}/licenses/LICENSE +0 -0
langchain_dev_utils/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.2.
|
|
1
|
+
__version__ = "1.2.4"
|
|
@@ -17,7 +17,7 @@ class ModelFallbackMiddleware(_ModelFallbackMiddleware):
|
|
|
17
17
|
|
|
18
18
|
Example:
|
|
19
19
|
```python
|
|
20
|
-
from langchain_dev_utils.agents.middleware
|
|
20
|
+
from langchain_dev_utils.agents.middleware import ModelFallbackMiddleware
|
|
21
21
|
from langchain_dev_utils.agents import create_agent
|
|
22
22
|
|
|
23
23
|
fallback = ModelFallbackMiddleware(
|
|
@@ -250,6 +250,8 @@ _PLAN_SYSTEM_PROMPT_NOT_READ_PLAN = """You can manage task plans using two simpl
|
|
|
250
250
|
## finish_sub_plan
|
|
251
251
|
- Call it **only when the current task is 100% done**. It automatically marks it `"done"` and promotes the next `"pending"` task to `"in_progress"`. No parameters needed. Never use it mid-task or if anything’s incomplete.
|
|
252
252
|
Keep plans lean, update immediately, and never batch completions.
|
|
253
|
+
|
|
254
|
+
**Note**: Make sure that all tasks end up with the status `"done"`.
|
|
253
255
|
"""
|
|
254
256
|
|
|
255
257
|
_PLAN_SYSTEM_PROMPT = """You can manage task plans using three simple tools:
|
|
@@ -263,6 +265,8 @@ _PLAN_SYSTEM_PROMPT = """You can manage task plans using three simple tools:
|
|
|
263
265
|
## read_plan
|
|
264
266
|
- Retrieve the full current plan list with statuses, especially when you forget which sub-plan you're supposed to execute next.
|
|
265
267
|
- No parameters required—returns a current plan list with statuses.
|
|
268
|
+
|
|
269
|
+
**Note**: Make sure that all tasks end up with the status `"done"`.
|
|
266
270
|
"""
|
|
267
271
|
|
|
268
272
|
|
|
@@ -290,7 +294,7 @@ class PlanMiddleware(AgentMiddleware):
|
|
|
290
294
|
message_key: The key of the message to be updated. Defaults to "messages".
|
|
291
295
|
Example:
|
|
292
296
|
```python
|
|
293
|
-
from langchain_dev_utils.agents.middleware
|
|
297
|
+
from langchain_dev_utils.agents.middleware import PlanMiddleware
|
|
294
298
|
from langchain_dev_utils.agents import create_agent
|
|
295
299
|
|
|
296
300
|
agent = create_agent("vllm:qwen3-4b", middleware=[PlanMiddleware()])
|
|
@@ -14,6 +14,7 @@ class ChatModelProvider(TypedDict):
|
|
|
14
14
|
provider_name: str
|
|
15
15
|
chat_model: ChatModelType
|
|
16
16
|
base_url: NotRequired[str]
|
|
17
|
+
provider_profile: NotRequired[dict[str, dict[str, Any]]]
|
|
17
18
|
provider_config: NotRequired[ProviderConfig]
|
|
18
19
|
|
|
19
20
|
|
|
@@ -94,6 +95,11 @@ def _load_chat_model_helper(
|
|
|
94
95
|
url_key = _get_base_url_field_name(chat_model)
|
|
95
96
|
if url_key:
|
|
96
97
|
kwargs.update({url_key: base_url})
|
|
98
|
+
if provider_profile := _MODEL_PROVIDERS_DICT[model_provider].get(
|
|
99
|
+
"provider_profile"
|
|
100
|
+
):
|
|
101
|
+
if model in provider_profile:
|
|
102
|
+
kwargs.update({"profile": provider_profile[model]})
|
|
97
103
|
return chat_model(model=model, **kwargs)
|
|
98
104
|
|
|
99
105
|
return _init_chat_model_helper(model, model_provider=model_provider, **kwargs)
|
|
@@ -103,6 +109,7 @@ def register_model_provider(
|
|
|
103
109
|
provider_name: str,
|
|
104
110
|
chat_model: ChatModelType,
|
|
105
111
|
base_url: Optional[str] = None,
|
|
112
|
+
provider_profile: Optional[dict[str, dict[str, Any]]] = None,
|
|
106
113
|
provider_config: Optional[ProviderConfig] = None,
|
|
107
114
|
):
|
|
108
115
|
"""Register a new model provider.
|
|
@@ -115,6 +122,7 @@ def register_model_provider(
|
|
|
115
122
|
provider_name: Name of the provider to register
|
|
116
123
|
chat_model: Either a BaseChatModel class or a string identifier for a supported provider
|
|
117
124
|
base_url: The API address of the model provider (optional, valid for both types of `chat_model`, but mainly used when `chat_model` is a string and is "openai-compatible")
|
|
125
|
+
provider_profile: Model provider's model configuration file (optional, valid for both types of `chat_model`); finally, it will read the corresponding model configuration parameters based on `model_name` and set them to `model.profile`.
|
|
118
126
|
provider_config: The configuration of the model provider (Optional parameter;effective only when `chat_model` is a string and is "openai-compatible".)
|
|
119
127
|
It can be configured to configure some related parameters of the provider, such as whether to support json_mode structured output mode, the list of supported tool_choice
|
|
120
128
|
Raises:
|
|
@@ -164,16 +172,30 @@ def register_model_provider(
|
|
|
164
172
|
"chat_model": chat_model,
|
|
165
173
|
"provider_config": provider_config,
|
|
166
174
|
"base_url": base_url,
|
|
175
|
+
"provider_profile": provider_profile,
|
|
167
176
|
}
|
|
168
177
|
}
|
|
169
178
|
)
|
|
170
179
|
else:
|
|
171
180
|
if base_url is not None:
|
|
172
181
|
_MODEL_PROVIDERS_DICT.update(
|
|
173
|
-
{
|
|
182
|
+
{
|
|
183
|
+
provider_name: {
|
|
184
|
+
"chat_model": chat_model,
|
|
185
|
+
"base_url": base_url,
|
|
186
|
+
"provider_profile": provider_profile,
|
|
187
|
+
}
|
|
188
|
+
}
|
|
174
189
|
)
|
|
175
190
|
else:
|
|
176
|
-
_MODEL_PROVIDERS_DICT.update(
|
|
191
|
+
_MODEL_PROVIDERS_DICT.update(
|
|
192
|
+
{
|
|
193
|
+
provider_name: {
|
|
194
|
+
"chat_model": chat_model,
|
|
195
|
+
"provider_profile": provider_profile,
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
)
|
|
177
199
|
|
|
178
200
|
|
|
179
201
|
def batch_register_model_provider(
|
|
@@ -189,6 +211,7 @@ def batch_register_model_provider(
|
|
|
189
211
|
- provider_name: Name of the provider to register
|
|
190
212
|
- chat_model: Either a BaseChatModel class or a string identifier for a supported provider
|
|
191
213
|
- base_url: The API address of the model provider (optional, valid for both types of `chat_model`, but mainly used when `chat_model` is a string and is "openai-compatible")
|
|
214
|
+
- provider_profile: Model provider's model configuration file (optional, valid for both types of `chat_model`); finally, it will read the corresponding model configuration parameters based on `model_name` and set them to `model.profile`.
|
|
192
215
|
- provider_config: The configuration of the model provider(Optional parameter; effective only when `chat_model` is a string and is "openai-compatible".)
|
|
193
216
|
It can be configured to configure some related parameters of the provider, such as whether to support json_mode structured output mode, the list of supported tool_choice
|
|
194
217
|
|
|
@@ -222,6 +245,7 @@ def batch_register_model_provider(
|
|
|
222
245
|
provider["provider_name"],
|
|
223
246
|
provider["chat_model"],
|
|
224
247
|
provider.get("base_url"),
|
|
248
|
+
provider_profile=provider.get("provider_profile"),
|
|
225
249
|
provider_config=provider.get("provider_config"),
|
|
226
250
|
)
|
|
227
251
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: langchain-dev-utils
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.4
|
|
4
4
|
Summary: A practical utility library for LangChain and LangGraph development
|
|
5
5
|
Project-URL: Source Code, https://github.com/TBice123123/langchain-dev-utils
|
|
6
6
|
Project-URL: repository, https://github.com/TBice123123/langchain-dev-utils
|
|
@@ -62,6 +62,7 @@ Mainly consists of the following two functions:
|
|
|
62
62
|
- `provider_name`: Model provider name, used as an identifier for subsequent model loading
|
|
63
63
|
- `chat_model`: Chat model, can be a ChatModel or a string (currently supports "openai-compatible")
|
|
64
64
|
- `base_url`: The API address of the model provider (optional, valid for both types of `chat_model`, but mainly used when `chat_model` is a string and is "openai-compatible")
|
|
65
|
+
- `provider_profile`: Model provider's model configuration file (optional, valid for both types of `chat_model`); finally, it will read the corresponding model configuration parameters based on `model_name` and set them to `model.profile`.
|
|
65
66
|
- `provider_config`: Relevant configuration for the model provider (optional, valid when `chat_model` is a string and is "openai-compatible"), can configure some provider-related parameters, such as whether to support structured output in json_mode, list of supported tool_choices, etc.
|
|
66
67
|
|
|
67
68
|
`load_chat_model` parameter description:
|
|
@@ -171,7 +172,7 @@ text = format_sequence([
|
|
|
171
172
|
], separator="\n", with_num=True)
|
|
172
173
|
```
|
|
173
174
|
|
|
174
|
-
**For more information about message conversion, please refer to**: [Message
|
|
175
|
+
**For more information about message conversion, please refer to**: [Message Process](https://tbice123123.github.io/langchain-dev-utils-docs/en/message-conversion/message.html), [Formatting List Content](https://tbice123123.github.io/langchain-dev-utils-docs/en/message-conversion/format.html)
|
|
175
176
|
|
|
176
177
|
### 3. **Tool Calling**
|
|
177
178
|
|
|
@@ -231,7 +232,7 @@ def get_current_time() -> str:
|
|
|
231
232
|
return str(datetime.datetime.now().timestamp())
|
|
232
233
|
```
|
|
233
234
|
|
|
234
|
-
**For more information about tool calling, please refer to**: [Add Human-in-the-Loop Support](https://tbice123123.github.io/langchain-dev-utils-docs/en/tool-calling/human-in-the-loop.html), [Tool Call
|
|
235
|
+
**For more information about tool calling, please refer to**: [Add Human-in-the-Loop Support](https://tbice123123.github.io/langchain-dev-utils-docs/en/tool-calling/human-in-the-loop.html), [Tool Call Handling](https://tbice123123.github.io/langchain-dev-utils-docs/en/tool-calling/tool.html)
|
|
235
236
|
|
|
236
237
|
### 4. **Agent Development**
|
|
237
238
|
|
|
@@ -278,7 +279,7 @@ response = agent.invoke({"messages": [{"role": "user", "content": "Give me a tra
|
|
|
278
279
|
print(response)
|
|
279
280
|
```
|
|
280
281
|
|
|
281
|
-
**For more information about agent development and all built-in middleware, please refer to**: [
|
|
282
|
+
**For more information about agent development and all built-in middleware, please refer to**: [Pre-built Agent Functions](https://tbice123123.github.io/langchain-dev-utils-docs/en/agent-development/prebuilt.html), [Middleware](https://tbice123123.github.io/langchain-dev-utils-docs/en/agent-development/middleware.html)
|
|
282
283
|
|
|
283
284
|
### 5. **State Graph Orchestration**
|
|
284
285
|
|
|
@@ -391,7 +392,7 @@ response = graph.invoke({"messages": [HumanMessage("Hello")]})
|
|
|
391
392
|
print(response)
|
|
392
393
|
```
|
|
393
394
|
|
|
394
|
-
**For more information about state graph orchestration, please refer to**: [State Graph Orchestration
|
|
395
|
+
**For more information about state graph orchestration, please refer to**: [State Graph Orchestration](https://tbice123123.github.io/langchain-dev-utils-docs/en/graph-orchestration/pipeline.html)
|
|
395
396
|
|
|
396
397
|
## 💬 Join the Community
|
|
397
398
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
langchain_dev_utils/__init__.py,sha256=
|
|
1
|
+
langchain_dev_utils/__init__.py,sha256=XBKH8E1LmDxv06U39yqMBbXZapOERFgICEDYZs_kRso,22
|
|
2
2
|
langchain_dev_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
langchain_dev_utils/agents/__init__.py,sha256=e17SMQdJIQngbUCr2N1tY-yw0tD3tEnH7PSvyDmVPeQ,127
|
|
4
4
|
langchain_dev_utils/agents/factory.py,sha256=h4uAkid2NJMMs4qV6RYFexew-ixfhEvpa254eDeDEcU,3912
|
|
@@ -6,14 +6,14 @@ langchain_dev_utils/agents/file_system.py,sha256=S6RUEmQI2eerW0gBQp0IP0X5ak5Fwvq
|
|
|
6
6
|
langchain_dev_utils/agents/plan.py,sha256=ydJuJLlNydheQvLPl2uCc3TBVv42YxGzPhKgtldIdIk,6497
|
|
7
7
|
langchain_dev_utils/agents/wrap.py,sha256=4BWksU9DRz8c3ZHQiUi4GHwGhNysDLNs8pmLWV7BeAI,5165
|
|
8
8
|
langchain_dev_utils/agents/middleware/__init__.py,sha256=cjrb8Rue5uukl9pKPF7CjSrHtcYsUBj3Mdvv2szlp7E,679
|
|
9
|
-
langchain_dev_utils/agents/middleware/model_fallback.py,sha256=
|
|
9
|
+
langchain_dev_utils/agents/middleware/model_fallback.py,sha256=pXdraahOMukLgvjX70LwhrjIoEhLYQfNEwJMQHG2WPk,1673
|
|
10
10
|
langchain_dev_utils/agents/middleware/model_router.py,sha256=bq-sQ7wmvpeRM3cjFPErLQxiWfS6l5nEVBN01NNWjAU,9077
|
|
11
|
-
langchain_dev_utils/agents/middleware/plan.py,sha256=
|
|
11
|
+
langchain_dev_utils/agents/middleware/plan.py,sha256=saRXhzkC2pd7LNiNclSmGJelmisbTXhhTrbSUkSkf9g,16220
|
|
12
12
|
langchain_dev_utils/agents/middleware/summarization.py,sha256=BtWPJcQBssGAT0nb1c0xsGEOsb8x5sAAE6xqujYjHhY,3027
|
|
13
13
|
langchain_dev_utils/agents/middleware/tool_emulator.py,sha256=u9rV24yUB-dyc1uUfUe74B1wOGVI3TZRwxkE1bvGm18,2025
|
|
14
14
|
langchain_dev_utils/agents/middleware/tool_selection.py,sha256=ZqdyK4Yhp2u3GM6B_D6U7Srca9vy1o7s6N_LrV24-dQ,3107
|
|
15
15
|
langchain_dev_utils/chat_models/__init__.py,sha256=YSLUyHrWEEj4y4DtGFCOnDW02VIYZdfAH800m4Klgeg,224
|
|
16
|
-
langchain_dev_utils/chat_models/base.py,sha256=
|
|
16
|
+
langchain_dev_utils/chat_models/base.py,sha256=emQs5biWgeqP9a8cEoovpOzn34w91-_SiTnytu-C5PM,12051
|
|
17
17
|
langchain_dev_utils/chat_models/types.py,sha256=FM_RyiGRTb1dy59MovhDYM4Kj9cpybt2BFha0e2u0qA,468
|
|
18
18
|
langchain_dev_utils/chat_models/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
19
|
langchain_dev_utils/chat_models/adapters/openai_compatible.py,sha256=wR7Uym9rQWsxhsBt8LrE30dayWcMnbsU8AXC4kOtnyI,19719
|
|
@@ -29,7 +29,7 @@ langchain_dev_utils/pipeline/types.py,sha256=T3aROKKXeWvd0jcH5XkgMDQfEkLfPaiOhhV
|
|
|
29
29
|
langchain_dev_utils/tool_calling/__init__.py,sha256=mu_WxKMcu6RoTf4vkTPbA1WSBSNc6YIqyBtOQ6iVQj4,322
|
|
30
30
|
langchain_dev_utils/tool_calling/human_in_the_loop.py,sha256=nbaON9806pv5tpMRQUA_Ch3HJA5HBFgzZR7kQRf6PiY,9819
|
|
31
31
|
langchain_dev_utils/tool_calling/utils.py,sha256=3cNv_Zx32KxdsGn8IkxjWUzxYEEwVJeJgTZTbfSg0pA,2751
|
|
32
|
-
langchain_dev_utils-1.2.
|
|
33
|
-
langchain_dev_utils-1.2.
|
|
34
|
-
langchain_dev_utils-1.2.
|
|
35
|
-
langchain_dev_utils-1.2.
|
|
32
|
+
langchain_dev_utils-1.2.4.dist-info/METADATA,sha256=1bYaEqoBkx54fvr35w355lth8_OwMz4g2OS1SWnzlag,16536
|
|
33
|
+
langchain_dev_utils-1.2.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
34
|
+
langchain_dev_utils-1.2.4.dist-info/licenses/LICENSE,sha256=AWAOzNEcsvCEzHOF0qby5OKxviVH_eT9Yce1sgJTico,1084
|
|
35
|
+
langchain_dev_utils-1.2.4.dist-info/RECORD,,
|
{langchain_dev_utils-1.2.2.dist-info → langchain_dev_utils-1.2.4.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|