mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
* refactor: expose core private symbols with compatibility aliases Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * types: narrow core migration diagnostics Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: preserve runtime behavior in core symbol migration Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: preserve core private usage migration behavior Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: preserve private value rebinding compatibility Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: restore optional imports and cover public helpers Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test: exempt router property from call coverage Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test: align recursive detector ignore names Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: mateo <mateo@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
36 lines
1,004 B
Python
36 lines
1,004 B
Python
from typing import Optional, Union
|
|
|
|
from litellm.secret_managers.main import str_to_bool
|
|
|
|
|
|
def should_block_robots():
|
|
"""
|
|
Returns True if the robots.txt file should block web crawlers
|
|
|
|
Controlled by
|
|
|
|
```yaml
|
|
general_settings:
|
|
block_robots: true
|
|
```
|
|
"""
|
|
from litellm.proxy.proxy_server import (
|
|
CommonProxyErrors,
|
|
general_settings,
|
|
premium_user,
|
|
)
|
|
|
|
_block_robots: Union[bool, str] = general_settings.get("block_robots", False)
|
|
block_robots: Optional[bool] = None
|
|
if isinstance(_block_robots, bool):
|
|
block_robots = _block_robots
|
|
elif isinstance(_block_robots, str):
|
|
block_robots = str_to_bool(_block_robots)
|
|
if block_robots is True:
|
|
if premium_user is not True:
|
|
raise ValueError(
|
|
f"Blocking web crawlers is an enterprise feature. {CommonProxyErrors.not_premium_user.value}"
|
|
)
|
|
return True
|
|
return False
|
|
_should_block_robots = should_block_robots
|