non-building checkpoint 1
This commit is contained in:
76
backend/app/core/config.py
Normal file
76
backend/app/core/config.py
Normal file
@@ -0,0 +1,76 @@
|
||||
"""
|
||||
Configuration settings for the application.
|
||||
Uses Pydantic settings management with environment variable support.
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import List, Optional
|
||||
from pydantic_settings import BaseSettings
|
||||
from pydantic import AnyHttpUrl, validator
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Application settings."""
|
||||
|
||||
# API Settings
|
||||
API_V1_STR: str = "/api/v1"
|
||||
PROJECT_NAME: str = "Daily Journal Prompt Generator API"
|
||||
VERSION: str = "1.0.0"
|
||||
DEBUG: bool = False
|
||||
ENVIRONMENT: str = "development"
|
||||
|
||||
# Server Settings
|
||||
HOST: str = "0.0.0.0"
|
||||
PORT: int = 8000
|
||||
|
||||
# CORS Settings
|
||||
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = [
|
||||
"http://localhost:3000", # Frontend dev server
|
||||
"http://localhost:80", # Frontend production
|
||||
]
|
||||
|
||||
# API Keys
|
||||
DEEPSEEK_API_KEY: Optional[str] = None
|
||||
OPENAI_API_KEY: Optional[str] = None
|
||||
API_BASE_URL: str = "https://api.deepseek.com"
|
||||
MODEL: str = "deepseek-chat"
|
||||
|
||||
# Application Settings
|
||||
MIN_PROMPT_LENGTH: int = 500
|
||||
MAX_PROMPT_LENGTH: int = 1000
|
||||
NUM_PROMPTS_PER_SESSION: int = 6
|
||||
CACHED_POOL_VOLUME: int = 20
|
||||
HISTORY_BUFFER_SIZE: int = 60
|
||||
FEEDBACK_HISTORY_SIZE: int = 30
|
||||
|
||||
# File Paths (relative to project root)
|
||||
DATA_DIR: str = "data"
|
||||
PROMPT_TEMPLATE_PATH: str = "data/ds_prompt.txt"
|
||||
FEEDBACK_TEMPLATE_PATH: str = "data/ds_feedback.txt"
|
||||
SETTINGS_CONFIG_PATH: str = "data/settings.cfg"
|
||||
|
||||
# Data File Names (relative to DATA_DIR)
|
||||
PROMPTS_HISTORIC_FILE: str = "prompts_historic.json"
|
||||
PROMPTS_POOL_FILE: str = "prompts_pool.json"
|
||||
FEEDBACK_WORDS_FILE: str = "feedback_words.json"
|
||||
FEEDBACK_HISTORIC_FILE: str = "feedback_historic.json"
|
||||
|
||||
@validator("BACKEND_CORS_ORIGINS", pre=True)
|
||||
def assemble_cors_origins(cls, v: str | List[str]) -> List[str] | str:
|
||||
"""Parse CORS origins from string or list."""
|
||||
if isinstance(v, str) and not v.startswith("["):
|
||||
return [i.strip() for i in v.split(",")]
|
||||
elif isinstance(v, (list, str)):
|
||||
return v
|
||||
raise ValueError(v)
|
||||
|
||||
class Config:
|
||||
"""Pydantic configuration."""
|
||||
env_file = ".env"
|
||||
case_sensitive = True
|
||||
extra = "ignore"
|
||||
|
||||
|
||||
# Create global settings instance
|
||||
settings = Settings()
|
||||
|
||||
Reference in New Issue
Block a user