LangChain Tools JSON Converter
This module provides utility functions to convert LangChain tool objects into JSON format and vice versa. It helps serialize and deserialize structured tool definitions for easier storage and transport.
Features
create_tools_json: Converts a list of LangChain tool objects into a JSON string.json_to_structured_tools: Converts a JSON representation of LangChain tools back intoStructuredToolobjects.
Installation
Ensure you have langchain_core installed before using this module:
pip install langchain-core
Usage
Converting Tools to JSON
from langchain_core.tools import StructuredTool
# Example tool
example_tool = StructuredTool(
name="example_tool",
description="An example tool",
func=None,
args_schema={}
)
# Convert to JSON
json_output = create_tools_json([example_tool])
print(json_output)
Converting JSON to Structured Tools
json_tools = [
{
"name": "example_tool",
"description": "An example tool",
"args_schema": {}
}
]
structured_tools = json_to_structured_tools(json_tools)
print(structured_tools)
Function Details
create_tools_json(tools)
Description: Converts a list of LangChain tool objects into a JSON string.
Parameters:
tools(List ofStructuredToolobjects): List of tool objects to be serialized.
Returns:
str: JSON string representation of the tools.
json_to_structured_tools(json_tools)
Description: Converts JSON-formatted LangChain tools into StructuredTool objects.
Parameters:
json_tools(list or dict): A list or single JSON object representing tools.
Returns:
StructuredToolor List ofStructuredToolobjects.
Notes
- The
funcattribute is set toNonewhen reconstructingStructuredToolobjects from JSON. - Ensure that the
args_schemamatches the expected schema format for LangChain.
License
This module is open-source and can be modified as needed.
Metadata
Release files for langgraph-utils 0.0.7.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| langgraph_utils-0.0.7.4.tar.gz | 4.5 kB | Without provenance | Details for langgraph_utils-0.0.7.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| langgraph_utils-0.0.7.4-py3-none-any.whl | Python 3 | none | any | Details for langgraph_utils-0.0.7.4-py3-none-any.whl |
Total release size: 8.3 kB
Release files / langgraph_utils-0.0.7.4.tar.gz
| Download URL | langgraph_utils-0.0.7.4.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ec11dd1e0edf71f5ffafc985051605fdbb44d0abe47c66f396ffae0aebbbeb5e
|
|
BLAKE2b-256 checksum How to use checksums |
71e09923e4556eaeed652d62df0321c474d4f53de92871c2ed794055f274069a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|
Release files / langgraph_utils-0.0.7.4-py3-none-any.whl
| Download URL | langgraph_utils-0.0.7.4-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26139c28f443e7296630342e62292976b7decd11073ac7ca5486f68bbe9e4143
|
|
BLAKE2b-256 checksum How to use checksums |
fbfdde4b2c6f2db906a68b1fb503e050700957a7c54f20455cc25b042e975c00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.16
|
Security for langgraph-utils 0.0.7.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.