Hammad712 commited on
Commit
cd8b1f9
Β·
verified Β·
1 Parent(s): 507fdbe

Update app/page_speed/config.py

Browse files
Files changed (1) hide show
  1. app/page_speed/config.py +9 -23
app/page_speed/config.py CHANGED
@@ -12,18 +12,13 @@ class Settings(BaseSettings):
12
  pagespeed_api_key: str
13
  gemini_api_key: str
14
 
15
- # Qdrant (vector DB) connection (optional; if not set, QdrantClient will use defaults)
16
  qdrant_url: str
17
  qdrant_api_key: str
18
- # Optional timeout (seconds) to use when creating clients or making calls
19
  qdrant_timeout: int = 60
20
 
21
  # ───────────────────────────────────────────────────────────────────────────
22
- # Chat & RAG Configuration
23
- # ───────────────────────────────────────────────────────────────────────────
24
-
25
- # ───────────────────────────────────────────────────────────────────────────
26
- # MongoDB Configuration (Local)
27
  # ───────────────────────────────────────────────────────────────────────────
28
  mongo_user: str
29
  mongo_password: str
@@ -35,30 +30,24 @@ class Settings(BaseSettings):
35
  def mongo_uri(self) -> str:
36
  """
37
  Return a mongodb+srv URI for use with MongoClient.
38
- Do NOT include ssl=true in the URI; we'll pass tls and CA explicitly to MongoClient.
39
  """
40
  pw = quote_plus(self.mongo_password)
41
- # keep retryWrites and w=majority; do not append ssl/tls params here
42
  return f"mongodb+srv://{self.mongo_user}:{pw}@{self.mongo_host}/{self.mongo_db}?retryWrites=true&w=majority"
43
 
44
-
45
-
46
- # ───────────────────────────────────────────────────────────────────────────
47
- # local MongoDB Connection
48
- # ───────────────────────────────────────────────────────────────────────────
49
-
50
- # return f"mongodb://localhost:27017/{self.mongo_db}"
51
-
52
-
53
  # ───────────────────────────────────────────────────────────────────────────
54
  # FastAPI Server Configuration
55
  # ───────────────────────────────────────────────────────────────────────────
56
  host: str = "0.0.0.0"
57
- port: int = int(os.getenv("port", 8080))
 
 
 
 
 
58
  debug: bool = False
59
 
60
  # ───────────────────────────────────────────────────────────────────────────
61
- # App Metadata (unchanged)
62
  # ───────────────────────────────────────────────────────────────────────────
63
  app_name: str = "PageSpeed Insights Report Generator"
64
  app_version: str = "1.0.0"
@@ -67,9 +56,6 @@ class Settings(BaseSettings):
67
  "using Google's APIs and Gemini AI"
68
  )
69
 
70
- # ───────────────────────────────────────────────────────────────────────────
71
- # Tell Pydantic to load from .env and ignore extras
72
- # ───────────────────────────────────────────────────────────────────────────
73
  model_config = SettingsConfigDict(
74
  env_file=".env",
75
  env_file_encoding="utf-8",
 
12
  pagespeed_api_key: str
13
  gemini_api_key: str
14
 
15
+ # Qdrant (vector DB) connection
16
  qdrant_url: str
17
  qdrant_api_key: str
 
18
  qdrant_timeout: int = 60
19
 
20
  # ───────────────────────────────────────────────────────────────────────────
21
+ # MongoDB Configuration
 
 
 
 
22
  # ───────────────────────────────────────────────────────────────────────────
23
  mongo_user: str
24
  mongo_password: str
 
30
  def mongo_uri(self) -> str:
31
  """
32
  Return a mongodb+srv URI for use with MongoClient.
 
33
  """
34
  pw = quote_plus(self.mongo_password)
 
35
  return f"mongodb+srv://{self.mongo_user}:{pw}@{self.mongo_host}/{self.mongo_db}?retryWrites=true&w=majority"
36
 
 
 
 
 
 
 
 
 
 
37
  # ───────────────────────────────────────────────────────────────────────────
38
  # FastAPI Server Configuration
39
  # ───────────────────────────────────────────────────────────────────────────
40
  host: str = "0.0.0.0"
41
+
42
+ # --- FIX IS HERE ---
43
+ # 1. Use "PORT" (uppercase) to match Cloud env variables
44
+ # 2. Default to 7860 to match Hugging Face requirements
45
+ port: int = int(os.getenv("PORT", 7860))
46
+
47
  debug: bool = False
48
 
49
  # ───────────────────────────────────────────────────────────────────────────
50
+ # App Metadata
51
  # ───────────────────────────────────────────────────────────────────────────
52
  app_name: str = "PageSpeed Insights Report Generator"
53
  app_version: str = "1.0.0"
 
56
  "using Google's APIs and Gemini AI"
57
  )
58
 
 
 
 
59
  model_config = SettingsConfigDict(
60
  env_file=".env",
61
  env_file_encoding="utf-8",