mirror of
https://github.com/coleam00/context-engineering-intro.git
synced 2025-12-29 16:14:56 +00:00
AI Agent Factory with Claude Code Subagents
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
"""
|
||||
Configuration management using pydantic-settings.
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import Optional
|
||||
from pydantic_settings import BaseSettings
|
||||
from pydantic import Field, field_validator, ConfigDict
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Application settings with environment variable support."""
|
||||
|
||||
model_config = ConfigDict(
|
||||
env_file=".env",
|
||||
env_file_encoding="utf-8",
|
||||
case_sensitive=False
|
||||
)
|
||||
|
||||
# LLM Configuration
|
||||
llm_provider: str = Field(default="openai")
|
||||
llm_api_key: str = Field(...)
|
||||
llm_model: str = Field(default="gpt-4")
|
||||
llm_base_url: Optional[str] = Field(default="https://api.openai.com/v1")
|
||||
|
||||
# Brave Search Configuration
|
||||
brave_api_key: str = Field(...)
|
||||
brave_search_url: str = Field(
|
||||
default="https://api.search.brave.com/res/v1/web/search"
|
||||
)
|
||||
|
||||
# Application Configuration
|
||||
app_env: str = Field(default="development")
|
||||
log_level: str = Field(default="INFO")
|
||||
debug: bool = Field(default=False)
|
||||
|
||||
@field_validator("llm_api_key", "brave_api_key")
|
||||
@classmethod
|
||||
def validate_api_keys(cls, v):
|
||||
"""Ensure API keys are not empty."""
|
||||
if not v or v.strip() == "":
|
||||
raise ValueError("API key cannot be empty")
|
||||
return v
|
||||
|
||||
|
||||
# Global settings instance
|
||||
try:
|
||||
settings = Settings()
|
||||
except Exception:
|
||||
# For testing, create settings with dummy values
|
||||
import os
|
||||
os.environ.setdefault("LLM_API_KEY", "test_key")
|
||||
os.environ.setdefault("BRAVE_API_KEY", "test_key")
|
||||
settings = Settings()
|
||||
Reference in New Issue
Block a user