Update pipeline.py
Browse files- pipeline.py +5 -1
pipeline.py
CHANGED
|
@@ -14,7 +14,10 @@ FORMS = {
|
|
| 14 |
}
|
| 15 |
|
| 16 |
# --- Configure Gemini ---
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
def extract_text_from_pdf(pdf_path):
|
| 20 |
pages = convert_from_path(pdf_path)
|
|
@@ -33,6 +36,7 @@ Document text:
|
|
| 33 |
{raw_text}
|
| 34 |
"""
|
| 35 |
model = genai.GenerativeModel("gemini-1.5-flash")
|
|
|
|
| 36 |
response = model.generate_content(prompt)
|
| 37 |
try:
|
| 38 |
return json.loads(response.text)
|
|
|
|
| 14 |
}
|
| 15 |
|
| 16 |
# --- Configure Gemini ---
|
| 17 |
+
api_key = os.getenv("GEMINI_API_KEY")
|
| 18 |
+
if not api_key:
|
| 19 |
+
raise ValueError("❌ GEMINI_API_KEY not found. Please set it in Hugging Face Space Secrets.")
|
| 20 |
+
genai.configure(api_key=api_key)
|
| 21 |
|
| 22 |
def extract_text_from_pdf(pdf_path):
|
| 23 |
pages = convert_from_path(pdf_path)
|
|
|
|
| 36 |
{raw_text}
|
| 37 |
"""
|
| 38 |
model = genai.GenerativeModel("gemini-1.5-flash")
|
| 39 |
+
print("Gemini API called successfully ✅")
|
| 40 |
response = model.generate_content(prompt)
|
| 41 |
try:
|
| 42 |
return json.loads(response.text)
|