Spaces:
Build error
Build error
Update util.py
Browse files
util.py
CHANGED
|
@@ -7,27 +7,10 @@ from langchain.prompts import PromptTemplate
|
|
| 7 |
from langchain_google_genai import GoogleGenerativeAIEmbeddings
|
| 8 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 9 |
import google.generativeai as genai
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
-
##
|
| 15 |
-
|
| 16 |
-
from functools import lru_cache
|
| 17 |
-
from pydantic_settings 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:
|
|
|
|
| 7 |
from langchain_google_genai import GoogleGenerativeAIEmbeddings
|
| 8 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 9 |
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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
def extract_text(json_path):
|
| 16 |
with open(json_path, 'r') as file:
|