Nischal Subedi
commited on
Commit
·
747d3ab
1
Parent(s):
d78d532
UI v7
Browse files
app.py
CHANGED
@@ -281,7 +281,7 @@ Answer:"""
|
|
281 |
["What is an implied warranty of habitability?", "Illinois"]
|
282 |
]
|
283 |
example_queries = []
|
284 |
-
if available_states_list and "Error" not in
|
285 |
loaded_states_set = set(available_states_list)
|
286 |
# Filter for examples whose state is in the loaded states
|
287 |
example_queries = [ex for ex in example_queries_base if ex[1] in loaded_states_set]
|
@@ -561,7 +561,7 @@ Answer:"""
|
|
561 |
.sub-section-title { font-size: 1.8rem !important; margin-top: 0.8rem !important; margin-bottom: 0.5rem !important; } /* Adjusted font size */
|
562 |
.gradio-textbox textarea, .gradio-dropdown select, .gradio-textbox input[type=password] { font-size: 1.05rem !important; padding: 1rem 1.2rem !important; }
|
563 |
.gradio-textbox textarea { min-height: 120px; }
|
564 |
-
.gradio-button { padding: 1rem 1.5rem !important; font-size:
|
565 |
.output-card .response-header { font-size: 1.4rem; } .output-card .response-icon { font-size: 1.5rem; }
|
566 |
.output-card .placeholder { padding: 2rem 1rem; font-size: 1.05rem; }
|
567 |
.examples-section { padding-top: 0.8rem; }
|
@@ -676,13 +676,13 @@ Answer:"""
|
|
676 |
logging.info("Gradio interface created with earneleh/paris theme and refined custom CSS.")
|
677 |
return demo
|
678 |
|
679 |
-
# --- Main Execution Block (remains untouched from original logic) ---
|
680 |
if __name__ == "__main__":
|
681 |
logging.info("Starting Landlord-Tenant Rights Bot application...")
|
682 |
try:
|
683 |
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
684 |
-
DEFAULT_PDF_PATH = os.path.join(SCRIPT_DIR, "tenant-landlord.pdf")
|
685 |
-
DEFAULT_DB_PATH = os.path.join(SCRIPT_DIR, "chroma_db")
|
686 |
|
687 |
PDF_PATH = os.getenv("PDF_PATH", DEFAULT_PDF_PATH)
|
688 |
VECTOR_DB_PATH = os.getenv("VECTOR_DB_PATH", DEFAULT_DB_PATH)
|
@@ -693,22 +693,20 @@ if __name__ == "__main__":
|
|
693 |
if not os.path.exists(PDF_PATH):
|
694 |
logging.error(f"FATAL: PDF file not found at the specified path: {PDF_PATH}")
|
695 |
print(f"\n--- CONFIGURATION ERROR ---\nPDF file ('{os.path.basename(PDF_PATH)}') not found at: {PDF_PATH}.\nPlease ensure it exists or set 'PDF_PATH' environment variable.\n---------------------------\n")
|
696 |
-
exit(1)
|
697 |
|
|
|
|
|
698 |
if not os.access(PDF_PATH, os.R_OK):
|
699 |
logging.error(f"FATAL: PDF file at '{PDF_PATH}' exists but is not readable. Check file permissions.")
|
700 |
print(f"\n--- PERMISSION ERROR ---\nPDF file ('{os.path.basename(PDF_PATH)}') found but not readable at: {PDF_PATH}\nPlease check file permissions (e.g., using 'chmod +r' in terminal).\n---------------------------\n")
|
701 |
-
|
702 |
|
703 |
logging.info(f"PDF file '{os.path.basename(PDF_PATH)}' found and is readable.")
|
704 |
|
705 |
vector_db_instance = VectorDatabase(persist_directory=VECTOR_DB_PATH)
|
706 |
rag = RAGSystem(vector_db=vector_db_instance)
|
707 |
|
708 |
-
# Ensure vector_db.py has process_and_load_pdf and it's called appropriately
|
709 |
-
# Example: if rag.load_pdf handles it internally based on db content.
|
710 |
-
# If not, you might need to call vector_db_instance.process_and_load_pdf(PDF_PATH) here
|
711 |
-
# For now, assuming rag.load_pdf is sufficient as per original structure.
|
712 |
rag.load_pdf(PDF_PATH)
|
713 |
|
714 |
app_interface = rag.gradio_interface()
|
|
|
281 |
["What is an implied warranty of habitability?", "Illinois"]
|
282 |
]
|
283 |
example_queries = []
|
284 |
+
if available_states_list and "Error" not in available_states_list[0] and len(available_states_list) > 0:
|
285 |
loaded_states_set = set(available_states_list)
|
286 |
# Filter for examples whose state is in the loaded states
|
287 |
example_queries = [ex for ex in example_queries_base if ex[1] in loaded_states_set]
|
|
|
561 |
.sub-section-title { font-size: 1.8rem !important; margin-top: 0.8rem !important; margin-bottom: 0.5rem !important; } /* Adjusted font size */
|
562 |
.gradio-textbox textarea, .gradio-dropdown select, .gradio-textbox input[type=password] { font-size: 1.05rem !important; padding: 1rem 1.2rem !important; }
|
563 |
.gradio-textbox textarea { min-height: 120px; }
|
564 |
+
.gradio-button { padding: 1rem 1.5rem !important; font-size: 1.0rem !important; }
|
565 |
.output-card .response-header { font-size: 1.4rem; } .output-card .response-icon { font-size: 1.5rem; }
|
566 |
.output-card .placeholder { padding: 2rem 1rem; font-size: 1.05rem; }
|
567 |
.examples-section { padding-top: 0.8rem; }
|
|
|
676 |
logging.info("Gradio interface created with earneleh/paris theme and refined custom CSS.")
|
677 |
return demo
|
678 |
|
679 |
+
# --- Main Execution Block (remains untouched from original logic, just fixed the exit) ---
|
680 |
if __name__ == "__main__":
|
681 |
logging.info("Starting Landlord-Tenant Rights Bot application...")
|
682 |
try:
|
683 |
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
684 |
+
DEFAULT_PDF_PATH = os.path.join(SCRIPT_DIR, "data/tenant-landlord.pdf")
|
685 |
+
DEFAULT_DB_PATH = os.path.join(SCRIPT_DIR, "data/chroma_db")
|
686 |
|
687 |
PDF_PATH = os.getenv("PDF_PATH", DEFAULT_PDF_PATH)
|
688 |
VECTOR_DB_PATH = os.getenv("VECTOR_DB_PATH", DEFAULT_DB_PATH)
|
|
|
693 |
if not os.path.exists(PDF_PATH):
|
694 |
logging.error(f"FATAL: PDF file not found at the specified path: {PDF_PATH}")
|
695 |
print(f"\n--- CONFIGURATION ERROR ---\nPDF file ('{os.path.basename(PDF_PATH)}') not found at: {PDF_PATH}.\nPlease ensure it exists or set 'PDF_PATH' environment variable.\n---------------------------\n")
|
696 |
+
exit(1) # This exit is correct: if file not found
|
697 |
|
698 |
+
# This `if` block checks for readability *only if the file exists*.
|
699 |
+
# The erroneous `exit(1)` that was likely at line 701 has been removed.
|
700 |
if not os.access(PDF_PATH, os.R_OK):
|
701 |
logging.error(f"FATAL: PDF file at '{PDF_PATH}' exists but is not readable. Check file permissions.")
|
702 |
print(f"\n--- PERMISSION ERROR ---\nPDF file ('{os.path.basename(PDF_PATH)}') found but not readable at: {PDF_PATH}\nPlease check file permissions (e.g., using 'chmod +r' in terminal).\n---------------------------\n")
|
703 |
+
exit(1) # This exit is correct: if file exists but is not readable
|
704 |
|
705 |
logging.info(f"PDF file '{os.path.basename(PDF_PATH)}' found and is readable.")
|
706 |
|
707 |
vector_db_instance = VectorDatabase(persist_directory=VECTOR_DB_PATH)
|
708 |
rag = RAGSystem(vector_db=vector_db_instance)
|
709 |
|
|
|
|
|
|
|
|
|
710 |
rag.load_pdf(PDF_PATH)
|
711 |
|
712 |
app_interface = rag.gradio_interface()
|