From a7fe34274bb4a800d7f8d11975f1b7175e237157 Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Mon, 30 Oct 2023 21:59:15 -0700 Subject: [PATCH 1/4] Adds version CLI command --- libs/cli/DOCS.md | 1 + libs/cli/langchain_cli/cli.py | 23 +++++++++++++++++++++++ libs/cli/pyproject.toml | 1 + 3 files changed, 25 insertions(+) diff --git a/libs/cli/DOCS.md b/libs/cli/DOCS.md index 47f4d6647f76b..d08ba956aa5e2 100644 --- a/libs/cli/DOCS.md +++ b/libs/cli/DOCS.md @@ -9,6 +9,7 @@ $ langchain [OPTIONS] COMMAND [ARGS]... **Options**: * `--help`: Show this message and exit. +* `-v, --version`: Print current CLI version. **Commands**: diff --git a/libs/cli/langchain_cli/cli.py b/libs/cli/langchain_cli/cli.py index 119209c1d88fb..d2d80ce67ff65 100644 --- a/libs/cli/langchain_cli/cli.py +++ b/libs/cli/langchain_cli/cli.py @@ -6,6 +6,8 @@ from langchain_cli.namespaces import app as app_namespace from langchain_cli.namespaces import template as template_namespace +__version__ = "0.0.9" + app = typer.Typer(no_args_is_help=True, add_completion=False) app.add_typer( template_namespace.package_cli, name="template", help=template_namespace.__doc__ @@ -13,6 +15,27 @@ app.add_typer(app_namespace.app_cli, name="app", help=app_namespace.__doc__) +def version_callback(show_version: bool) -> None: + if show_version: + typer.echo(f"LangChain {__version__}") + raise typer.Exit() + + +@app.callback() +def main( + version: bool = typer.Option( + False, + "--version", + "-v", + help="Print the current CLI version.", + callback=version_callback, + is_eager=True, + ), +): + pass + +main() + @app.command() def serve( *, diff --git a/libs/cli/pyproject.toml b/libs/cli/pyproject.toml index a15a59a873792..7178d2436f27b 100644 --- a/libs/cli/pyproject.toml +++ b/libs/cli/pyproject.toml @@ -47,6 +47,7 @@ watch = "poetry run ptw" lint = "poetry run ruff ." format = "poetry run ruff . --fix" +[tool.poetry_bumpversion.file."langchain_cli/cli.py"] [build-system] requires = ["poetry-core"] From 4552a18b40515b17338552241ebbb7b84feb23a6 Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Mon, 30 Oct 2023 22:02:01 -0700 Subject: [PATCH 2/4] Update README --- libs/cli/README.md | 4 ++++ libs/cli/langchain_cli/cli.py | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/cli/README.md b/libs/cli/README.md index b8b1705d7138f..532eefc95986f 100644 --- a/libs/cli/README.md +++ b/libs/cli/README.md @@ -3,3 +3,7 @@ [Docs](./DOCS.md) [LangServe Templates Quickstart](../../templates/README.md) + +## Contributing + +Update CLI versions with `poetry version patch` to ensure that version commands display correctly. diff --git a/libs/cli/langchain_cli/cli.py b/libs/cli/langchain_cli/cli.py index d2d80ce67ff65..70ae14cf3f17f 100644 --- a/libs/cli/langchain_cli/cli.py +++ b/libs/cli/langchain_cli/cli.py @@ -34,7 +34,6 @@ def main( ): pass -main() @app.command() def serve( From e2ff9f99901d87bdaffbc2b3ebd42086e283a4b9 Mon Sep 17 00:00:00 2001 From: Erick Friis Date: Tue, 31 Oct 2023 13:36:02 -0700 Subject: [PATCH 3/4] specify cli --- libs/cli/langchain_cli/cli.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/cli/langchain_cli/cli.py b/libs/cli/langchain_cli/cli.py index 29aeab25611cb..9751a503851af 100644 --- a/libs/cli/langchain_cli/cli.py +++ b/libs/cli/langchain_cli/cli.py @@ -17,7 +17,7 @@ def version_callback(show_version: bool) -> None: if show_version: - typer.echo(f"LangChain {__version__}") + typer.echo(f"langchain-cli {__version__}") raise typer.Exit() From b9ce9a6e17169d1b3b01a3fecde92bfbefc72b1f Mon Sep 17 00:00:00 2001 From: Erick Friis Date: Tue, 31 Oct 2023 13:41:04 -0700 Subject: [PATCH 4/4] poetry lock --- libs/cli/poetry.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/cli/poetry.lock b/libs/cli/poetry.lock index 111ea806151c5..b57a93982e4e9 100644 --- a/libs/cli/poetry.lock +++ b/libs/cli/poetry.lock @@ -1535,4 +1535,4 @@ serve = ["langserve"] [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<4.0" -content-hash = "a517a85a6637b587a86067501f3c723d2f2a4c814a40bbf1761bd64baf8d276a" +content-hash = "80e530d72b799e5d066f3f6e5f472e5b70a288aed9f3bf4ee6293e3bf5a9e987"