add a template for the package readme (#12499)

Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
Harrison Chase
2023-10-30 16:39:39 -07:00
committed by GitHub
parent 9bedda50f2
commit 8b5e879171
19 changed files with 288 additions and 245 deletions

View File

@@ -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__":