Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

fix: Env now override default config file

Clémence Lesné85afe66cc655
diff --git a/helpers/config_models/root.py b/helpers/config_models/root.py
index fa5b4f5..ed9d161 100644
--- a/helpers/config_models/root.py
+++ b/helpers/config_models/root.py
@@ -1,5 +1,9 @@
from pydantic import Field
-from pydantic_settings import BaseSettings, SettingsConfigDict
+from pydantic_settings import (
+ BaseSettings,
+ PydanticBaseSettingsSource,
+ SettingsConfigDict,
+)
from helpers.config_models.ai_search import AiSearchModel
from helpers.config_models.ai_translation import AiTranslationModel
@@ -45,3 +49,25 @@ class RootModel(BaseSettings):
conversation: ConversationModel = Field(
serialization_alias="workflow"
) # Compatibility with v7
+
+ @classmethod
+ def settings_customise_sources(
+ cls,
+ settings_cls: type[BaseSettings],
+ init_settings: PydanticBaseSettingsSource,
+ env_settings: PydanticBaseSettingsSource,
+ dotenv_settings: PydanticBaseSettingsSource,
+ file_secret_settings: PydanticBaseSettingsSource,
+ ) -> tuple[PydanticBaseSettingsSource, ...]:
+ """
+ Customise the order of the settings sources.
+
+ Order is now:
+ 1. Environment variables
+ 2. .env file
+ 3. Docker secrets
+ 4. Initial settings
+
+ See: https://docs.pydantic.dev/latest/concepts/pydantic_settings/#changing-priority
+ """
+ return env_settings, dotenv_settings, file_secret_settings, init_settings