-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
158 lines (152 loc) · 6.59 KB
/
Copy pathconfig.py
File metadata and controls
158 lines (152 loc) · 6.59 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import os
from dataclasses import dataclass
@dataclass(frozen=True)
class Settings:
app_env: str
repository_backend: str
database_url: str
redis_url: str
deepseek_api_key: str
deepseek_base_url: str
deepseek_model: str
deepseek_input_token_price_per_1k: float
deepseek_output_token_price_per_1k: float
deepseek_timeout_seconds: int
deepseek_max_concurrency: int
deepseek_circuit_breaker_failure_threshold: int
deepseek_circuit_breaker_recovery_seconds: int
workflow_storage_dir: str
postgres_pool_size: int
postgres_max_overflow: int
postgres_max_connections: int
postgres_pool_recycle_seconds: int
redis_socket_timeout_seconds: int
redis_health_check_interval_seconds: int
max_run_retries: int
max_agent_retries: int
retry_base_delay_seconds: int
retry_max_delay_seconds: int
worker_heartbeat_interval_seconds: int
worker_heartbeat_stale_seconds: int
worker_concurrency: int
worker_tenant_inflight_limit: int
api_process_model: str
api_bind: str
api_workers: int
api_timeout_seconds: int
api_graceful_timeout_seconds: int
api_keep_alive_seconds: int
api_max_request_body_bytes: int
api_rate_limit_per_minute: int
tenant_run_quota_per_day: int
tenant_monthly_run_quota: int
tenant_monthly_token_quota: int
tenant_monthly_cost_quota_usd: float
data_retention_run_days: int
data_retention_audit_event_days: int
data_retention_usage_ledger_days: int
tenant_deletion_grace_days: int
api_key: str
api_key_auth_backend: str
api_key_tenant_map: str
metrics_api_key: str
platform_operator_api_key: str
platform_operator_allowed_cidrs: str
trusted_proxy_cidrs: str
grafana_admin_user: str
grafana_admin_password: str
cors_allowed_origins: str
trusted_hosts: str
def get_settings() -> Settings:
return Settings(
app_env=os.getenv("APP_ENV", "local"),
repository_backend=os.getenv("REPOSITORY_BACKEND", "json"),
database_url=os.getenv(
"DATABASE_URL",
"postgresql://agent:agent_password@localhost:5432/agent",
),
redis_url=os.getenv("REDIS_URL", "redis://localhost:6379/0"),
deepseek_api_key=os.getenv("DEEPSEEK_API_KEY", ""),
deepseek_base_url=os.getenv("DEEPSEEK_BASE_URL", "https://api.deepseek.com"),
deepseek_model=os.getenv("DEEPSEEK_MODEL", "deepseek-chat"),
deepseek_input_token_price_per_1k=float(
os.getenv("DEEPSEEK_INPUT_TOKEN_PRICE_PER_1K", "0")
),
deepseek_output_token_price_per_1k=float(
os.getenv("DEEPSEEK_OUTPUT_TOKEN_PRICE_PER_1K", "0")
),
deepseek_timeout_seconds=int(os.getenv("DEEPSEEK_TIMEOUT_SECONDS", "60")),
deepseek_max_concurrency=int(os.getenv("DEEPSEEK_MAX_CONCURRENCY", "4")),
deepseek_circuit_breaker_failure_threshold=int(
os.getenv("DEEPSEEK_CIRCUIT_BREAKER_FAILURE_THRESHOLD", "5")
),
deepseek_circuit_breaker_recovery_seconds=int(
os.getenv("DEEPSEEK_CIRCUIT_BREAKER_RECOVERY_SECONDS", "60")
),
workflow_storage_dir=os.getenv("WORKFLOW_STORAGE_DIR", "data/runs"),
postgres_pool_size=int(os.getenv("POSTGRES_POOL_SIZE", "5")),
postgres_max_overflow=int(os.getenv("POSTGRES_MAX_OVERFLOW", "10")),
postgres_max_connections=int(os.getenv("POSTGRES_MAX_CONNECTIONS", "0")),
postgres_pool_recycle_seconds=int(
os.getenv("POSTGRES_POOL_RECYCLE_SECONDS", "1800")
),
redis_socket_timeout_seconds=int(os.getenv("REDIS_SOCKET_TIMEOUT_SECONDS", "5")),
redis_health_check_interval_seconds=int(
os.getenv("REDIS_HEALTH_CHECK_INTERVAL_SECONDS", "30")
),
max_run_retries=int(os.getenv("MAX_RUN_RETRIES", "3")),
max_agent_retries=int(os.getenv("MAX_AGENT_RETRIES", "2")),
retry_base_delay_seconds=int(os.getenv("RETRY_BASE_DELAY_SECONDS", "5")),
retry_max_delay_seconds=int(os.getenv("RETRY_MAX_DELAY_SECONDS", "60")),
worker_heartbeat_interval_seconds=int(
os.getenv("WORKER_HEARTBEAT_INTERVAL_SECONDS", "30")
),
worker_heartbeat_stale_seconds=int(
os.getenv("WORKER_HEARTBEAT_STALE_SECONDS", "300")
),
worker_concurrency=int(os.getenv("WORKER_CONCURRENCY", "1")),
worker_tenant_inflight_limit=int(
os.getenv("WORKER_TENANT_INFLIGHT_LIMIT", "0")
),
api_process_model=os.getenv("API_PROCESS_MODEL", "uvicorn"),
api_bind=os.getenv("API_BIND", "0.0.0.0:8000"),
api_workers=int(os.getenv("API_WORKERS", "1")),
api_timeout_seconds=int(os.getenv("API_TIMEOUT_SECONDS", "120")),
api_graceful_timeout_seconds=int(
os.getenv("API_GRACEFUL_TIMEOUT_SECONDS", "30")
),
api_keep_alive_seconds=int(os.getenv("API_KEEP_ALIVE_SECONDS", "5")),
api_max_request_body_bytes=int(
os.getenv("API_MAX_REQUEST_BODY_BYTES", "1048576")
),
api_rate_limit_per_minute=int(os.getenv("API_RATE_LIMIT_PER_MINUTE", "0")),
tenant_run_quota_per_day=int(os.getenv("TENANT_RUN_QUOTA_PER_DAY", "0")),
tenant_monthly_run_quota=int(os.getenv("TENANT_MONTHLY_RUN_QUOTA", "0")),
tenant_monthly_token_quota=int(os.getenv("TENANT_MONTHLY_TOKEN_QUOTA", "0")),
tenant_monthly_cost_quota_usd=float(
os.getenv("TENANT_MONTHLY_COST_QUOTA_USD", "0")
),
data_retention_run_days=int(os.getenv("DATA_RETENTION_RUN_DAYS", "90")),
data_retention_audit_event_days=int(
os.getenv("DATA_RETENTION_AUDIT_EVENT_DAYS", "365")
),
data_retention_usage_ledger_days=int(
os.getenv("DATA_RETENTION_USAGE_LEDGER_DAYS", "730")
),
tenant_deletion_grace_days=int(os.getenv("TENANT_DELETION_GRACE_DAYS", "30")),
api_key=os.getenv("API_KEY", ""),
api_key_auth_backend=os.getenv("API_KEY_AUTH_BACKEND", "env"),
api_key_tenant_map=os.getenv("API_KEY_TENANT_MAP", ""),
metrics_api_key=os.getenv("METRICS_API_KEY", ""),
platform_operator_api_key=os.getenv("PLATFORM_OPERATOR_API_KEY", ""),
platform_operator_allowed_cidrs=os.getenv(
"PLATFORM_OPERATOR_ALLOWED_CIDRS",
"",
),
trusted_proxy_cidrs=os.getenv("TRUSTED_PROXY_CIDRS", ""),
grafana_admin_user=os.getenv("GRAFANA_ADMIN_USER", "admin"),
grafana_admin_password=os.getenv("GRAFANA_ADMIN_PASSWORD", "admin"),
cors_allowed_origins=os.getenv("CORS_ALLOWED_ORIGINS", ""),
trusted_hosts=os.getenv("TRUSTED_HOSTS", ""),
)
settings = get_settings()