54 lines
1.3 KiB
Python
54 lines
1.3 KiB
Python
"""Configuration helper for ADK agent."""
|
|
|
|
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
|
|
|
|
# MCP configuration
|
|
mcp_remote_url: str
|
|
|
|
model_config = SettingsConfigDict(
|
|
yaml_file=CONFIG_FILE_PATH,
|
|
extra="ignore", # Ignore extra fields from config.yaml
|
|
)
|
|
|
|
@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({})
|