langchain-dev-utils 1.2.14__py3-none-any.whl → 1.2.15__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.
@@ -1 +1 @@
1
- __version__ = "1.2.14"
1
+ __version__ = "1.2.15"
@@ -19,6 +19,7 @@ class ModelDict(TypedDict):
19
19
  model_description: str
20
20
  tools: NotRequired[list[BaseTool | dict[str, Any]]]
21
21
  model_kwargs: NotRequired[dict[str, Any]]
22
+ model_instance: NotRequired[BaseChatModel]
22
23
  model_system_prompt: NotRequired[str]
23
24
 
24
25
 
@@ -76,7 +77,7 @@ class ModelRouterMiddleware(AgentMiddleware):
76
77
  model name or a BaseChatModel instance
77
78
  model_list: List of available routing models, each containing model_name,
78
79
  model_description, tools(Optional), model_kwargs(Optional),
79
- model_system_prompt(Optional)
80
+ model_instance(Optional), model_system_prompt(Optional)
80
81
  router_prompt: Routing prompt template, uses default template if None
81
82
 
82
83
  Examples:
@@ -155,6 +156,7 @@ class ModelRouterMiddleware(AgentMiddleware):
155
156
  "tools": item.get("tools", None),
156
157
  "kwargs": item.get("model_kwargs", None),
157
158
  "system_prompt": item.get("model_system_prompt", None),
159
+ "model_instance": item.get("model_instance", None),
158
160
  }
159
161
  for item in self.model_list
160
162
  }
@@ -163,10 +165,13 @@ class ModelRouterMiddleware(AgentMiddleware):
163
165
  override_kwargs = {}
164
166
  if select_model_name != "default-model" and select_model_name in model_dict:
165
167
  model_values = model_dict.get(select_model_name, {})
166
- if model_values["kwargs"] is not None:
167
- model = load_chat_model(select_model_name, **model_values["kwargs"])
168
+ if model_values["model_instance"] is not None:
169
+ model = model_values["model_instance"]
168
170
  else:
169
- model = load_chat_model(select_model_name)
171
+ if model_values["kwargs"] is not None:
172
+ model = load_chat_model(select_model_name, **model_values["kwargs"])
173
+ else:
174
+ model = load_chat_model(select_model_name)
170
175
  override_kwargs["model"] = model
171
176
  if model_values["tools"] is not None:
