Ykeremy/fix router pass empty redis password (#143)

This commit is contained in:
Kerem Yilmaz 2024-04-01 16:28:46 -07:00 committed by GitHub
parent f175545399
commit 3cc07c9d20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 2 deletions

31
poetry.lock generated
View file

@ -402,6 +402,17 @@ files = [
{file = "async_lru-2.0.4-py3-none-any.whl", hash = "sha256:ff02944ce3c288c5be660c42dbcca0742b32c3b279d6dceda655190240b99224"},
]
[[package]]
name = "async-timeout"
version = "4.0.3"
description = "Timeout context manager for asyncio programs"
optional = false
python-versions = ">=3.7"
files = [
{file = "async-timeout-4.0.3.tar.gz", hash = "sha256:4640d96be84d82d02ed59ea2b7105a0f7b33abe8703703cd0ab0bf87c427522f"},
{file = "async_timeout-4.0.3-py3-none-any.whl", hash = "sha256:7405140ff1230c310e51dc27b3145b9092d659ce68ff733fb0cefe3ee42be028"},
]
[[package]]
name = "asyncache"
version = "0.3.1"
@ -5085,6 +5096,24 @@ files = [
[package.dependencies]
cffi = {version = "*", markers = "implementation_name == \"pypy\""}
[[package]]
name = "redis"
version = "5.0.3"
description = "Python client for Redis database and key-value store"
optional = false
python-versions = ">=3.7"
files = [
{file = "redis-5.0.3-py3-none-any.whl", hash = "sha256:5da9b8fe9e1254293756c16c008e8620b3d15fcc6dde6babde9541850e72a32d"},
{file = "redis-5.0.3.tar.gz", hash = "sha256:4973bae7444c0fbed64a06b87446f79361cb7e4ec1538c022d696ed7a5015580"},
]
[package.dependencies]
async-timeout = {version = ">=4.0.3", markers = "python_full_version < \"3.11.3\""}
[package.extras]
hiredis = ["hiredis (>=1.0.0)"]
ocsp = ["cryptography (>=36.0.1)", "pyopenssl (==20.0.1)", "requests (>=2.26.0)"]
[[package]]
name = "referencing"
version = "0.33.0"
@ -6881,4 +6910,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p
[metadata]
lock-version = "2.0"
python-versions = "^3.11,<3.12"
content-hash = "5f870005a2514272e756ca1c02e22ed94077fe1999ac6f838f94fd0f44f81965"
content-hash = "369e5937d9afe626740a29fe87a01f4fd83d9f137e480d41db56976087377431"

View file

@ -49,6 +49,7 @@ types-toml = "^0.10.8.7"
apscheduler = "^3.10.4"
httpx = "^0.27.0"
filetype = "^1.2.0"
redis = "^5.0.3"
[tool.poetry.group.dev.dependencies]

View file

@ -35,6 +35,7 @@ class LLMAPIHandlerFactory:
model_list=[dataclasses.asdict(model) for model in llm_config.model_list],
redis_host=llm_config.redis_host,
redis_port=llm_config.redis_port,
redis_password=llm_config.redis_password,
routing_strategy=llm_config.routing_strategy,
fallbacks=[{llm_config.main_model_group: llm_config.fallback_model_group}]
if llm_config.fallback_model_group

View file

@ -33,8 +33,10 @@ class LLMRouterModelConfig:
@dataclass(frozen=True)
class LLMRouterConfig(LLMConfig):
model_list: list[LLMRouterModelConfig]
# All three redis parameters are required. Even if there isn't a password, it should be an empty string.
redis_host: str
redis_port: int
redis_password: str
main_model_group: str
fallback_model_group: str | None = None
routing_strategy: Literal[
@ -45,7 +47,7 @@ class LLMRouterConfig(LLMConfig):
] = "usage-based-routing"
num_retries: int = 2
retry_delay_seconds: int = 15
set_verbose: bool = True
set_verbose: bool = False
class LLMAPIHandler(Protocol):