All checks were successful
CI / ci (push) Successful in 21s
Co-authored-by: Anibal Angulo <a8065384@banorte.com> Reviewed-on: #31
70 lines
1.8 KiB
Python
70 lines
1.8 KiB
Python
"""Configuration helper for ADK agent."""
|
|
|
|
import logging
|
|
import os
|
|
|
|
from pydantic_settings import (
|
|
BaseSettings,
|
|
PydanticBaseSettingsSource,
|
|
SettingsConfigDict,
|
|
YamlConfigSettingsSource,
|
|
)
|
|
|
|
CONFIG_FILE_PATH = os.getenv("CONFIG_YAML", "config.yaml")
|
|
|
|
|
|
class AgentSettings(BaseSettings):
|
|
"""Settings for ADK agent with vector search."""
|
|
|
|
google_cloud_project: str
|
|
google_cloud_location: str
|
|
|
|
# Agent configuration
|
|
agent_name: str
|
|
agent_instructions: str
|
|
agent_model: str
|
|
|
|
# Firestore configuration
|
|
firestore_db: str
|
|
|
|
# Notifications configuration
|
|
notifications_collection_path: str = (
|
|
"artifacts/bnt-orquestador-cognitivo-dev/notifications"
|
|
)
|
|
notifications_max_to_notify: int = 5
|
|
notifications_window_hours: float = 48
|
|
|
|
# MCP configuration
|
|
mcp_audience: str
|
|
mcp_remote_url: str
|
|
|
|
# Logging
|
|
log_level: str = "INFO"
|
|
|
|
model_config = SettingsConfigDict(
|
|
yaml_file=CONFIG_FILE_PATH,
|
|
extra="ignore", # Ignore extra fields from config.yaml
|
|
env_file=".env",
|
|
)
|
|
|
|
@classmethod
|
|
def settings_customise_sources(
|
|
cls,
|
|
settings_cls: type[BaseSettings],
|
|
init_settings: PydanticBaseSettingsSource, # noqa: ARG003
|
|
env_settings: PydanticBaseSettingsSource,
|
|
dotenv_settings: PydanticBaseSettingsSource, # noqa: ARG003
|
|
file_secret_settings: PydanticBaseSettingsSource, # noqa: ARG003
|
|
) -> tuple[PydanticBaseSettingsSource, ...]:
|
|
"""Use env vars and YAML as settings sources."""
|
|
return (
|
|
env_settings,
|
|
YamlConfigSettingsSource(settings_cls),
|
|
)
|
|
|
|
|
|
settings = AgentSettings.model_validate({})
|
|
|
|
logging.basicConfig()
|
|
logging.getLogger("va_agent").setLevel(settings.log_level.upper())
|