bichnhan2701 commited on
Commit
54bf491
·
1 Parent(s): dec42d4

Change Gemini model version

Browse files
app/config.py CHANGED
@@ -1,4 +1,5 @@
1
  import os
2
 
3
  GEMINI_API_KEY = os.getenv("GEMINI_API_KEY", "")
 
4
  FIREBASE_SERVICE_ACCOUNT = os.getenv("FIREBASE_SERVICE_ACCOUNT", "")
 
1
  import os
2
 
3
  GEMINI_API_KEY = os.getenv("GEMINI_API_KEY", "")
4
+ GEMINI_MODEL = os.getenv("GEMINI_MODEL", "")
5
  FIREBASE_SERVICE_ACCOUNT = os.getenv("FIREBASE_SERVICE_ACCOUNT", "")
app/services/mindmap_service.py CHANGED
@@ -3,23 +3,25 @@ import asyncio
3
  import json
4
  import logging
5
 
6
- from app.config import GEMINI_API_KEY
7
 
8
  import google.genai as genai
9
  from google.api_core.exceptions import GoogleAPIError
10
 
11
- _MINDMAP_MODEL = "gemini-1.5-flash"
12
  _gemini_client = None
13
 
14
- if GEMINI_API_KEY:
 
 
 
 
15
  try:
16
  _gemini_client = genai.Client(api_key=GEMINI_API_KEY)
17
- logging.info(f"[mindmap_service] Initialized google.genai client with model={_MINDMAP_MODEL}")
18
  except Exception as e:
19
  logging.exception(f"[mindmap_service] Failed to init google.genai client: {e}")
20
  _gemini_client = None
21
- else:
22
- logging.warning("[mindmap_service] GEMINI_API_KEY is not set, mindmap generation will be disabled")
23
 
24
 
25
  async def generate_mindmap(text: str) -> dict:
 
3
  import json
4
  import logging
5
 
6
+ from app.config import GEMINI_API_KEY, GEMINI_MODEL
7
 
8
  import google.genai as genai
9
  from google.api_core.exceptions import GoogleAPIError
10
 
11
+ _MINDMAP_MODEL = GEMINI_MODEL
12
  _gemini_client = None
13
 
14
+ if not GEMINI_API_KEY:
15
+ logging.warning("[mindmap_service] GEMINI_API_KEY is not set; mindmap generation disabled")
16
+ elif not _MINDMAP_MODEL:
17
+ logging.warning("[mindmap_service] GEMINI_MODEL is not set; mindmap generation disabled")
18
+ else:
19
  try:
20
  _gemini_client = genai.Client(api_key=GEMINI_API_KEY)
21
+ logging.info(f"[mindmap_service] Initialized google.genai client; model={_MINDMAP_MODEL}")
22
  except Exception as e:
23
  logging.exception(f"[mindmap_service] Failed to init google.genai client: {e}")
24
  _gemini_client = None
 
 
25
 
26
 
27
  async def generate_mindmap(text: str) -> dict:
app/services/summary_service.py CHANGED
@@ -1,7 +1,7 @@
1
  import asyncio
2
  import logging
3
 
4
- from app.config import GEMINI_API_KEY
5
 
6
  try:
7
  import google.genai as genai
@@ -11,17 +11,19 @@ except Exception:
11
 
12
  from google.api_core.exceptions import GoogleAPIError
13
 
14
- _SUMMARY_MODEL = "gemini-1.5-flash"
15
  _gemini_client = None
16
 
17
  if not genai:
18
- logging.warning("[summary_service] google.genai not available, summary will be empty")
19
  elif not GEMINI_API_KEY:
20
- logging.warning("[summary_service] GEMINI_API_KEY is not set, summary will be empty")
 
 
21
  else:
22
  try:
23
  _gemini_client = genai.Client(api_key=GEMINI_API_KEY)
24
- logging.info(f"[summary_service] Initialized google.genai client with model={_SUMMARY_MODEL}")
25
  except Exception as e:
26
  logging.exception(f"[summary_service] Failed to init google.genai client: {e}")
27
  _gemini_client = None
 
1
  import asyncio
2
  import logging
3
 
4
+ from app.config import GEMINI_API_KEY, GEMINI_MODEL
5
 
6
  try:
7
  import google.genai as genai
 
11
 
12
  from google.api_core.exceptions import GoogleAPIError
13
 
14
+ _SUMMARY_MODEL = GEMINI_MODEL
15
  _gemini_client = None
16
 
17
  if not genai:
18
+ logging.warning("[summary_service] google.genai not available; summaries disabled")
19
  elif not GEMINI_API_KEY:
20
+ logging.warning("[summary_service] GEMINI_API_KEY is not set; summaries disabled")
21
+ elif not _SUMMARY_MODEL:
22
+ logging.warning("[summary_service] GEMINI_MODEL is not set; summaries disabled")
23
  else:
24
  try:
25
  _gemini_client = genai.Client(api_key=GEMINI_API_KEY)
26
+ logging.info(f"[summary_service] Initialized google.genai client; model={_SUMMARY_MODEL}")
27
  except Exception as e:
28
  logging.exception(f"[summary_service] Failed to init google.genai client: {e}")
29
  _gemini_client = None