Files
Open-Assistant/inference/server/oasst_inference_server/settings.py
T
Yannic Kilcher 90c3d5640e Added database to inference server (#1446)
* added db for inference

* fixed dockerfiles for inference
2023-02-10 22:51:35 +01:00

39 lines
1.0 KiB
Python

from typing import Any
import pydantic
class Settings(pydantic.BaseSettings):
redis_host: str = "localhost"
redis_port: int = 6379
redis_db: int = 0
sse_retry_timeout: int = 15000
update_alembic: bool = True
alembic_retries: int = 5
alembic_retry_timeout: int = 1
postgres_host: str = "localhost"
postgres_port: str = "5432"
postgres_user: str = "postgres"
postgres_password: str = "postgres"
postgres_db: str = "postgres"
database_uri: str | None = None
@pydantic.validator("database_uri", pre=True)
def assemble_db_connection(cls, v: str | None, values: dict[str, Any]) -> Any:
if isinstance(v, str):
return v
return pydantic.PostgresDsn.build(
scheme="postgresql",
user=values.get("postgres_user"),
password=values.get("postgres_password"),
host=values.get("postgres_host"),
port=values.get("postgres_port"),
path=f"/{values.get('postgres_db') or ''}",
)
settings = Settings()