forked from LAION-AI/Open-Assistant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
116 lines (82 loc) · 3.04 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
from typing import Any
import pydantic
def split_keys_string(keys: str | None):
if not keys:
return []
return list(filter(bool, keys.split(",")))
class Settings(pydantic.BaseSettings):
redis_host: str = "localhost"
redis_port: int = 6379
redis_db: int = 0
message_queue_expire: int = 60
work_queue_max_size: int | None = None
allowed_worker_compat_hashes: str = "*"
@property
def allowed_worker_compat_hashes_list(self) -> list[str]:
return self.allowed_worker_compat_hashes.split(",")
allowed_model_config_names: str = "*"
@property
def allowed_model_config_names_list(self) -> list[str]:
return self.allowed_model_config_names.split(",")
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+asyncpg",
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 ''}",
)
db_pool_size: int = 75
db_max_overflow: int = 20
db_echo: bool = False
root_token: str = "1234"
debug_api_keys: str = ""
@property
def debug_api_keys_list(self) -> list[str]:
return split_keys_string(self.debug_api_keys)
trusted_client_keys: str | None
@property
def trusted_api_keys_list(self) -> list[str]:
return split_keys_string(self.trusted_client_keys)
do_compliance_checks: bool = False
compliance_check_interval: int = 60
compliance_check_timeout: int = 60
# url of this server
api_root: str = "http://localhost:8000"
allow_debug_auth: bool = False
session_middleware_secret_key: str = ""
auth_info: bytes = b"NextAuth.js Generated Encryption Key"
auth_salt: bytes = b""
auth_length: int = 32
auth_secret: bytes = b""
auth_algorithm: str = "HS256"
auth_access_token_expire_minutes: int = 60
auth_refresh_token_expire_minutes: int = 60 * 24 * 7
auth_discord_client_id: str = ""
auth_discord_client_secret: str = ""
auth_github_client_id: str = ""
auth_github_client_secret: str = ""
auth_google_client_id: str = ""
auth_google_client_secret: str = ""
pending_event_interval: int = 1
worker_ping_interval: int = 3
assistant_message_timeout: int = 60
inference_cors_origins: str = "*"
@property
def inference_cors_origins_list(self) -> list[str]:
return self.inference_cors_origins.split(",")
settings = Settings()