@@ -59,6 +59,10 @@ class Config:
59
59
server_key : str = "server.key"
60
60
force_certs : bool = False
61
61
62
+ # Update configuration.
63
+ use_update_service : bool = False
64
+ update_service_url : str = "https://updates.codegate.ai/api/v1/version"
65
+
62
66
max_fim_hash_lifetime : int = 60 * 5 # Time in seconds. Default is 5 minutes.
63
67
64
68
# Min value is 0 (max similarity), max value is 2 (orthogonal)
@@ -165,6 +169,8 @@ def from_file(cls, config_path: Union[str, Path]) -> "Config":
165
169
force_certs = config_data .get ("force_certs" , cls .force_certs ),
166
170
prompts = prompts_config ,
167
171
provider_urls = provider_urls ,
172
+ use_update_service = config_data .get ("use_update_service" , cls .use_update_service ),
173
+ update_service_url = config_data .get ("update_service_url" , cls .update_service_url ),
168
174
)
169
175
except yaml .YAMLError as e :
170
176
raise ConfigurationError (f"Failed to parse config file: { e } " )
@@ -209,11 +215,17 @@ def from_env(cls) -> "Config":
209
215
if "CODEGATE_SERVER_KEY" in os .environ :
210
216
config .server_key = os .environ ["CODEGATE_SERVER_KEY" ]
211
217
if "CODEGATE_FORCE_CERTS" in os .environ :
212
- config .force_certs = os .environ ["CODEGATE_FORCE_CERTS" ]
218
+ config .force_certs = cls . __bool_from_string ( os .environ ["CODEGATE_FORCE_CERTS" ])
213
219
if "CODEGATE_DB_PATH" in os .environ :
214
220
config .db_path = os .environ ["CODEGATE_DB_PATH" ]
215
221
if "CODEGATE_VEC_DB_PATH" in os .environ :
216
222
config .vec_db_path = os .environ ["CODEGATE_VEC_DB_PATH" ]
223
+ if "CODEGATE_USE_UPDATE_SERVICE" in os .environ :
224
+ config .use_update_service = cls .__bool_from_string (
225
+ os .environ ["CODEGATE_USE_UPDATE_SERVICE" ]
226
+ )
227
+ if "CODEGATE_UPDATE_SERVICE_URL" in os .environ :
228
+ config .update_service_url = os .environ ["CODEGATE_UPDATE_SERVICE_URL" ]
217
229
218
230
# Load provider URLs from environment variables
219
231
for provider in DEFAULT_PROVIDER_URLS .keys ():
@@ -246,6 +258,8 @@ def load(
246
258
force_certs : Optional [bool ] = None ,
247
259
db_path : Optional [str ] = None ,
248
260
vec_db_path : Optional [str ] = None ,
261
+ use_update_service : Optional [bool ] = None ,
262
+ update_service_url : Optional [str ] = None ,
249
263
) -> "Config" :
250
264
"""Load configuration with priority resolution.
251
265
@@ -274,6 +288,8 @@ def load(
274
288
force_certs: Optional flag to force certificate generation
275
289
db_path: Optional path to the main SQLite database file
276
290
vec_db_path: Optional path to the vector SQLite database file
291
+ use_update_service: Optional flag to enable the update service
292
+ update_service_url: Optional URL for the update service
277
293
278
294
Returns:
279
295
Config: Resolved configuration
@@ -326,6 +342,10 @@ def load(
326
342
config .db_path = env_config .db_path
327
343
if "CODEGATE_VEC_DB_PATH" in os .environ :
328
344
config .vec_db_path = env_config .vec_db_path
345
+ if "CODEGATE_USE_UPDATE_SERVICE" in os .environ :
346
+ config .use_update_service = env_config .use_update_service
347
+ if "CODEGATE_UPDATE_SERVICE_URL" in os .environ :
348
+ config .update_service_url = env_config .update_service_url
329
349
330
350
# Override provider URLs from environment
331
351
for provider , url in env_config .provider_urls .items ():
@@ -366,6 +386,10 @@ def load(
366
386
config .vec_db_path = vec_db_path
367
387
if force_certs is not None :
368
388
config .force_certs = force_certs
389
+ if use_update_service is not None :
390
+ config .use_update_service = use_update_service
391
+ if update_service_url is not None :
392
+ config .update_service_url = update_service_url
369
393
370
394
# Set the __config class attribute
371
395
Config .__config = config
@@ -375,3 +399,7 @@ def load(
375
399
@classmethod
376
400
def get_config (cls ) -> "Config" :
377
401
return cls .__config
402
+
403
+ @staticmethod
404
+ def __bool_from_string (raw_value ) -> bool :
405
+ return raw_value .lower () == "true"
0 commit comments