ishans24 commited on
Commit
424c49f
·
verified ·
1 Parent(s): 55c7dac

Update util.py

Browse files
Files changed (1) hide show
  1. util.py +17 -1
util.py CHANGED
@@ -10,9 +10,25 @@ import google.generativeai as genai
10
  # from dotenv import load_dotenv
11
  # load_dotenv()
12
  # genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
13
- from .ConfigEnv import config
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  genai.configure(api_key=config.GOOGLE_API_KEY)
15
 
 
 
16
  def extract_text(json_path):
17
  with open(json_path, 'r') as file:
18
  data = json.load(file)
 
10
  # from dotenv import load_dotenv
11
  # load_dotenv()
12
  # genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
13
+
14
+ ##
15
+
16
+ from functools import lru_cache
17
+ from pydantic import BaseSettings
18
+
19
+ class Settings(BaseSettings):
20
+ GOOGLE_API_KEY: str
21
+ class Config:
22
+ env_file = '.env'
23
+
24
+ @lru_cache()
25
+ def get_settings():
26
+ return Settings()
27
+ config = get_settings()
28
  genai.configure(api_key=config.GOOGLE_API_KEY)
29
 
30
+ ##
31
+
32
  def extract_text(json_path):
33
  with open(json_path, 'r') as file:
34
  data = json.load(file)