Update llm/apimodels/gemini_model.py
Browse files
llm/apimodels/gemini_model.py
CHANGED
@@ -1,26 +1,10 @@
|
|
1 |
-
|
2 |
import os
|
3 |
-
import logging
|
4 |
|
5 |
from llm.utils.hf_interface import HFInterface
|
6 |
|
7 |
from langchain_google_genai import GoogleGenerativeAI
|
8 |
from abc import ABC
|
9 |
|
10 |
-
logger = logging.getLogger(__name__)
|
11 |
-
logger.setLevel(logging.ERROR)
|
12 |
-
|
13 |
-
file_handler = logging.FileHandler(
|
14 |
-
"logs/chelsea_llm_gemini.log") # for all modules here template for logs file is "llm/logs/chelsea_{module_name}_{entity}.log"
|
15 |
-
logger.setLevel(logging.INFO) # informed
|
16 |
-
|
17 |
-
formatted = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
|
18 |
-
file_handler.setFormatter(formatted)
|
19 |
-
|
20 |
-
logger.addHandler(file_handler)
|
21 |
-
logger.info("Getting information from apimodel module")
|
22 |
-
|
23 |
-
|
24 |
# 429 - You've exceeded the rate limit.
|
25 |
# 400 - The request body is malformed.
|
26 |
# 403 - Your API key doesn't have the required permissions.
|
@@ -33,7 +17,7 @@ logger.info("Getting information from apimodel module")
|
|
33 |
# якщо ж у користувача відсутнє інтернет зʼєднання, то нічим не зарадиш,
|
34 |
# хіба що пропонувати скачати репозиторій.
|
35 |
|
36 |
-
_api = os.environ.get("
|
37 |
|
38 |
|
39 |
class Gemini(HFInterface, ABC):
|
@@ -74,7 +58,6 @@ class Gemini(HFInterface, ABC):
|
|
74 |
try:
|
75 |
return self.llm
|
76 |
except Exception as e:
|
77 |
-
logger.error("Something wrong with Gemini api", exc_info=e)
|
78 |
print(f"Something wrong with Gemini api: {e}")
|
79 |
|
80 |
def model_name(self):
|
|
|
|
|
1 |
import os
|
|
|
2 |
|
3 |
from llm.utils.hf_interface import HFInterface
|
4 |
|
5 |
from langchain_google_genai import GoogleGenerativeAI
|
6 |
from abc import ABC
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
# 429 - You've exceeded the rate limit.
|
9 |
# 400 - The request body is malformed.
|
10 |
# 403 - Your API key doesn't have the required permissions.
|
|
|
17 |
# якщо ж у користувача відсутнє інтернет зʼєднання, то нічим не зарадиш,
|
18 |
# хіба що пропонувати скачати репозиторій.
|
19 |
|
20 |
+
_api = os.environ.get("GOOGLE_API_KEY")
|
21 |
|
22 |
|
23 |
class Gemini(HFInterface, ABC):
|
|
|
58 |
try:
|
59 |
return self.llm
|
60 |
except Exception as e:
|
|
|
61 |
print(f"Something wrong with Gemini api: {e}")
|
62 |
|
63 |
def model_name(self):
|