mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-01 19:12:42 +00:00
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:
@@ -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
|
||||
)
|
||||
|
@@ -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,
|
||||
)
|
||||
|
Reference in New Issue
Block a user