diff --git a/langserve/server.py b/langserve/server.py index d147f010..5bd03e52 100644 --- a/langserve/server.py +++ b/langserve/server.py @@ -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""" __ ___ .__ __. _______ _______. _______ .______ ____ ____ _______ | | / \ | \ | | / _____| / || ____|| _ \ \ \ / / | ____| | | / ^ \ | \| | | | __ | (----`| |__ | |_) | \ \/ / | |__ @@ -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: @@ -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()