Skip to content

Commit 0ea1cf0

Browse files
"Fix DEV_MODE handling and RAGAgent initialization"
- Prioritize DEV_MODE explicitly during model selection - Avoid ambiguous `model is None` checks - Ensure model argument is always a valid identifier - Clean up requirements.txt (remove duplicate entry, add newline at EOF) This improves startup reliability and aligns with expected development and production behavior.
1 parent e601cd8 commit 0ea1cf0

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

app/ai.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,14 @@ class RAGAgent:
3838

3939
def __init__(self, model: Optional[str] = None, quantize: bool = True):
4040
# Determine which model to use based on DEV_MODE
41-
if model is None:
42-
if settings.DEV_MODE:
43-
# Use a lightweight model that runs easily on CPUs/Low RAM
44-
self.model_name = "google/flan-t5-small"
45-
print(f"🔧 DEV_MODE active: Switching to lightweight model: {self.model_name}")
46-
else:
47-
self.model_name = "google/gemma-3-27b-it"
48-
else:
41+
if settings.DEV_MODE:
42+
# Use a lightweight model that runs easily on CPUs / low RAM
43+
self.model_name = "google/flan-t5-small"
44+
print(f"DEV_MODE active: Switching to lightweight model: {self.model_name}")
45+
elif model is not None:
4946
self.model_name = model
47+
else:
48+
self.model_name = "google/gemma-3-27b-it"
5049

5150
# Only quantize if it's NOT dev mode and CUDA is available
5251
self.use_quant = quantize and torch.cuda.is_available() and not settings.DEV_MODE

app/config.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,21 @@ class Settings(BaseSettings):
1818
DOC_PATHS: List[str] = Field(default_factory=list)
1919
MAX_DAILY_REQUESTS: int = 100
2020

21+
# OAuth
2122
github_client_id: Optional[str] = None
2223
github_client_secret: Optional[str] = None
2324
google_client_id: Optional[str] = None
2425
google_client_secret: Optional[str] = None
2526
oauth_redirect_uri: Optional[str] = None
2627
session_secret_key: Optional[str] = None
27-
28-
port: int = 8000
28+
29+
port: Optional[str] = None
30+
31+
# application settings
2932
TEMPLATES_DIR: str = "templates"
33+
34+
class Config:
35+
env_file = ".env"
36+
extra = "allow" # this allows extra attribute if we have any
3037

31-
model_config = SettingsConfigDict(
32-
env_file=".env",
33-
env_file_encoding="utf-8",
34-
extra="allow"
35-
)
36-
37-
settings = Settings()
38+
settings = Settings()

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ itsdangerous
1818
httpx
1919
pydantic-settings
2020
sentence-transformers
21-
python-dotenv
21+
python-dotenv

0 commit comments

Comments
 (0)