mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
(Proxy) add support for DOCS_URL and REDOC_URL (#6806)
* add support for DOCS_URL and REDOC_URL * document env vars * add unit tests for docs url and redocs url
This commit is contained in:
parent
7550aba474
commit
1890fde3f3
4 changed files with 79 additions and 3 deletions
|
@ -3099,6 +3099,34 @@ def get_error_message_str(e: Exception) -> str:
|
|||
return error_message
|
||||
|
||||
|
||||
def _get_redoc_url() -> str:
|
||||
"""
|
||||
Get the redoc URL from the environment variables.
|
||||
|
||||
- If REDOC_URL is set, return it.
|
||||
- Otherwise, default to "/redoc".
|
||||
"""
|
||||
return os.getenv("REDOC_URL", "/redoc")
|
||||
|
||||
|
||||
def _get_docs_url() -> Optional[str]:
|
||||
"""
|
||||
Get the docs URL from the environment variables.
|
||||
|
||||
- If DOCS_URL is set, return it.
|
||||
- If NO_DOCS is True, return None.
|
||||
- Otherwise, default to "/".
|
||||
"""
|
||||
docs_url = os.getenv("DOCS_URL", None)
|
||||
if docs_url:
|
||||
return docs_url
|
||||
|
||||
if os.getenv("NO_DOCS", "False") == "True":
|
||||
return None
|
||||
|
||||
# default to "/"
|
||||
return "/"
|
||||
|
||||
def handle_exception_on_proxy(e: Exception) -> ProxyException:
|
||||
"""
|
||||
Returns an Exception as ProxyException, this ensures all exceptions are OpenAI API compatible
|
||||
|
@ -3120,3 +3148,4 @@ def handle_exception_on_proxy(e: Exception) -> ProxyException:
|
|||
param=getattr(e, "param", "None"),
|
||||
code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue