Yassine Mhirsi commited on
Commit
70a2026
·
1 Parent(s): 17abb72

Update configuration for stance detection model by renaming environment variables and adjusting model loading in main.py

Browse files
Files changed (2) hide show
  1. config.py +2 -2
  2. main.py +4 -3
config.py CHANGED
@@ -13,11 +13,11 @@ PROJECT_ROOT = API_DIR.parent
13
 
14
  # Hugging Face configuration
15
  HUGGINGFACE_API_KEY = os.getenv("HUGGINGFACE_API_KEY", "")
16
- HUGGINGFACE_MODEL_ID = os.getenv("HUGGINGFACE_MODEL_ID", "yassine-mhirsi/debertav3-stance-detection")
17
 
18
  # Stance detection model configuration
19
  # Use Hugging Face model ID instead of local path
20
- STANCE_MODEL_ID = HUGGINGFACE_MODEL_ID
21
 
22
  # API configuration
23
  API_TITLE = "NLP Project API"
 
13
 
14
  # Hugging Face configuration
15
  HUGGINGFACE_API_KEY = os.getenv("HUGGINGFACE_API_KEY", "")
16
+ HUGGINGFACE_STANCE_MODEL_ID = os.getenv("HUGGINGFACE_STANCE_MODEL_ID", "yassine-mhirsi/debertav3-stance-detection")
17
 
18
  # Stance detection model configuration
19
  # Use Hugging Face model ID instead of local path
20
+ STANCE_MODEL_ID = HUGGINGFACE_STANCE_MODEL_ID
21
 
22
  # API configuration
23
  API_TITLE = "NLP Project API"
main.py CHANGED
@@ -19,7 +19,8 @@ from config import (
19
  API_DESCRIPTION,
20
  API_VERSION,
21
  STANCE_MODEL_ID,
22
- HUGGINGFACE_API_KEY,
 
23
  HOST,
24
  PORT,
25
  RELOAD,
@@ -44,8 +45,8 @@ async def lifespan(app: FastAPI):
44
 
45
  # Load stance detection model
46
  try:
47
- logger.info(f"Loading stance model from Hugging Face: {STANCE_MODEL_ID}")
48
- stance_model_manager.load_model(STANCE_MODEL_ID, HUGGINGFACE_API_KEY)
49
  except Exception as e:
50
  logger.error(f"✗ Failed to load stance model: {str(e)}")
51
  logger.error("⚠️ Stance detection endpoints will not work!")
 
19
  API_DESCRIPTION,
20
  API_VERSION,
21
  STANCE_MODEL_ID,
22
+ HUGGINGFACE_STANCE_API_KEY,
23
+ HUGGINGFACE_STANCE_MODEL_ID,
24
  HOST,
25
  PORT,
26
  RELOAD,
 
45
 
46
  # Load stance detection model
47
  try:
48
+ logger.info(f"Loading stance model from Hugging Face: {HUGGINGFACE_STANCE_MODEL_ID}")
49
+ stance_model_manager.load_model(HUGGINGFACE_STANCE_MODEL_ID, HUGGINGFACE_STANCE_API_KEY)
50
  except Exception as e:
51
  logger.error(f"✗ Failed to load stance model: {str(e)}")
52
  logger.error("⚠️ Stance detection endpoints will not work!")