Compare commits

..
Author SHA1 Message Date
William Fu-Hinthorn ebb781c0f8 Support mount_prefix in langgraph-sdk
Signed-off-by: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com>
2025-04-07 12:36:37 -07:00
Eugene YurtsevandGitHub 05a4fcc8bb cli: release 0.1.89 (#4173)
Release to pick up this: https://github.com/langchain-ai/langgraph/pull/4164
2025-04-04 13:46:47 -04:00
Eugene YurtsevandGitHub adac016e33 cli: support dict format for graph specification in langgraph.json (#4164)
Allow the CLI to work with dict format for the graph specification.

```json
{
  "dependencies": ["./my_agent"],
  "graphs": {
    "agent": {
      "path": "./my_agent/agent.py:graph",
      "description": "this is my agent description"
    }
  },
  "env": ".env"
}
```

And backwards compatible with:

```json
{
  "dependencies": ["./my_agent"],
  "graphs": {
    "agent": "./my_agent/agent.py:graph",
  },
  "env": ".env"
}
```
2025-04-04 10:16:20 -04:00
5 changed files with 73 additions and 4 deletions
+20 -2
View File
@@ -778,7 +778,22 @@ def _update_graph_paths(
FileNotFoundError: If the local file (module) does not actually exist on disk.
IsADirectoryError: If `module_str` points to a directory instead of a file.
"""
for graph_id, import_str in config["graphs"].items():
for graph_id, data in config["graphs"].items():
if isinstance(data, dict):
# Then we're looking for a 'path' key
if "path" not in data:
raise ValueError(
f"Graph '{graph_id}' must contain a 'path' key if "
f" it is a dictionary."
)
import_str = data["path"]
elif isinstance(data, str):
import_str = data
else:
raise ValueError(
f"Graph '{graph_id}' must be a string or a dictionary with a 'path' key."
)
module_str, _, attr_str = import_str.partition(":")
if not module_str or not attr_str:
message = (
@@ -818,7 +833,10 @@ def _update_graph_paths(
"Add its containing package to 'dependencies' list."
)
# update the config
config["graphs"][graph_id] = f"{module_str}:{attr_str}"
if isinstance(data, dict):
config["graphs"][graph_id]["path"] = f"{module_str}:{attr_str}"
else:
config["graphs"][graph_id] = f"{module_str}:{attr_str}"
def _update_auth_path(
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langgraph-cli"
version = "0.1.84"
version = "0.1.89"
description = "CLI for interacting with LangGraph API"
authors = []
license = "MIT"
+44
View File
@@ -196,6 +196,50 @@ def test_dockerfile_command_basic() -> None:
assert save_path.exists()
def test_dockerfile_command_new_style_config() -> None:
"""Test `dockerfile` command with a new style config.
This config format allows specifying agent data as a dictionary.
{
"graphs": {
"agent1": {
"path": ... # path to graph definition,
... # other fields
}
}
}
"""
runner = CliRunner()
config_content = {
"dependencies": ["./my_agent"],
"graphs": {
"agent": {
"path": "./my_agent/agent.py:graph",
"description": "This is a test agent",
}
},
"env": ".env",
}
with temporary_config_folder(config_content) as temp_dir:
save_path = temp_dir / "Dockerfile"
# Add agent.py file
agent_path = temp_dir / "my_agent" / "agent.py"
agent_path.parent.mkdir(parents=True, exist_ok=True)
agent_path.touch()
result = runner.invoke(
cli,
["dockerfile", str(save_path), "--config", str(temp_dir / "config.json")],
)
# Assert command was successful
assert result.exit_code == 0, result.output
assert "✅ Created: Dockerfile" in result.output
# Check if Dockerfile was created
assert save_path.exists()
def test_dockerfile_command_with_docker_compose() -> None:
"""Test the 'dockerfile' command with Docker Compose configuration."""
runner = CliRunner()
+7
View File
@@ -162,6 +162,13 @@ def get_client(
transport = httpx.ASGITransport(app, root_path="/noauth")
except Exception:
url = "http://localhost:8123"
try:
from langgraph_api.config import HTTP_CONFIG
if prefix := HTTP_CONFIG.get("mount_prefix"):
url = f"{url}{prefix}"
except ImportError:
pass
if transport is None:
transport = httpx.AsyncHTTPTransport(retries=5)
+1 -1
View File
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langgraph-sdk"
version = "0.1.61"
version = "0.1.62"
description = "SDK for interacting with LangGraph API"
authors = []
license = "MIT"