Skip to content

Commit

Permalink
Update Splash Screen with warning about openapi docs (#221)
Browse files Browse the repository at this point in the history
Update the splash screen to output a warning about OpenAPI docs missing
when using pydantic v2.
  • Loading branch information
eyurtsev authored Nov 13, 2023
1 parent 38b9356 commit 2f4bcdd
Showing 1 changed file with 16 additions and 2 deletions.
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."
)
print()


Expand Down

0 comments on commit 2f4bcdd

Please sign in to comment.