-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
78 lines (61 loc) · 2 KB
/
config.py
File metadata and controls
78 lines (61 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
"""
AI-Powered E-Learning Generator Configuration
This module contains configuration settings for the application.
Move sensitive settings to environment variables for production.
"""
import os
from typing import Dict, Any
class Config:
"""Base configuration class"""
# Flask Configuration
SECRET_KEY = os.environ.get('SECRET_KEY') or 'dev-secret-key-change-in-production'
DEBUG = os.environ.get('FLASK_ENV') == 'development'
# OpenAI Configuration
OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY')
# Server Configuration
HOST = os.environ.get('FLASK_HOST', '0.0.0.0')
PORT = int(os.environ.get('FLASK_PORT', 8080))
# CORS Configuration
CORS_ORIGINS = os.environ.get('CORS_ORIGIN', 'http://127.0.0.1:5500').split(',')
# API Configuration
API_VERSION = 'v1.0'
API_BASE_PATH = f'/api/{API_VERSION}'
# AI Model Configuration
DEFAULT_MODEL = 'text-davinci-003'
MAX_TOKENS = 1500
TEMPERATURE = 0.7
# Image Generation Configuration
IMAGE_SIZE = '512x512'
IMAGE_COUNT = 1
# Application Limits
MAX_QUESTIONS = 50
MAX_ANSWERS = 10
MAX_CONTENT_LENGTH = 10000
# Supported Languages
SUPPORTED_LANGUAGES = {
'italian': 'Italian',
'english': 'English',
'french': 'French',
'spanish': 'Spanish'
}
class DevelopmentConfig(Config):
"""Development configuration"""
DEBUG = True
class ProductionConfig(Config):
"""Production configuration"""
DEBUG = False
class TestingConfig(Config):
"""Testing configuration"""
TESTING = True
DEBUG = True
# Configuration mapping
config_map: Dict[str, Any] = {
'development': DevelopmentConfig,
'production': ProductionConfig,
'testing': TestingConfig,
'default': DevelopmentConfig
}
def get_config(env: str = None) -> Config:
"""Get configuration based on environment"""
env = env or os.environ.get('FLASK_ENV', 'default')
return config_map.get(env, DevelopmentConfig)