Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Splash Screen with warning about openapi docs #221

Merged
merged 3 commits into from
Nov 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions langserve/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def _scrub_exceptions_in_event(event: CallbackEventDict) -> CallbackEventDict:
def _setup_global_app_handlers(app: Union[FastAPI, APIRouter]) -> None:
@app.on_event("startup")
async def startup_event():
LANGSERVE = """
LANGSERVE = r"""
__ ___ .__ __. _______ _______. _______ .______ ____ ____ _______
| | / \ | \ | | / _____| / || ____|| _ \ \ \ / / | ____|
| | / ^ \ | \| | | | __ | (----`| |__ | |_) | \ \/ / | |__
Expand All @@ -284,9 +284,14 @@ async def startup_event():
|_______/__/ \__\ |__| \__| \______| |_______/ |_______|| _| `._____| \__/ |_______|
""" # noqa: E501

def green(text):
def green(text: str) -> str:
"""Return the given text in green."""
return "\x1b[1;32;40m" + text + "\x1b[0m"

def orange(text: str) -> str:
"""Return the given text in orange."""
return "\x1b[1;31;40m" + text + "\x1b[0m"

paths = _APP_TO_PATHS[app]
print(LANGSERVE)
for path in paths:
Expand All @@ -298,6 +303,15 @@ def green(text):
print(f'{green("LANGSERVE:")} └──> {path}/playground/')
print(f'{green("LANGSERVE:")}')
print(f'{green("LANGSERVE:")} See all available routes at {app.docs_url}/')

if _PYDANTIC_MAJOR_VERSION == 2:
print()
print(f'{orange("OpenAPI Docs:")}: ', end="")
print(
"Running with pydantic >= 2: OpenAPI docs for "
"invoke/batch/stream/stream_log` endpoints will not be "
"generated; but, API endpoints and playground will not be affected."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generated, but API ...

)
print()


Expand Down