Skip to content

The agent engineering platform.

CLI 0.0.13, Configurable Template Demo (#12796)

Erick Friis49e283a0cdec
diff --git a/libs/cli/langchain_cli/cli.py b/libs/cli/langchain_cli/cli.py
index 1ef0291b4e..3a6bcca9fc 100644
--- a/libs/cli/langchain_cli/cli.py
+++ b/libs/cli/langchain_cli/cli.py
@@ -6,7 +6,7 @@ from typing_extensions import Annotated
from langchain_cli.namespaces import app as app_namespace
from langchain_cli.namespaces import template as template_namespace
-__version__ = "0.0.12"
+__version__ = "0.0.13"
app = typer.Typer(no_args_is_help=True, add_completion=False)
app.add_typer(
diff --git a/libs/cli/langchain_cli/dev_scripts.py b/libs/cli/langchain_cli/dev_scripts.py
index ab9617ce0a..90001d4799 100644
--- a/libs/cli/langchain_cli/dev_scripts.py
+++ b/libs/cli/langchain_cli/dev_scripts.py
@@ -2,6 +2,8 @@
Development Scripts for template packages
"""
+from typing import Sequence
+
from fastapi import FastAPI
from langserve import add_routes
from langserve.packages import get_langserve_export
@@ -9,7 +11,10 @@ from langserve.packages import get_langserve_export
from langchain_cli.utils.packages import get_package_root
-def create_demo_server():
+def create_demo_server(
+ *,
+ config_keys: Sequence[str] = (),
+):
"""
Creates a demo server for the current template.
"""
@@ -22,10 +27,18 @@ def create_demo_server():
mod = __import__(package["module"], fromlist=[package["attr"]])
chain = getattr(mod, package["attr"])
- add_routes(app, chain)
+ add_routes(
+ app,
+ chain,
+ config_keys=config_keys,
+ )
except KeyError as e:
raise KeyError("Missing fields from pyproject.toml") from e
except ImportError as e:
raise ImportError("Could not import module defined in pyproject.toml") from e
return app
+
+
+def create_demo_server_configurable():
+ return create_demo_server(config_keys=["configurable"])
diff --git a/libs/cli/langchain_cli/namespaces/template.py b/libs/cli/langchain_cli/namespaces/template.py
index 121bd41492..d9dc9e76f5 100644
--- a/libs/cli/langchain_cli/namespaces/template.py
+++ b/libs/cli/langchain_cli/namespaces/template.py
@@ -90,6 +90,13 @@ def serve(
host: Annotated[
Optional[str], typer.Option(help="The host to run the server on")
] = None,
+ configurable: Annotated[
+ bool,
+ typer.Option(
+ "--configurable/--no-configurable",
+ help="Whether to include a configurable route",
+ ),
+ ] = True,
) -> None:
"""
Starts a demo app for this template.
@@ -104,10 +111,16 @@ def serve(
port_str = str(port) if port is not None else "8000"
host_str = host if host is not None else "127.0.0.1"
+ script = (
+ "langchain_cli.dev_scripts:create_demo_server"
+ if not configurable
+ else "langchain_cli.dev_scripts:create_demo_server_configurable"
+ )
+
command = [
"uvicorn",
"--factory",
- "langchain_cli.dev_scripts:create_demo_server",
+ script,
"--reload",
"--port",
port_str,
diff --git a/libs/cli/pyproject.toml b/libs/cli/pyproject.toml
index 86202c4bd9..d404ac02ea 100644
--- a/libs/cli/pyproject.toml
+++ b/libs/cli/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langchain-cli"
-version = "0.0.12"
+version = "0.0.13"
description = "CLI for interacting with LangChain"
authors = ["Erick Friis <[email protected]>"]
readme = "README.md"