apac-ops-bot/backend/app/config.py
SamoilenkoVadym c15f35a1df Update pricing for gpt-5-nano and fix chat interface
- Update token pricing with actual gpt-5-nano-2025-08-07 prices:
  * Input: $0.05 per 1M = $0.00005 per 1K
  * Cached: $0.005 per 1M = $0.000005 per 1K
  * Output: $0.40 per 1M = $0.0004 per 1K
- Add cached_tokens support in OpenAI service
- Update cost calculation to use cached token pricing
- Add cached_tokens column to token_usage table (migration)
- Fix chat interface keyboard handling:
  * Send message on Enter key
  * New line on Shift+Enter
  * Change onKeyPress to onKeyDown for better support
- Add textarea auto-resize with maxHeight limit
- Improve responsive styles for mobile devices
- Add iOS-specific fixes (prevent zoom on input focus)
2026-01-27 20:18:42 +00:00

67 lines
1.7 KiB
Python

"""
Application configuration using Pydantic Settings.
All configuration values are loaded from environment variables.
"""
from pydantic_settings import BaseSettings
from typing import List
class Settings(BaseSettings):
"""Application settings loaded from environment variables"""
# Application
APP_NAME: str = "Seapac Ops Bot"
APP_ENV: str = "development"
DEBUG: bool = True
SECRET_KEY: str
CORS_ORIGINS: str = "http://localhost:3000"
# Database
DATABASE_URL: str
# Azure AD / MSAL
AZURE_TENANT_ID: str
AZURE_CLIENT_ID: str
AZURE_CLIENT_SECRET: str
AZURE_REDIRECT_URI: str
# OpenAI Responses API
OPENAI_API_KEY: str
OPENAI_VECTOR_STORE_ID: str = "vs_QkOKiQCqzCHS4iFT5lP9qUxc"
OPENAI_MODEL: str = "gpt-5-nano-2025-08-07"
OPENAI_API_BASE: str = "https://api.openai.com/v1"
# Redis
REDIS_URL: str = "redis://localhost:6379/0"
# Rate Limiting
RATE_LIMIT_PER_MINUTE: int = 30
RATE_LIMIT_PER_DAY: int = 1000
# Token Costs (USD per 1K tokens)
# gpt-5-nano-2025-08-07 pricing
PROMPT_TOKEN_COST: float = 0.00005
CACHED_PROMPT_TOKEN_COST: float = 0.000005
COMPLETION_TOKEN_COST: float = 0.0004
@property
def cors_origins_list(self) -> List[str]:
"""Parse CORS origins from comma-separated string"""
return [origin.strip() for origin in self.CORS_ORIGINS.split(",")]
class Config:
env_file = ".env"
case_sensitive = True
# Global settings instance
settings = Settings()
def get_settings() -> Settings:
"""
Dependency function to get settings instance.
Used for FastAPI dependency injection.
"""
return settings