Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,19 +8,24 @@ import os
|
|
| 8 |
from crewai import Agent, Task, Crew
|
| 9 |
from crewai_tools import SerperDevTool # Ensure it's correctly installed
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
|
|
|
| 13 |
serper_key = os.getenv("serper_key")
|
| 14 |
|
| 15 |
-
if not
|
| 16 |
-
raise ValueError("ERROR:
|
| 17 |
if not serper_key:
|
| 18 |
raise ValueError("ERROR: SERPER_API_KEY is missing. Set it in Hugging Face Spaces settings.")
|
| 19 |
|
| 20 |
-
|
| 21 |
-
os.environ[
|
| 22 |
os.environ["SERPER_API_KEY"] = serper_key
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
def extract_text_from_pdf(file_path):
|
| 25 |
"""Extracts text from a PDF file using PyMuPDF."""
|
| 26 |
doc = fitz.open(file_path)
|
|
@@ -129,5 +134,5 @@ with gr.Blocks() as demo:
|
|
| 129 |
)
|
| 130 |
|
| 131 |
demo.queue()
|
| 132 |
-
demo.launch(server_port=
|
| 133 |
|
|
|
|
| 8 |
from crewai import Agent, Task, Crew
|
| 9 |
from crewai_tools import SerperDevTool # Ensure it's correctly installed
|
| 10 |
|
| 11 |
+
# Retrieve Gemini API key from environment variables
|
| 12 |
+
gemini_key = os.getenv("geminiapikey") # Assuming you named it "geminiapikey" in HF Spaces
|
| 13 |
+
|
| 14 |
serper_key = os.getenv("serper_key")
|
| 15 |
|
| 16 |
+
if not gemini_key:
|
| 17 |
+
raise ValueError("ERROR: geminiapikey is missing. Set it in Hugging Face Spaces settings.")
|
| 18 |
if not serper_key:
|
| 19 |
raise ValueError("ERROR: SERPER_API_KEY is missing. Set it in Hugging Face Spaces settings.")
|
| 20 |
|
| 21 |
+
# Set the environment variable for crewai (if needed)
|
| 22 |
+
os.environ['gemini_API_KEY'] = gemini_key # Correctly set the environment variable
|
| 23 |
os.environ["SERPER_API_KEY"] = serper_key
|
| 24 |
|
| 25 |
+
# ... (Rest of your code remains the same)
|
| 26 |
+
|
| 27 |
+
# Make sure the port is 7860
|
| 28 |
+
|
| 29 |
def extract_text_from_pdf(file_path):
|
| 30 |
"""Extracts text from a PDF file using PyMuPDF."""
|
| 31 |
doc = fitz.open(file_path)
|
|
|
|
| 134 |
)
|
| 135 |
|
| 136 |
demo.queue()
|
| 137 |
+
demo.launch(server_port=7860) # Change the port number
|
| 138 |
|