mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-03 03:59:42 +00:00
36
libs/cli/langchain_cli/cli.py
Normal file
36
libs/cli/langchain_cli/cli.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import typer
|
||||
import subprocess
|
||||
from typing import Optional
|
||||
from typing_extensions import Annotated
|
||||
|
||||
from langchain_cli.namespaces import hub
|
||||
from langchain_cli.namespaces import serve
|
||||
|
||||
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.command()
|
||||
def start(
|
||||
*,
|
||||
port: Annotated[
|
||||
Optional[int], typer.Option(help="The port to run the server on")
|
||||
] = None,
|
||||
host: Annotated[
|
||||
Optional[str], typer.Option(help="The host to run the server on")
|
||||
] = None,
|
||||
) -> None:
|
||||
"""
|
||||
Start the LangServe instance, whether it's a hub package or a serve project.
|
||||
"""
|
||||
cmd = ["poetry", "run", "poe", "start"]
|
||||
if port is not None:
|
||||
cmd += ["--port", str(port)]
|
||||
if host is not None:
|
||||
cmd += ["--host", host]
|
||||
subprocess.run(cmd)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app()
|
Reference in New Issue
Block a user