CLI 0.0.14, Uvicorn update and no more [serve] (#12845)

Calls uvicorn directly from cli:
Reload works if you define app by import string instead of object.
(was doing subprocess in order to get reloading)

Version bump to 0.0.14

Remove the need for [serve] for simplicity.

Readmes are updated in #12847 to avoid cluttering this PR
This commit is contained in:
Erick Friis
2023-11-03 11:05:52 -07:00
committed by GitHub
parent 76bcac5bb3
commit 1bc35f61cb
5 changed files with 56 additions and 57 deletions

View File

@@ -220,8 +220,10 @@ def serve(
"""
app_str = app if app is not None else "app.server:app"
port_str = str(port) if port is not None else "8000"
host_str = host if host is not None else "127.0.0.1"
cmd = ["uvicorn", app_str, "--reload", "--port", port_str, "--host", host_str]
subprocess.run(cmd)
import uvicorn
uvicorn.run(
app_str, host=host_str, port=port if port is not None else 8000, reload=True
)

View File

@@ -113,7 +113,6 @@ def serve(
# get langserve export - throws KeyError if invalid
get_langserve_export(pyproject)
port_str = str(port) if port is not None else "8000"
host_str = host if host is not None else "127.0.0.1"
script = (
@@ -122,14 +121,12 @@ def serve(
else "langchain_cli.dev_scripts:create_demo_server_configurable"
)
command = [
"uvicorn",
"--factory",
import uvicorn
uvicorn.run(
script,
"--reload",
"--port",
port_str,
"--host",
host_str,
]
subprocess.run(command)
factory=True,
reload=True,
port=port if port is not None else 8000,
host=host_str,
)