# config/settings.py import os from pathlib import Path import streamlit as st # Check if we're running on HuggingFace Space IS_HF_SPACE = os.getenv('SPACE_ID') is not None # Base directories if IS_HF_SPACE: # Use a directory in the HF space BASE_DIR = Path('/data') else: BASE_DIR = Path(__file__).resolve().parent.parent # Data directories DATA_DIR = BASE_DIR / "data" CHAT_HISTORIES_DIR = DATA_DIR / "chat_histories" CHAT_IMAGES_DIR = DATA_DIR / "chat_images" # Create directories if they don't exist for directory in [DATA_DIR, CHAT_HISTORIES_DIR, CHAT_IMAGES_DIR]: try: directory.mkdir(parents=True, exist_ok=True) # Ensure directories are writable if directory.exists(): os.chmod(directory, 0o777) except Exception as e: st.warning(f"Could not create or modify directory {directory}: {str(e)}") # Fallback to temporary directory if needed if str(directory).startswith(str(BASE_DIR)): new_path = Path('/tmp') / directory.relative_to(BASE_DIR) new_path.mkdir(parents=True, exist_ok=True) if IS_HF_SPACE: directory = new_path # API Settings - Get from HuggingFace secrets ANTHROPIC_API_KEY = os.getenv('ANTHROPIC_API_KEY') CLAUDE_MODEL = "claude-3-opus-20240229" # App Settings APP_NAME = "Stock Chart Assistant" APP_EMOJI = "📈" # Analysis Options CHART_PATTERNS = [ "Double Top/Bottom", "Head and Shoulders", "Triangle", "Flag", "Wedge", "Channel", "Support/Resistance" ] TECHNICAL_INDICATORS = [ "Moving Averages", "RSI", "MACD", "Bollinger Bands", "Volume", "Stochastic", "ADX" ]