forked from Shreyas765/RefNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
72 lines (52 loc) · 2.14 KB
/
config.py
File metadata and controls
72 lines (52 loc) · 2.14 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
"""Configuration settings for RefNet."""
import os
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
class Config:
"""Base configuration class."""
# Flask settings
SECRET_KEY = os.getenv('SECRET_KEY', 'dev-secret-key-change-in-production')
DEBUG = os.getenv('FLASK_DEBUG', 'False').lower() == 'true'
HOST = os.getenv('FLASK_HOST', '0.0.0.0')
PORT = int(os.getenv('FLASK_PORT', 8000))
# API settings
API_RATE_LIMIT_DELAY = float(os.getenv('API_RATE_LIMIT_DELAY', '0.1')) # Reduced delay for faster processing
API_MAX_RETRIES = int(os.getenv('API_MAX_RETRIES', '3'))
# Search settings
DEFAULT_PAGE_SIZE = int(os.getenv('DEFAULT_PAGE_SIZE', '25'))
MAX_PAGE_SIZE = int(os.getenv('MAX_PAGE_SIZE', '50'))
# Graph settings
DEFAULT_ITERATIONS = int(os.getenv('DEFAULT_ITERATIONS', '3'))
MAX_ITERATIONS = int(os.getenv('MAX_ITERATIONS', '5'))
DEFAULT_CITED_LIMIT = int(os.getenv('DEFAULT_CITED_LIMIT', '5'))
MAX_CITED_LIMIT = int(os.getenv('MAX_CITED_LIMIT', '20'))
DEFAULT_REF_LIMIT = int(os.getenv('DEFAULT_REF_LIMIT', '5'))
MAX_REF_LIMIT = int(os.getenv('MAX_REF_LIMIT', '20'))
# Cache settings
ENABLE_CACHE = os.getenv('ENABLE_CACHE', 'True').lower() == 'true'
CACHE_TTL = int(os.getenv('CACHE_TTL', '3600')) # 1 hour in seconds
class DevelopmentConfig(Config):
"""Development configuration."""
DEBUG = True
API_RATE_LIMIT_DELAY = 0.1 # Faster for development
class ProductionConfig(Config):
"""Production configuration."""
DEBUG = False
API_RATE_LIMIT_DELAY = 0.5 # Slower for production
class TestingConfig(Config):
"""Testing configuration."""
TESTING = True
API_RATE_LIMIT_DELAY = 0.0 # No delay for testing
# Configuration mapping
config = {
'development': DevelopmentConfig,
'production': ProductionConfig,
'testing': TestingConfig,
'default': DevelopmentConfig
}
def get_config(config_name=None):
"""Get configuration class by name."""
if config_name is None:
config_name = os.getenv('FLASK_ENV', 'default')
return config.get(config_name, config['default'])