Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1550,14 +1550,14 @@ class RealEstateModelPipeline:
|
|
| 1550 |
|
| 1551 |
if __name__ == "__main__":
|
| 1552 |
|
| 1553 |
-
|
|
|
|
|
|
|
|
|
|
| 1554 |
"""Process uploaded PDFs and return Excel file"""
|
| 1555 |
if not pdf_files:
|
| 1556 |
return None, "Please upload at least one PDF file"
|
| 1557 |
|
| 1558 |
-
if not api_key or api_key.strip() == "":
|
| 1559 |
-
return None, "Please enter your Gemini API key"
|
| 1560 |
-
|
| 1561 |
try:
|
| 1562 |
# Create temporary directory for PDFs
|
| 1563 |
temp_dir = tempfile.mkdtemp()
|
|
@@ -1566,8 +1566,8 @@ if __name__ == "__main__":
|
|
| 1566 |
for pdf_file in pdf_files:
|
| 1567 |
shutil.copy(pdf_file.name, temp_dir)
|
| 1568 |
|
| 1569 |
-
# Initialize pipeline with
|
| 1570 |
-
pipeline = RealEstateModelPipeline(
|
| 1571 |
|
| 1572 |
# Create output file in temp directory
|
| 1573 |
output_file = Path(temp_dir) / "Real_Estate_Financial_Model.xlsx"
|
|
@@ -1605,13 +1605,6 @@ if __name__ == "__main__":
|
|
| 1605 |
|
| 1606 |
with gr.Row():
|
| 1607 |
with gr.Column(scale=2):
|
| 1608 |
-
api_key_input = gr.Textbox(
|
| 1609 |
-
label="Gemini API Key",
|
| 1610 |
-
placeholder="Enter your Gemini API key (AIza...)",
|
| 1611 |
-
type="password",
|
| 1612 |
-
info="Get your API key from Google AI Studio"
|
| 1613 |
-
)
|
| 1614 |
-
|
| 1615 |
pdf_input = gr.File(
|
| 1616 |
label="Upload PDF Files",
|
| 1617 |
file_count="multiple",
|
|
@@ -1652,7 +1645,7 @@ if __name__ == "__main__":
|
|
| 1652 |
|
| 1653 |
process_btn.click(
|
| 1654 |
fn=process_pdfs,
|
| 1655 |
-
inputs=[pdf_input
|
| 1656 |
outputs=[excel_output, output_text]
|
| 1657 |
)
|
| 1658 |
|
|
|
|
| 1550 |
|
| 1551 |
if __name__ == "__main__":
|
| 1552 |
|
| 1553 |
+
# Hardcoded API Key
|
| 1554 |
+
GEMINI_API_KEY = "AIzaSyCy6GoBR724Hj9VyuW3hKM4N0P6liBOlDo"
|
| 1555 |
+
|
| 1556 |
+
def process_pdfs(pdf_files):
|
| 1557 |
"""Process uploaded PDFs and return Excel file"""
|
| 1558 |
if not pdf_files:
|
| 1559 |
return None, "Please upload at least one PDF file"
|
| 1560 |
|
|
|
|
|
|
|
|
|
|
| 1561 |
try:
|
| 1562 |
# Create temporary directory for PDFs
|
| 1563 |
temp_dir = tempfile.mkdtemp()
|
|
|
|
| 1566 |
for pdf_file in pdf_files:
|
| 1567 |
shutil.copy(pdf_file.name, temp_dir)
|
| 1568 |
|
| 1569 |
+
# Initialize pipeline with hardcoded API key
|
| 1570 |
+
pipeline = RealEstateModelPipeline(GEMINI_API_KEY)
|
| 1571 |
|
| 1572 |
# Create output file in temp directory
|
| 1573 |
output_file = Path(temp_dir) / "Real_Estate_Financial_Model.xlsx"
|
|
|
|
| 1605 |
|
| 1606 |
with gr.Row():
|
| 1607 |
with gr.Column(scale=2):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1608 |
pdf_input = gr.File(
|
| 1609 |
label="Upload PDF Files",
|
| 1610 |
file_count="multiple",
|
|
|
|
| 1645 |
|
| 1646 |
process_btn.click(
|
| 1647 |
fn=process_pdfs,
|
| 1648 |
+
inputs=[pdf_input],
|
| 1649 |
outputs=[excel_output, output_text]
|
| 1650 |
)
|
| 1651 |
|