mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-02 03:26:17 +00:00
add a template for the package readme (#12499)
Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
@@ -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__":
|
||||
|
Reference in New Issue
Block a user