A practical utility library for LangChain and LangGraph development
Project description
langchain-dev-utils
A practical enhancement utility library for LangChain / LangGraph developers, empowering the construction of complex and maintainable large language model applications.
🚀 Installation
pip install -U langchain-dev-utils
📦 Core Features
1. Model Management
- Supports registering any chat model or embedding model provider
- Provides unified interfaces
load_chat_model()/load_embeddings()to simplify model loading - Fully compatible with LangChain’s official
init_chat_model/init_embeddings, enabling seamless extension
from langchain_dev_utils import register_model_provider, load_chat_model
from langchain_qwq import ChatQwen
register_model_provider("dashscope", ChatQwen)
register_model_provider("openrouter", "openai", base_url="https://openrouter.ai/api/v1")
model = load_chat_model("dashscope:qwen-flash")
print(model.invoke("Hello!"))
2. Message Processing
- Automatically merges reasoning content (e.g., from DeepSeek models) into the
contentfield - Supports streaming and asynchronous streaming responses (
stream/astream) - Utility functions include:
merge_ai_message_chunk(): merges message chunkshas_tool_calling()/parse_tool_calling(): detects and parses tool callsmessage_format(): formats messages or document lists (with numbering, separators, etc.)
from langchain_dev_utils import has_tool_calling, parse_tool_calling
response = model.invoke("What time is it now?")
if has_tool_calling(response):
tool_calls = parse_tool_calling(response)
print(tool_calls)
3. Tool Enhancement
- Easily extend existing tools with new capabilities
- Currently supports adding human-in-the-loop functionality to tools
from langchain_dev_utils import human_in_the_loop_async
from langchain_core.tools import tool
import asyncio
import datetime
@human_in_the_loop_async
@tool
async def async_get_current_time() -> str:
"""Asynchronously retrieve the current timestamp"""
await asyncio.sleep(1)
return str(datetime.datetime.now().timestamp())
4. Context Engineering
-
Automatically generates essential context management tools:
create_write_plan_tool()/create_update_plan_tool()create_write_note_tool()/create_query_note_tool()/create_ls_tool()/create_update_note_tool()
-
Provides corresponding State classes—no need to reimplement them
from langchain_dev_utils import (
create_write_plan_tool,
create_update_plan_tool,
create_write_note_tool,
create_ls_tool,
create_query_note_tool,
create_update_note_tool,
)
plan_tools = [create_write_plan_tool(), create_update_plan_tool()]
note_tools = [create_write_note_tool(), create_ls_tool(), create_query_note_tool(), create_update_note_tool()]
5. Graph Orchestration
- Composes multiple
StateGraphs in sequential or parallel fashion - Supports complex multi-agent workflows:
sequential_pipeline(): executes subgraphs sequentiallyparallel_pipeline(): executes subgraphs in parallel with dynamic branching (via theSendAPI)
- Allows specifying entry nodes and custom state/input/output schemas
from langchain_dev_utils import parallel_pipeline
graph = parallel_pipeline(
sub_graphs=[graph1, graph2, graph3],
state_schema=State,
branches_fn=lambda state: [
Send("graph1", arg={"a": state["a"]}),
Send("graph2", arg={"a": state["a"]}),
]
)
📚 Documentation and Examples
For more information, please refer to the following documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file langchain_dev_utils-0.1.15.tar.gz.
File metadata
- Download URL: langchain_dev_utils-0.1.15.tar.gz
- Upload date:
- Size: 70.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5914e6f5ef37b6e7103a742e5afabff27369ebddc2a6adbb39fdb062b1afea40
|
|
| MD5 |
6c36df5d344b0ba59d048736406ccc2c
|
|
| BLAKE2b-256 |
4c5fe9cafe6ae24416c5604ab7571bf916eb862fdf83fe62c01399459b65408e
|
File details
Details for the file langchain_dev_utils-0.1.15-py3-none-any.whl.
File metadata
- Download URL: langchain_dev_utils-0.1.15-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abf58b6309e405dbfabab12585208c645354a38e89d53281b5802430b61db38e
|
|
| MD5 |
029700941f1aabb29ac20baa4477fd2a
|
|
| BLAKE2b-256 |
47172f4b6b187405f03add843989b8ea742fed3145fc9ed7ada6ae8df6fbe9e8
|