Skip to content

The agent engineering platform.

add a template for the package readme (#12499)

Harrison Chase8b5e8791711f
diff --git a/libs/cli/DOCS.md b/libs/cli/DOCS.md
index 63fbc8761d..47f4d6647f 100644
--- a/libs/cli/DOCS.md
+++ b/libs/cli/DOCS.md
@@ -12,18 +12,18 @@ $ langchain [OPTIONS] COMMAND [ARGS]...
**Commands**:
-* `hub`: Manage installable hub packages.
-* `serve`: Manage LangServe application projects.
-* `start`: Start the LangServe instance, whether it's...
+* `app`: Manage LangChain apps
+* `serve`: Start the LangServe app, whether it's a...
+* `template`: Develop installable templates.
-## `langchain hub`
+## `langchain app`
-Manage installable hub packages.
+Manage LangChain apps
**Usage**:
```console
-$ langchain hub [OPTIONS] COMMAND [ARGS]...
+$ langchain app [OPTIONS] COMMAND [ARGS]...
```
**Options**:
@@ -32,182 +32,157 @@ $ langchain hub [OPTIONS] COMMAND [ARGS]...
**Commands**:
-* `new`: Creates a new hub package.
-* `start`: Starts a demo LangServe instance for this...
+* `add`: Adds the specified template to the current...
+* `new`: Create a new LangServe application.
+* `remove`: Removes the specified package from the...
+* `serve`: Starts the LangServe app.
+
+### `langchain app add`
-### `langchain hub new`
+Adds the specified template to the current LangServe app.
-Creates a new hub package.
+e.g.:
+langchain app add extraction-openai-functions
+langchain app add git+ssh://[email protected]/efriis/simple-pirate.git
**Usage**:
```console
-$ langchain hub new [OPTIONS] NAME
+$ langchain app add [OPTIONS] [DEPENDENCIES]...
```
**Arguments**:
-* `NAME`: [required]
+* `[DEPENDENCIES]...`: The dependency to add
**Options**:
+* `--api-path TEXT`: API paths to add
+* `--project-dir PATH`: The project directory
+* `--repo TEXT`: Install templates from a specific github repo instead
+* `--branch TEXT`: Install templates from a specific branch
* `--help`: Show this message and exit.
-### `langchain hub start`
+### `langchain app new`
-Starts a demo LangServe instance for this hub package.
+Create a new LangServe application.
**Usage**:
```console
-$ langchain hub start [OPTIONS]
+$ langchain app new [OPTIONS] NAME
```
-**Options**:
-
-* `--port INTEGER`
-* `--host TEXT`
-* `--help`: Show this message and exit.
-
-## `langchain serve`
-
-Manage LangServe application projects.
-
-**Usage**:
+**Arguments**:
-```console
-$ langchain serve [OPTIONS] COMMAND [ARGS]...
-```
+* `NAME`: The name of the folder to create [required]
**Options**:
+* `--package TEXT`: Packages to seed the project with
* `--help`: Show this message and exit.
-**Commands**:
+### `langchain app remove`
-* `add`: Adds the specified package to the current...
-* `install`
-* `list`: Lists all packages in the current...
-* `new`: Create a new LangServe application.
-* `remove`: Removes the specified package from the...
-* `start`: Starts the LangServe instance.
-
-### `langchain serve add`
-
-Adds the specified package to the current LangServe instance.
-
-e.g.:
-langchain serve add extraction-openai-functions
-langchain serve add git+ssh://[email protected]/efriis/simple-pirate.git
-langchain serve add git+https://github.com/efriis/hub.git#devbranch#subdirectory=mypackage
+Removes the specified package from the current LangServe app.
**Usage**:
```console
-$ langchain serve add [OPTIONS] DEPENDENCIES...
+$ langchain app remove [OPTIONS] API_PATHS...
```
**Arguments**:
-* `DEPENDENCIES...`: [required]
+* `API_PATHS...`: The API paths to remove [required]
**Options**:
-* `--api-path TEXT`
-* `--project-dir PATH`
* `--help`: Show this message and exit.
-### `langchain serve install`
+### `langchain app serve`
+
+Starts the LangServe app.
**Usage**:
```console
-$ langchain serve install [OPTIONS]
+$ langchain app serve [OPTIONS]
```
**Options**:
+* `--port INTEGER`: The port to run the server on
+* `--host TEXT`: The host to run the server on
+* `--app TEXT`: The app to run, e.g. `app.server:app`
* `--help`: Show this message and exit.
-### `langchain serve list`
+## `langchain serve`
-Lists all packages in the current LangServe instance.
+Start the LangServe app, whether it's a template or an app.
**Usage**:
```console
-$ langchain serve list [OPTIONS]
+$ langchain serve [OPTIONS]
```
**Options**:
+* `--port INTEGER`: The port to run the server on
+* `--host TEXT`: The host to run the server on
* `--help`: Show this message and exit.
-### `langchain serve new`
+## `langchain template`
-Create a new LangServe application.
+Develop installable templates.
**Usage**:
```console
-$ langchain serve new [OPTIONS] NAME
+$ langchain template [OPTIONS] COMMAND [ARGS]...
```
-**Arguments**:
-
-* `NAME`: [required]
-
**Options**:
-* `--package TEXT`
* `--help`: Show this message and exit.
-### `langchain serve remove`
+**Commands**:
+
+* `new`: Creates a new template package.
+* `serve`: Starts a demo app for this template.
-Removes the specified package from the current LangServe instance.
+### `langchain template new`
+
+Creates a new template package.
**Usage**:
```console
-$ langchain serve remove [OPTIONS] API_PATHS...
+$ langchain template new [OPTIONS] NAME
```
**Arguments**:
-* `API_PATHS...`: [required]
-
-**Options**:
-
-* `--help`: Show this message and exit.
-
-### `langchain serve start`
-
-Starts the LangServe instance.
-
-**Usage**:
-
-```console
-$ langchain serve start [OPTIONS]
-```
+* `NAME`: The name of the folder to create [required]
**Options**:
-* `--port INTEGER`
-* `--host TEXT`
+* `--with-poetry / --no-poetry`: Don't run poetry install [default: no-poetry]
* `--help`: Show this message and exit.
-## `langchain start`
+### `langchain template serve`
-Start the LangServe instance, whether it's a hub package or a serve project.
+Starts a demo app for this template.
**Usage**:
```console
-$ langchain start [OPTIONS]
+$ langchain template serve [OPTIONS]
```
**Options**:
-* `--port INTEGER`
-* `--host TEXT`
+* `--port INTEGER`: The port to run the server on
+* `--host TEXT`: The host to run the server on
* `--help`: Show this message and exit.
diff --git a/libs/cli/langchain_cli/cli.py b/libs/cli/langchain_cli/cli.py
index e80e893403..119209c1d8 100644
--- a/libs/cli/langchain_cli/cli.py
+++ b/libs/cli/langchain_cli/cli.py
@@ -3,15 +3,18 @@ from typing import Optional
import typer
from typing_extensions import Annotated
-from langchain_cli.namespaces import hub, serve
+from langchain_cli.namespaces import app as app_namespace
+from langchain_cli.namespaces import template as template_namespace
app = typer.Typer(no_args_is_help=True, add_completion=False)
-app.add_typer(hub.hub, name="hub", help=hub.__doc__)
-app.add_typer(serve.serve, name="serve", help=serve.__doc__)
+app.add_typer(
+ template_namespace.package_cli, name="template", help=template_namespace.__doc__
+)
+app.add_typer(app_namespace.app_cli, name="app", help=app_namespace.__doc__)
@app.command()
-def start(
+def serve(
*,
port: Annotated[
Optional[int], typer.Option(help="The port to run the server on")
@@ -21,14 +24,14 @@ def start(
] = None,
) -> None:
"""
- Start the LangServe instance, whether it's a hub package or a serve project.
+ Start the LangServe app, whether it's a template or an app.
"""
- # try starting hub package, if error, try langserve
+ # try starting template package, if error, try langserve
try:
- hub.start(port=port, host=host)
+ template_namespace.serve(port=port, host=host)
except KeyError:
- serve.start(port=port, host=host)
+ app_namespace.serve(port=port, host=host)
if __name__ == "__main__":
diff --git a/libs/cli/langchain_cli/dev_scripts.py b/libs/cli/langchain_cli/dev_scripts.py
index 7eee1e2735..77612f6c20 100644
--- a/libs/cli/langchain_cli/dev_scripts.py
+++ b/libs/cli/langchain_cli/dev_scripts.py
@@ -1,5 +1,5 @@
"""
-Development Scripts for Hub Packages
+Development Scripts for template packages
"""
from fastapi import FastAPI
@@ -10,7 +10,7 @@ from langchain_cli.utils.packages import get_package_root
def create_demo_server():
"""
- Creates a demo server for the current hub package.
+ Creates a demo server for the current template.
"""
app = FastAPI()
package_root = get_package_root()
diff --git a/libs/cli/langchain_cli/namespaces/serve.py b/libs/cli/langchain_cli/namespaces/app.py
similarity index 65%
rename from libs/cli/langchain_cli/namespaces/serve.py
rename to libs/cli/langchain_cli/namespaces/app.py
index 22c5c030cb..26b33ed7b8 100644
--- a/libs/cli/langchain_cli/namespaces/serve.py
+++ b/libs/cli/langchain_cli/namespaces/app.py
@@ -1,5 +1,5 @@
"""
-Manage LangServe application projects.
+Manage LangChain apps
"""
import shutil
@@ -8,7 +8,7 @@ from pathlib import Path
from typing import Dict, List, Optional, Tuple
import typer
-from langserve.packages import get_langserve_export, list_packages
+from langserve.packages import get_langserve_export
from typing_extensions import Annotated
from langchain_cli.utils.events import create_events
@@ -22,10 +22,10 @@ from langchain_cli.utils.packages import get_package_root
REPO_DIR = Path(typer.get_app_dir("langchain")) / "git_repos"
-serve = typer.Typer(no_args_is_help=True, add_completion=False)
+app_cli = typer.Typer(no_args_is_help=True, add_completion=False)
+@app_cli.command()
def new(
name: Annotated[str, typer.Argument(help="The name of the folder to create")],
*,
@@ -33,10 +33,6 @@ def new(
Optional[List[str]],
typer.Option(help="Packages to seed the project with"),
] = None,
- with_poetry: Annotated[
- bool,
- typer.Option("--with-poetry/--no-poetry", help="Run poetry install"),
- ] = False,
):
"""
Create a new LangServe application.
@@ -44,31 +40,19 @@ def new(
# copy over template from ../project_template
project_template_dir = Path(__file__).parents[1] / "project_template"
destination_dir = Path.cwd() / name if name != "." else Path.cwd()
+ app_name = name if name != "." else Path.cwd().name
shutil.copytree(project_template_dir, destination_dir, dirs_exist_ok=name == ".")
- # poetry install
- if with_poetry:
- subprocess.run(["poetry", "install"], cwd=destination_dir)
+ readme = destination_dir / "README.md"
+ readme_contents = readme.read_text()
+ readme.write_text(readme_contents.replace("__app_name__", app_name))
# add packages if specified
if package is not None and len(package) > 0:
- add(package, project_dir=destination_dir, with_poetry=with_poetry)
+ add(package, project_dir=destination_dir)
-def install():
- package_root = get_package_root() / "packages"
- for package_path in list_packages(package_root):
- try:
- pyproject_path = package_path / "pyproject.toml"
- langserve_export = get_langserve_export(pyproject_path)
- typer.echo(f"Installing {langserve_export['package_name']}...")
- subprocess.run(["poetry", "add", "--editable", package_path])
- except Exception as e:
- typer.echo(f"Skipping installing {package_path} due to error: {e}")
-
-
+@app_cli.command()
def add(
dependencies: Annotated[
Optional[List[str]], typer.Argument(help="The dependency to add")
@@ -79,22 +63,19 @@ def add(
Optional[Path], typer.Option(help="The project directory")
] = None,
repo: Annotated[
- List[str], typer.Option(help="Install deps from a specific github repo instead")
+ List[str],
+ typer.Option(help="Install templates from a specific github repo instead"),
] = [],
branch: Annotated[
- List[str], typer.Option(help="Install deps from a specific branch")
+ List[str], typer.Option(help="Install templates from a specific branch")
] = [],
- with_poetry: Annotated[
- bool,
- typer.Option("--with-poetry/--no-poetry", help="Run poetry install"),
- ] = False,
):
"""
- Adds the specified package to the current LangServe instance.
+ Adds the specified template to the current LangServe app.
e.g.:
- langchain serve add extraction-openai-functions
- langchain serve add git+ssh://[email protected]/efriis/simple-pirate.git
+ langchain app add extraction-openai-functions
+ langchain app add git+ssh://[email protected]/efriis/simple-pirate.git
"""
parsed_deps = parse_dependencies(dependencies, repo, branch, api_path)
@@ -122,7 +103,7 @@ def add(
if len(group_deps) == 1:
typer.echo(f"Adding {git}@{ref}...")
else:
- typer.echo(f"Adding {len(group_deps)} dependencies from {git}@{ref}")
+ typer.echo(f"Adding {len(group_deps)} templates from {git}@{ref}")
source_repo_path = update_repo(git, ref, REPO_DIR)
for dep in group_deps:
@@ -159,20 +140,14 @@ def add(
installed_desination_strs = [
str(p.relative_to(cwd)) for p in installed_destination_paths
]
+ cmd = ["pip", "install", "-e"] + installed_desination_strs
+ cmd_str = " \\\n ".join(installed_desination_strs)
+ install_str = f"To install:\n\npip install -e \\\n {cmd_str}"
+ typer.echo(install_str)
+
+ if typer.confirm("Run it?"):
+ subprocess.run(cmd, cwd=cwd)
- if with_poetry:
- subprocess.run(
- ["poetry", "add", "--editable"] + installed_desination_strs,
- cwd=cwd,
- )
- else:
- cmd = ["pip", "install", "-e"] + installed_desination_strs
- cmd_str = " \\\n ".join(installed_desination_strs)
- install_str = f"To install:\n\npip install -e \\\n {cmd_str}"
- typer.echo(install_str)
-
- if typer.confirm("Run it?"):
- subprocess.run(cmd, cwd=cwd)
if typer.confirm("\nGenerate route code for these packages?", default=True):
chain_names = []
for e in installed_exports:
@@ -200,21 +175,20 @@ def add(
lines = (
["", "Great! Add the following to your app:\n\n```", ""]
- + imports + [""] + routes + ["```"]
+ + imports
+ + [""]
+ + routes
+ + ["```"]
)
typer.echo("\n".join(lines))
+@app_cli.command()
def remove(
api_paths: Annotated[List[str], typer.Argument(help="The API paths to remove")],
- with_poetry: Annotated[
- bool,
- typer.Option("--with_poetry/--no-poetry", help="Don't run poetry remove"),
- ] = False,
):
"""
- Removes the specified package from the current LangServe instance.
+ Removes the specified package from the current LangServe app.
"""
for api_path in api_paths:
package_dir = Path.cwd() / "packages" / api_path
@@ -224,28 +198,12 @@ def remove(
pyproject = package_dir / "pyproject.toml"
langserve_export = get_langserve_export(pyproject)
typer.echo(f"Removing {langserve_export['package_name']}...")
- if with_poetry:
- subprocess.run(["poetry", "remove", langserve_export["package_name"]])
- shutil.rmtree(package_dir)
-
-def list():
- """
- Lists all packages in the current LangServe instance.
- """
- package_root = get_package_root() / "packages"
- for package_path in list_packages(package_root):
- relative = package_path.relative_to(package_root)
- pyproject_path = package_path / "pyproject.toml"
- langserve_export = get_langserve_export(pyproject_path)
- typer.echo(
- f"{relative}: ({langserve_export['module']}.{langserve_export['attr']})"
- )
+ shutil.rmtree(package_dir)
-def start(
+@app_cli.command()
+def serve(
*,
port: Annotated[
Optional[int], typer.Option(help="The port to run the server on")
@@ -253,10 +211,12 @@ def start(
host: Annotated[
Optional[str], typer.Option(help="The host to run the server on")
] = None,
- app: Annotated[Optional[str], typer.Option(help="The app to run")] = None,
+ app: Annotated[
+ Optional[str], typer.Option(help="The app to run, e.g. `app.server:app`")
+ ] = None,
) -> None:
"""
- Starts the LangServe instance.
+ Starts the LangServe app.
"""
app_str = app if app is not None else "app.server:app"
diff --git a/libs/cli/langchain_cli/namespaces/hub.py b/libs/cli/langchain_cli/namespaces/template.py
similarity index 75%
rename from libs/cli/langchain_cli/namespaces/hub.py
rename to libs/cli/langchain_cli/namespaces/template.py
index 27a70c6656..bcd186c2b8 100644
--- a/libs/cli/langchain_cli/namespaces/hub.py
+++ b/libs/cli/langchain_cli/namespaces/template.py
@@ -1,5 +1,5 @@
"""
-Manage installable hub packages.
+Develop installable templates.
"""
import re
@@ -14,10 +14,10 @@ from typing_extensions import Annotated
from langchain_cli.utils.packages import get_package_root
-hub = typer.Typer(no_args_is_help=True, add_completion=False)
+package_cli = typer.Typer(no_args_is_help=True, add_completion=False)
+@package_cli.command()
def new(
name: Annotated[str, typer.Argument(help="The name of the folder to create")],
with_poetry: Annotated[
@@ -26,7 +26,7 @@ def new(
] = False,
):
"""
- Creates a new hub package.
+ Creates a new template package.
"""
computed_name = name if name != "." else Path.cwd().name
destination_dir = Path.cwd() / name if name != "." else Path.cwd()
@@ -36,33 +36,44 @@ def new(
shutil.copytree(project_template_dir, destination_dir, dirs_exist_ok=name == ".")
package_name_split = computed_name.split("/")
- package_name_last = (
+ package_name = (
package_name_split[-2]
if len(package_name_split) > 1 and package_name_split[-1] == ""
else package_name_split[-1]
)
- default_package_name = re.sub(
+ module_name = re.sub(
r"[^a-zA-Z0-9_]",
"_",
- package_name_last,
+ package_name,
+ )
+
+ # generate app route code
+ chain_name = f"{module_name}_chain"
+ app_route_code = (
+ f"from {module_name} import chain as {chain_name}\n\n"
+ f'add_routes(app, {chain_name}, path="/{package_name}")'
)
# replace template strings
pyproject = destination_dir / "pyproject.toml"
pyproject_contents = pyproject.read_text()
pyproject.write_text(
- pyproject_contents.replace("__package_name__", default_package_name)
+ pyproject_contents.replace("__package_name__", module_name).replace(
+ "__module_name__", module_name
+ )
)
# move module folder
- package_dir = destination_dir / default_package_name
+ package_dir = destination_dir / module_name
shutil.move(destination_dir / "package_template", package_dir)
# replace readme
readme = destination_dir / "README.md"
readme_contents = readme.read_text()
readme.write_text(
- readme_contents.replace("__package_name_last__", package_name_last)
+ readme_contents.replace("__package_name_last__", package_name).replace(
+ "__app_route_code__", app_route_code
+ )
)
# poetry install
@@ -70,8 +81,8 @@ def new(
subprocess.run(["poetry", "install"], cwd=destination_dir)
-def start(
+@package_cli.command()
+def serve(
*,
port: Annotated[
Optional[int], typer.Option(help="The port to run the server on")
@@ -81,7 +92,7 @@ def start(
] = None,
) -> None:
"""
- Starts a demo LangServe instance for this hub package.
+ Starts a demo app for this template.
"""
# load pyproject.toml
project_dir = get_package_root()
diff --git a/libs/cli/langchain_cli/package_template/README.md b/libs/cli/langchain_cli/package_template/README.md
index 29f06a9d0d..eec90dfacc 100644
--- a/libs/cli/langchain_cli/package_template/README.md
+++ b/libs/cli/langchain_cli/package_template/README.md
@@ -1 +1,64 @@
# __package_name_last__
+
+TODO: What does this package do
+
+## Environment Setup
+
+TODO: What environment variables need to be set (if any)
+
+## Usage
+
+To use this package, you should first have the LangChain CLI installed:
+
+```shell
+pip install -U "langchain-cli[serve]"
+```
+
+To create a new LangChain project and install this as the only package, you can do:
+
+```shell
+langchain app new my-app --package __package_name__
+```
+
+If you want to add this to an existing project, you can just run:
+
+```shell
+langchain app add __package_name__
+```
+
+And add the following code to your `server.py` file:
+```python
+__app_route_code__
+```
+
+(Optional) Let's now configure LangSmith.
+LangSmith will help us trace, monitor and debug LangChain applications.
+LangSmith is currently in private beta, you can sign up [here](https://smith.langchain.com/).
+If you don't have access, you can skip this section
+
+
+```shell
+export LANGCHAIN_TRACING_V2=true
+export LANGCHAIN_API_KEY=<your-api-key>
+export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
+```
+
+If you are inside this directory, then you can spin up a LangServe instance directly by:
+
+```shell
+langchain serve
+```
+
+This will start the FastAPI app with a server is running locally at
+[http://localhost:8000](http://localhost:8000)
+
+We can see all templates at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
+We can access the playground at [http://127.0.0.1:8000/__package_name__/playground](http://127.0.0.1:8000/__package_name__/playground)
+
+We can access the template from code with:
+
+```python
+from langserve.client import RemoteRunnable
+
+runnable = RemoteRunnable("http://localhost:8000/__package_name__")
+```
\ No newline at end of file
diff --git a/libs/cli/langchain_cli/package_template/package_template/__init__.py b/libs/cli/langchain_cli/package_template/package_template/__init__.py
index e69de29bb2..b941ff9ff1 100644
--- a/libs/cli/langchain_cli/package_template/package_template/__init__.py
+++ b/libs/cli/langchain_cli/package_template/package_template/__init__.py
@@ -0,0 +1,3 @@
+from chain import chain
+
+__all__ = ["chain"]
diff --git a/libs/cli/langchain_cli/package_template/pyproject.toml b/libs/cli/langchain_cli/package_template/pyproject.toml
index eaa5924cc5..937c4a16a2 100644
--- a/libs/cli/langchain_cli/package_template/pyproject.toml
+++ b/libs/cli/langchain_cli/package_template/pyproject.toml
@@ -16,7 +16,7 @@ fastapi = "^0.104.0"
sse-starlette = "^1.6.5"
[tool.langserve]
-export_module = "__package_name__.chain"
+export_module = "__module_name__"
export_attr = "chain"
[build-system]
diff --git a/libs/cli/langchain_cli/project_template/README.md b/libs/cli/langchain_cli/project_template/README.md
index 66d6308922..887af0f2b3 100644
--- a/libs/cli/langchain_cli/project_template/README.md
+++ b/libs/cli/langchain_cli/project_template/README.md
@@ -1,4 +1,4 @@
-# LangServeHub Project Template
+# __app_name__
## Installation
@@ -11,11 +11,39 @@ pip install -U "langchain-cli[serve]"
## Adding packages
```bash
-langchain serve add $PROJECT_NAME
+# adding packages from
+# https://github.com/langchain-ai/langchain/tree/master/templates
+langchain app add $PROJECT_NAME
+
+# adding custom GitHub repo packages
+langchain app add --repo $OWNER/$REPO
+# or with whole git string (supports other git providers):
+# langchain app add git+https://github.com/hwchase17/chain-of-verification
+
+# with a custom api mount point (defaults to `/{package_name}`)
+langchain app add $PROJECT_NAME --api_path=/my/custom/path/rag
```
-## Launch LangServe
+Note: you remove packages by their api path
+
+```bash
+langchain app remove my/custom/path/rag
+```
+
+## Setup LangSmith (Optional)
+LangSmith will help us trace, monitor and debug LangChain applications.
+LangSmith is currently in private beta, you can sign up [here](https://smith.langchain.com/).
+If you don't have access, you can skip this section
+
```shell
-python app/server.py
+export LANGCHAIN_TRACING_V2=true
+export LANGCHAIN_API_KEY=<your-api-key>
+export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
+```
+
+## Launch LangServe
+
+```bash
+langchain serve
```
diff --git a/libs/cli/langchain_cli/utils/git.py b/libs/cli/langchain_cli/utils/git.py
index ab4e016a1c..3c90fc8f08 100644
--- a/libs/cli/langchain_cli/utils/git.py
+++ b/libs/cli/langchain_cli/utils/git.py
@@ -132,7 +132,7 @@ def parse_dependencies(
):
raise ValueError(
"Number of defined repos/branches/api_paths did not match the "
- "number of dependencies."
+ "number of templates."
)
inner_deps = _list_arg_to_length(dependencies, num_deps)
inner_api_paths = _list_arg_to_length(api_path, num_deps)
diff --git a/templates/README.md b/templates/README.md
index f23d143c98..d3042ddebf 100644
--- a/templates/README.md
+++ b/templates/README.md
@@ -17,7 +17,7 @@ pip install -U "langchain-cli[serve]"
Next, create a new LangChain project:
```shell
-langchain serve new my-app
+langchain app new my-app
```
This will create a new directory called `my-app` with two folders:
@@ -36,7 +36,7 @@ In this getting started guide, we will add a simple `pirate-speak` project.
All this project does is convert user input into pirate speak.
```shell
-langchain serve add pirate-speak
+langchain app add pirate-speak
```
This will pull in the specified template into `packages/pirate-speak`
@@ -53,7 +53,7 @@ If we accept, we will see the following code generated:
```shell
from pirate_speak.chain import chain as pirate_speak_chain
-add_routes(app, pirate_speak_chain, path="/pirate_speak")
+add_routes(app, pirate_speak_chain, path="/pirate-speak")
```
You can now edit the template you pulled down.
@@ -72,7 +72,7 @@ from pirate_speak.chain import chain as pirate_speak_chain
app = FastAPI()
-add_routes(app, pirate_speak_chain, path="/pirate_speak")
+add_routes(app, pirate_speak_chain, path="/pirate-speak")
```
(Optional) Let's now configure LangSmith.
@@ -96,11 +96,11 @@ export OPENAI_API_KEY=sk-...
You can then spin up production-ready endpoints, along with a playground, by running:
```shell
-langchain start
+langchain serve
```
This now gives a fully deployed LangServe application.
-For example, you get a playground out-of-the-box at [http://127.0.0.1:8000/pirate_speak/playground/](http://127.0.0.1:8000/pirate_speak/playground/):
+For example, you get a playground out-of-the-box at [http://127.0.0.1:8000/pirate-speak/playground/](http://127.0.0.1:8000/pirate-speak/playground/):
![playground.png](docs/playground.png)
@@ -113,7 +113,7 @@ Use the LangServe python or js SDK to interact with the API as if it were a regu
```python
from langserve import RemoteRunnable
-api = RemoteRunnable("http://127.0.0.1:8000/pirate_speak")
+api = RemoteRunnable("http://127.0.0.1:8000/pirate-speak")
api.invoke({"text": "hi"})
```
diff --git a/templates/docs/CONTRIBUTING.md b/templates/docs/CONTRIBUTING.md
index c352e78062..b5a281885c 100644
--- a/templates/docs/CONTRIBUTING.md
+++ b/templates/docs/CONTRIBUTING.md
@@ -18,7 +18,7 @@ You can then run the following command to create a new skeleton of a package.
By convention, package names should use `-` delimeters (not `_`).
```shell
-langchain hub new $PROJECT_NAME
+langchain template new $PROJECT_NAME
```
You can then edit the contents of the package as you desire.
diff --git a/templates/docs/LAUNCHING_PACKAGE.md b/templates/docs/LAUNCHING_PACKAGE.md
index 3ddbd6ded7..8077f5d1e6 100644
--- a/templates/docs/LAUNCHING_PACKAGE.md
+++ b/templates/docs/LAUNCHING_PACKAGE.md
@@ -32,7 +32,7 @@ pip install -U "langchain-cli[serve]"
You can then run:
```shell
-langchain hub start
+langchain template serve
```
This will spin up endpoints, documentation, and playground for this chain.
diff --git a/templates/extraction-anthropic-functions/extraction_anthropic_functions.ipynb b/templates/extraction-anthropic-functions/extraction_anthropic_functions.ipynb
index 23f300ec6c..3df1e56909 100644
--- a/templates/extraction-anthropic-functions/extraction_anthropic_functions.ipynb
+++ b/templates/extraction-anthropic-functions/extraction_anthropic_functions.ipynb
@@ -32,8 +32,8 @@
"\n",
"As shown in the README, add template and start server:\n",
"```\n",
- "langchain serve add extraction-anthropic-functions\n",
- "langchain start\n",
+ "langchain app add extraction-anthropic-functions\n",
+ "langchain serve\n",
"```\n",
"\n",
"We can now look at the endpoints:\n",
diff --git a/templates/rag-chroma/rag_chroma.ipynb b/templates/rag-chroma/rag_chroma.ipynb
index a9c458b5ba..a83e7a2df8 100644
--- a/templates/rag-chroma/rag_chroma.ipynb
+++ b/templates/rag-chroma/rag_chroma.ipynb
@@ -9,8 +9,8 @@
"\n",
"As shown in the README, add template and start server:\n",
"```\n",
- "langchain serve add rag-chroma\n",
- "langchain start\n",
+ "langchain app add rag-chroma\n",
+ "langchain serve\n",
"```\n",
"\n",
"We can now look at the endpoints:\n",
diff --git a/templates/rag-redis/README.md b/templates/rag-redis/README.md
index bf149b32ca..91e5cebe9a 100644
--- a/templates/rag-redis/README.md
+++ b/templates/rag-redis/README.md
@@ -62,16 +62,16 @@ We use a variety of environment variables to configure this application
## Installation
To create a langserve application using this template, run the following:
```bash
-langchain serve new my-langserve-app
+langchain app new my-langserve-app
cd my-langserve-app
```
Add this template:
```bash
-langchain serve add rag-redis
+langchain app add rag-redis
```
Start the server:
```bash
-langchain start
+langchain serve
```
\ No newline at end of file
diff --git a/templates/rag-semi-structured/README.md b/templates/rag-semi-structured/README.md
index 9aa3acd5f4..f24ed65ac3 100644
--- a/templates/rag-semi-structured/README.md
+++ b/templates/rag-semi-structured/README.md
@@ -30,18 +30,18 @@ Be sure that `OPENAI_API_KEY` is set in order to the OpenAI models.
Create your LangServe app:
```
-langchain serve new my-app
+langchain app new my-app
cd my-app
```
Add template:
```
-langchain serve add rag-semi-structured
+langchain app add rag-semi-structured
```
Start server:
```
-langchain start
+langchain serve
```
See Jupyter notebook `rag_semi_structured` for various way to connect to the template.
\ No newline at end of file
diff --git a/templates/rag-semi-structured/rag_semi_structured.ipynb b/templates/rag-semi-structured/rag_semi_structured.ipynb
index 9760547616..6f8f96f333 100644
--- a/templates/rag-semi-structured/rag_semi_structured.ipynb
+++ b/templates/rag-semi-structured/rag_semi_structured.ipynb
@@ -9,8 +9,8 @@
"\n",
"As shown in the README, add template and start server:\n",
"```\n",
- "langchain serve add rag-semi-structured\n",
- "langchain start\n",
+ "langchain app add rag-semi-structured\n",
+ "langchain serve\n",
"```\n",
"\n",
"We can now look at the endpoints:\n",
diff --git a/templates/summarize-anthropic/summarize_anthropic.ipynb b/templates/summarize-anthropic/summarize_anthropic.ipynb
index 95d7c20bdc..f168c7fb26 100644
--- a/templates/summarize-anthropic/summarize_anthropic.ipynb
+++ b/templates/summarize-anthropic/summarize_anthropic.ipynb
@@ -101,7 +101,7 @@
"* This will create a new Poetry environment /\n",
"```\n",
"pip install < to add > \n",
- "langchain serve new my-app\n",
+ "langchain app new my-app\n",
"cd my-app\n",
"```\n",
"\n",
@@ -110,13 +110,13 @@
"* When we add a template, we update the Poetry config file with the necessary dependencies.\n",
"* It also automatically installed these template dependencies in your Poetry environment\n",
"```\n",
- "langchain serve add summarize-anthropic\n",
+ "langchain app add summarize-anthropic\n",
"```\n",
"\n",
"`Start FastAPI server`\n",
"\n",
"```\n",
- "langchain start\n",
+ "langchain serve\n",
"```\n",
"\n",
"Note, we can now look at the endpoints:\n",