# app/config/settings.py """ HealthSync AI 애플리케이션 설정 관리 (올바른 Pinecone 설정) """ from pydantic_settings import BaseSettings from typing import List, Optional import os from dotenv import load_dotenv # .env 파일 로드 load_dotenv() class Settings(BaseSettings): """HealthSync AI 애플리케이션 설정 클래스""" # 기본 앱 설정 app_name: str = "HealthSync AI" app_version: str = "1.0.0" debug: bool = True app_description: str = "AI 기반 개인 맞춤형 건강관리 서비스" # 서버 설정 host: str = "localhost" port: int = 8000 # 보안 설정 secret_key: str = "healthsync-ai-secret-key-change-in-production" algorithm: str = "HS256" access_token_expire_minutes: int = 30 # API 설정 api_v1_prefix: str = "/api" cors_origins: List[str] = ["*"] # PostgreSQL 설정 db_host: str = "localhost" db_port: int = 5432 db_name: str = "healthsync_ai" db_username: str = "postgres" db_password: str = "password" db_min_size: int = 1 db_max_size: int = 10 # Claude AI 설정 claude_api_key: str = "" claude_model: str = "claude-3-5-sonnet-20241022" claude_max_tokens: int = 1500 claude_temperature: float = 0.7 claude_timeout: int = 30 claude_api_base_url: str = "https://api.anthropic.com" # Pinecone 벡터DB 설정 (올바른 기본값) pinecone_api_key: str = "" pinecone_environment: str = "aped-4627-b74a" # 실제 환경 pinecone_index_name: str = "healthsync-users" # Azure Cache for Redis 설정 redis_host: str = "localhost" redis_port: int = 6380 # Azure Cache for Redis 기본 SSL 포트 redis_password: str = "" # Azure Cache Primary Access Key redis_db: int = 0 redis_cache_ttl: int = 1800 # 30분 redis_ssl: bool = True # Azure Cache는 SSL 필수 # 로깅 설정 log_level: str = "INFO" @property def database_url(self) -> str: """데이터베이스 URL 생성""" return f"postgresql://{self.db_username}:{self.db_password}@{self.db_host}:{self.db_port}/{self.db_name}" @property def redis_url(self) -> str: """Redis URL 생성 (Azure Cache for Redis 지원)""" if self.redis_password: # Azure Cache for Redis (SSL + 인증) protocol = "rediss" if self.redis_ssl else "redis" return f"{protocol}://:{self.redis_password}@{self.redis_host}:{self.redis_port}/{self.redis_db}" else: # 로컬 Redis (비SSL) return f"redis://{self.redis_host}:{self.redis_port}/{self.redis_db}" @property def is_azure_redis(self) -> bool: """Azure Cache for Redis 사용 여부 확인""" return bool(self.redis_password and "cache.windows.net" in self.redis_host) class Config: env_file = ".env" case_sensitive = False # 전역 설정 인스턴스 settings = Settings()