@@ -59,6 +59,10 @@ class Config:
5959 server_key : str = "server.key"
6060 force_certs : bool = False
6161
62+ # Update configuration.
63+ use_update_service : bool = False
64+ update_service_url : str = "https://updates.codegate.ai/api/v1/version"
65+
6266 max_fim_hash_lifetime : int = 60 * 5 # Time in seconds. Default is 5 minutes.
6367
6468 # 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":
165169 force_certs = config_data .get ("force_certs" , cls .force_certs ),
166170 prompts = prompts_config ,
167171 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 ),
168174 )
169175 except yaml .YAMLError as e :
170176 raise ConfigurationError (f"Failed to parse config file: { e } " )
@@ -209,11 +215,17 @@ def from_env(cls) -> "Config":
209215 if "CODEGATE_SERVER_KEY" in os .environ :
210216 config .server_key = os .environ ["CODEGATE_SERVER_KEY" ]
211217 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" ])
213219 if "CODEGATE_DB_PATH" in os .environ :
214220 config .db_path = os .environ ["CODEGATE_DB_PATH" ]
215221 if "CODEGATE_VEC_DB_PATH" in os .environ :
216222 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" ]
217229
218230 # Load provider URLs from environment variables
219231 for provider in DEFAULT_PROVIDER_URLS .keys ():
@@ -246,6 +258,8 @@ def load(
246258 force_certs : Optional [bool ] = None ,
247259 db_path : Optional [str ] = None ,
248260 vec_db_path : Optional [str ] = None ,
261+ use_update_service : Optional [bool ] = None ,
262+ update_service_url : Optional [str ] = None ,
249263 ) -> "Config" :
250264 """Load configuration with priority resolution.
251265
@@ -274,6 +288,8 @@ def load(
274288 force_certs: Optional flag to force certificate generation
275289 db_path: Optional path to the main SQLite database file
276290 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
277293
278294 Returns:
279295 Config: Resolved configuration
@@ -326,6 +342,10 @@ def load(
326342 config .db_path = env_config .db_path
327343 if "CODEGATE_VEC_DB_PATH" in os .environ :
328344 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
329349
330350 # Override provider URLs from environment
331351 for provider , url in env_config .provider_urls .items ():
@@ -366,6 +386,10 @@ def load(
366386 config .vec_db_path = vec_db_path
367387 if force_certs is not None :
368388 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
369393
370394 # Set the __config class attribute
371395 Config .__config = config
@@ -375,3 +399,7 @@ def load(
375399 @classmethod
376400 def get_config (cls ) -> "Config" :
377401 return cls .__config
402+
403+ @staticmethod
404+ def __bool_from_string (raw_value ) -> bool :
405+ return raw_value .lower () == "true"
0 commit comments