Joash commited on
Commit
a01c4ae
·
1 Parent(s): a307172

Switch to smaller model and reduce memory limits

Browse files
Files changed (1) hide show
  1. src/config.py +14 -7
src/config.py CHANGED
@@ -15,18 +15,17 @@ class Config:
15
  # API Settings
16
  API_VERSION = os.getenv("API_VERSION", "v1")
17
  API_TITLE = os.getenv("API_TITLE", "Code Review Assistant API")
18
- API_DESCRIPTION = os.getenv("API_DESCRIPTION", "An automated code review system powered by Gemma-2b-it")
19
  HOST = os.getenv("HOST", "0.0.0.0")
20
  PORT = int(os.getenv("PORT", 8000))
21
  DEBUG = os.getenv("DEBUG", "false").lower() == "true"
22
 
23
  # Model Settings
24
- MODEL_NAME = os.getenv("MODEL_NAME", "google/gemma-2-2b-it")
25
- MAX_INPUT_LENGTH = int(os.getenv("MAX_INPUT_LENGTH", 2048))
26
- MAX_OUTPUT_LENGTH = int(os.getenv("MAX_OUTPUT_LENGTH", 1024))
27
  TEMPERATURE = float(os.getenv("TEMPERATURE", 0.7))
28
  TOP_P = float(os.getenv("TOP_P", 0.95))
29
- # Token must be set in environment variables
30
  HUGGING_FACE_TOKEN = os.getenv("HUGGING_FACE_TOKEN")
31
 
32
  # Database Settings
@@ -45,8 +44,14 @@ class Config:
45
  LOG_FILE = os.getenv("LOG_FILE", "logs/code_review.log")
46
 
47
  # Review History Settings
48
- MAX_HISTORY_ITEMS = int(os.getenv("MAX_HISTORY_ITEMS", 1000))
49
- HISTORY_RETENTION_DAYS = int(os.getenv("HISTORY_RETENTION_DAYS", 30))
 
 
 
 
 
 
50
 
51
  @staticmethod
52
  def validate():
@@ -58,6 +63,8 @@ class Config:
58
  logger.info(f"HOST: {Config.HOST}")
59
  logger.info(f"PORT: {Config.PORT}")
60
  logger.info(f"DEBUG: {Config.DEBUG}")
 
 
61
 
62
  if not Config.HUGGING_FACE_TOKEN:
63
  raise ValueError("HUGGING_FACE_TOKEN must be set in environment variables to access Hugging Face models.")
 
15
  # API Settings
16
  API_VERSION = os.getenv("API_VERSION", "v1")
17
  API_TITLE = os.getenv("API_TITLE", "Code Review Assistant API")
18
+ API_DESCRIPTION = os.getenv("API_DESCRIPTION", "An automated code review system powered by Gemma")
19
  HOST = os.getenv("HOST", "0.0.0.0")
20
  PORT = int(os.getenv("PORT", 8000))
21
  DEBUG = os.getenv("DEBUG", "false").lower() == "true"
22
 
23
  # Model Settings
24
+ MODEL_NAME = os.getenv("MODEL_NAME", "google/gemma-2b-it") # Using 2B parameter model instead of 7B
25
+ MAX_INPUT_LENGTH = int(os.getenv("MAX_INPUT_LENGTH", 512)) # Reduced from 2048
26
+ MAX_OUTPUT_LENGTH = int(os.getenv("MAX_OUTPUT_LENGTH", 512)) # Reduced from 1024
27
  TEMPERATURE = float(os.getenv("TEMPERATURE", 0.7))
28
  TOP_P = float(os.getenv("TOP_P", 0.95))
 
29
  HUGGING_FACE_TOKEN = os.getenv("HUGGING_FACE_TOKEN")
30
 
31
  # Database Settings
 
44
  LOG_FILE = os.getenv("LOG_FILE", "logs/code_review.log")
45
 
46
  # Review History Settings
47
+ MAX_HISTORY_ITEMS = int(os.getenv("MAX_HISTORY_ITEMS", 100)) # Reduced from 1000
48
+ HISTORY_RETENTION_DAYS = int(os.getenv("HISTORY_RETENTION_DAYS", 7)) # Reduced from 30
49
+
50
+ # Memory Settings
51
+ MAX_MEMORY_USAGE = "2GB" # Limit memory usage
52
+ BATCH_SIZE = 1
53
+ USE_CACHE = False
54
+ USE_GRADIENT_CHECKPOINTING = True
55
 
56
  @staticmethod
57
  def validate():
 
63
  logger.info(f"HOST: {Config.HOST}")
64
  logger.info(f"PORT: {Config.PORT}")
65
  logger.info(f"DEBUG: {Config.DEBUG}")
66
+ logger.info(f"MAX_INPUT_LENGTH: {Config.MAX_INPUT_LENGTH}")
67
+ logger.info(f"MAX_OUTPUT_LENGTH: {Config.MAX_OUTPUT_LENGTH}")
68
 
69
  if not Config.HUGGING_FACE_TOKEN:
70
  raise ValueError("HUGGING_FACE_TOKEN must be set in environment variables to access Hugging Face models.")