Skip to main content

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-compatible", 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 content field
  • Supports streaming and asynchronous streaming responses (stream / astream)
  • Utility functions include:
    • merge_ai_message_chunk(): merges message chunks
    • has_tool_calling() / parse_tool_calling(): detects and parses tool calls
    • message_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 sequentially
    • parallel_pipeline(): executes subgraphs in parallel with dynamic branching (via the Send API)
  • 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

langchain_dev_utils-0.1.23.tar.gz (76.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_dev_utils-0.1.23-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file langchain_dev_utils-0.1.23.tar.gz.

File metadata

File hashes

Hashes for langchain_dev_utils-0.1.23.tar.gz
Algorithm Hash digest
SHA256 5198e3aa0fd104621aac504c78ee4c1e41e942db386cc90ea52a12bc2c52e4ed
MD5 8dcaaddd6897ef2ec046a1eb6de313b9
BLAKE2b-256 ad6407ff8177ea2d99dd68a57ccf668e9a9117c89879fde7ad71fc2d9f3cc35a

See more details on using hashes here.

File details

Details for the file langchain_dev_utils-0.1.23-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_dev_utils-0.1.23-py3-none-any.whl
Algorithm Hash digest
SHA256 3c4c6f997b396edd35ae7165884e2dfc115262bbfafe8ec1bc6ee8e67efd1cee
MD5 a6c5351b6f1fab8c232e5e4fae48b999
BLAKE2b-256 b6dae9d9d7086aab39596e18fa98bb5a9d4777aabbb118bb9546ad60308af956

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page