Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -17,12 +17,21 @@ app = FastAPI()
|
|
17 |
# Set up logging
|
18 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s: %(message)s')
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
if not api_key:
|
24 |
raise EnvironmentError("Google API Key not found in environment variables.")
|
25 |
-
|
|
|
|
|
|
|
26 |
|
27 |
def get_pdf_text(pdf_docs):
|
28 |
text = ""
|
|
|
17 |
# Set up logging
|
18 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s: %(message)s')
|
19 |
|
20 |
+
import google.generativeai as genai
|
21 |
+
from dotenv import load_dotenv
|
22 |
+
import os
|
23 |
+
|
24 |
+
# Load environment variables from .env file
|
25 |
+
load_dotenv()
|
26 |
+
|
27 |
+
# Retrieve the API key from the environment
|
28 |
+
api_key = os.getenv("GOOGLE_API_KEY")
|
29 |
if not api_key:
|
30 |
raise EnvironmentError("Google API Key not found in environment variables.")
|
31 |
+
|
32 |
+
# Configure Google Generative AI
|
33 |
+
genai.configure(api_key=api_key)
|
34 |
+
|
35 |
|
36 |
def get_pdf_text(pdf_docs):
|
37 |
text = ""
|