172
177
  override_kwargs["tools"] = model_values["tools"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langchain-dev-utils
3
- Version: 1.2.14
3
+ Version: 1.2.15
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
@@ -54,38 +54,38 @@ Tired of writing repetitive code in LangChain development? `langchain-dev-utils`
54
54
 
55
55
  ## ⚡ Quick Start
56
56
 
57
- 1. Install `langchain-dev-utils`:
57
+ **1. Install `langchain-dev-utils`**
58
58
 
59
- ```bash
60
- pip install -U langchain[openai] langchain-dev-utils
61
- ```
59
+ ```bash
60
+ pip install -U "langchain-dev-utils[standard]"
61
+ ```
62
62
 
63
- 2. Start using:
63
+ **2. Start using**
64
64
 
65
- ```python
66
- from langchain.tools import tool
67
- from langchain_core.messages import HumanMessage
68
- from langchain_dev_utils.chat_models import register_model_provider, load_chat_model
69
- from langchain_dev_utils.agents import create_agent
65
+ ```python
66
+ from langchain.tools import tool
67
+ from langchain_core.messages import HumanMessage
68
+ from langchain_dev_utils.chat_models import register_model_provider, load_chat_model
69
+ from langchain_dev_utils.agents import create_agent
70
70
 
71
- # Register model provider
72
- register_model_provider("vllm", "openai-compatible", "http://localhost:8000/v1")
71
+ # Register model provider
72
+ register_model_provider("vllm", "openai-compatible", base_url="http://localhost:8000/v1")
73
73
 
74
- @tool
75
- def get_current_weather(location: str) -> str:
76
- """Get the current weather for the specified location"""
77
- return f"25 degrees, {location}"
74
+ @tool
75
+ def get_current_weather(location: str) -> str:
76
+ """Get the current weather for the specified location"""
77
+ return f"25 degrees, {location}"
78
78
 
79
- # Dynamically load model using string
80
- model = load_chat_model("vllm:qwen3-4b")
81
- response = model.invoke("Hello")
82
- print(response)
79
+ # Dynamically load model using string
80
+ model = load_chat_model("vllm:qwen3-4b")
81
+ response = model.invoke("Hello")
82
+ print(response)
83
83
 
84
- # Create agent
85
- agent = create_agent("vllm:qwen3-4b", tools=[get_current_weather])
86
- response = agent.invoke({"messages": [HumanMessage(content="What's the weather like in New York today?")]})
87
- print(response)
88
- ```
84
+ # Create agent
85
+ agent = create_agent("vllm:qwen3-4b", tools=[get_current_weather])
86
+ response = agent.invoke({"messages": [HumanMessage(content="What's the weather like in New York today?")]})
87
+ print(response)
88
+ ```
89
89
 
90
90
  **For more features of this library, please visit the [full documentation](https://tbice123123.github.io/langchain-dev-utils/)**
91
91
 
@@ -1,4 +1,4 @@
1
- langchain_dev_utils/__init__.py,sha256=mxzjGyB-ihJR05pHYcBiUe_XT5X9wj6cBHLxOXBhAeM,23
1
+ langchain_dev_utils/__init__.py,sha256=Q6rDLuL8XHKQggYBtRCtxzpPQJgFYWn4x0gcVlH7H4g,23
2
2
  langchain_dev_utils/_utils.py,sha256=MFEzR1BjXMj6HEVwt2x2omttFuDJ_rYAEbNqe99r9pM,1338
3
3
  langchain_dev_utils/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  langchain_dev_utils/agents/__init__.py,sha256=PJ-lSDZv_AXMYA3H4fx-HzJa14tPbkGmq1HX8LNfaPo,125
@@ -9,7 +9,7 @@ langchain_dev_utils/agents/wrap.py,sha256=RuchoH_VotPmKFuYEn2SXoSgNxZhSA9jKM0Iv_
9
9
  langchain_dev_utils/agents/middleware/__init__.py,sha256=EECbcYcHXQAMA-guJNRGwCVi9jG957d0nOaoIuyIKC0,832
10
10
  langchain_dev_utils/agents/middleware/format_prompt.py,sha256=rfii98tmOqkjaNHxWy7hovhEYKXrF0CdzsMLO54_CDI,2359
11
11
  langchain_dev_utils/agents/middleware/model_fallback.py,sha256=nivtXXF4cwyOBv6p7RW12nXtNg87wjTWxO3BKIYiroI,1674
12
- langchain_dev_utils/agents/middleware/model_router.py,sha256=pOK-4PNTLrmjaQA9poHoQnsaVwoX0JeJrLVysulv9iU,7631
12
+ langchain_dev_utils/agents/middleware/model_router.py,sha256=sBXp1D1u_mv9g_JN_RcwKp9DONEY3XMWQVb4nGHPgkw,7925
13
13
  langchain_dev_utils/agents/middleware/plan.py,sha256=0qDCmenxgY_zrwMfOyYlgLfhYNw-HszNLeeOkfj14NA,16002
14
14
  langchain_dev_utils/agents/middleware/summarization.py,sha256=IoZ2PM1OC3AXwf0DWpfreuPOAipeiYu0KPmAABWXuY0,3087
15
15
  langchain_dev_utils/agents/middleware/tool_call_repair.py,sha256=oZF0Oejemqs9kSn8xbW79FWyVVarL4IGCz0gpqYBkFM,3529
@@ -32,7 +32,7 @@ langchain_dev_utils/pipeline/types.py,sha256=T3aROKKXeWvd0jcH5XkgMDQfEkLfPaiOhhV
32
32
  langchain_dev_utils/tool_calling/__init__.py,sha256=mu_WxKMcu6RoTf4vkTPbA1WSBSNc6YIqyBtOQ6iVQj4,322
33
33
  langchain_dev_utils/tool_calling/human_in_the_loop.py,sha256=7Z_QO5OZUR6K8nLoIcafc6osnvX2IYNorOJcbx6bVso,9672
34
34
  langchain_dev_utils/tool_calling/utils.py,sha256=S4-KXQ8jWmpGTXYZitovF8rxKpaSSUkFruM8LDwvcvE,2765
35
- langchain_dev_utils-1.2.14.dist-info/METADATA,sha256=QDvbo10fXRhdu1AP-afZ3aa9Tl39fKW1mMI06hY4GVI,4594
36
- langchain_dev_utils-1.2.14.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
37
- langchain_dev_utils-1.2.14.dist-info/licenses/LICENSE,sha256=AWAOzNEcsvCEzHOF0qby5OKxviVH_eT9Yce1sgJTico,1084
38
- langchain_dev_utils-1.2.14.dist-info/RECORD,,
35
+ langchain_dev_utils-1.2.15.dist-info/METADATA,sha256=f5J-j-1HdBe7bor7rXmgFWaLEXYXci0CpppO8hJaJ2U,4516
36
+ langchain_dev_utils-1.2.15.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
37
+ langchain_dev_utils-1.2.15.dist-info/licenses/LICENSE,sha256=AWAOzNEcsvCEzHOF0qby5OKxviVH_eT9Yce1sgJTico,1084
38
+ langchain_dev_utils-1.2.15.dist-info/RECORD,,