Update app.py
Browse files
app.py
CHANGED
|
@@ -223,11 +223,11 @@ def sanitize_input(text):
|
|
| 223 |
return ""
|
| 224 |
return bleach.clean(text.strip())
|
| 225 |
|
| 226 |
-
# Rule-based completeness engine with weighted scoring
|
| 227 |
-
def evaluate_readiness(logs, qa_report, punch_list_text):
|
| 228 |
try:
|
| 229 |
# Log inputs for debugging
|
| 230 |
-
logging.info(f"Inputs - Logs: {logs}, QA Report: {qa_report}, Punch List: {punch_list_text}")
|
| 231 |
|
| 232 |
# Initialize score and lists for tracking
|
| 233 |
score = 0
|
|
@@ -243,10 +243,10 @@ def evaluate_readiness(logs, qa_report, punch_list_text):
|
|
| 243 |
logs = sanitize_input(logs)
|
| 244 |
qa_report = sanitize_input(qa_report)
|
| 245 |
punch_list_text = sanitize_input(punch_list_text)
|
|
|
|
| 246 |
|
| 247 |
# Process Project Logs (30% weight)
|
| 248 |
-
|
| 249 |
-
logs_pass = logs and re.search(log_keywords, logs.lower())
|
| 250 |
if logs_pass:
|
| 251 |
score += LOGS_WEIGHT
|
| 252 |
checklist_details.append("Logs: Completed")
|
|
@@ -381,7 +381,8 @@ with gr.Blocks(css="""
|
|
| 381 |
)
|
| 382 |
with gr.Row():
|
| 383 |
with gr.Column(scale=2):
|
| 384 |
-
logs_input = gr.Textbox(label="Project Logs", lines=5, placeholder="Enter project logs (e.g., 'Project
|
|
|
|
| 385 |
qa_input = gr.Dropdown(
|
| 386 |
label="QA Report",
|
| 387 |
choices=["Approved", "Passed", "Cleared", "Pending", "Not Started"],
|
|
@@ -411,7 +412,7 @@ with gr.Blocks(css="""
|
|
| 411 |
# Chain the evaluation, PDF generation, and Salesforce record creation
|
| 412 |
submit_btn.click(
|
| 413 |
fn=evaluate_readiness,
|
| 414 |
-
inputs=[logs_input, qa_input, punch_input],
|
| 415 |
outputs=[
|
| 416 |
score_output, checklist_output, missing_output, status_output, progress_output,
|
| 417 |
gr.State(), gr.State(), gr.State(), gr.State(), open_punch_items_output, status_output
|
|
|
|
| 223 |
return ""
|
| 224 |
return bleach.clean(text.strip())
|
| 225 |
|
| 226 |
+
# Rule-based completeness engine with weighted scoring, updated to accept custom log_keywords
|
| 227 |
+
def evaluate_readiness(logs, qa_report, punch_list_text, log_keywords):
|
| 228 |
try:
|
| 229 |
# Log inputs for debugging
|
| 230 |
+
logging.info(f"Inputs - Logs: {logs}, QA Report: {qa_report}, Punch List: {punch_list_text}, Log Keywords: {log_keywords}")
|
| 231 |
|
| 232 |
# Initialize score and lists for tracking
|
| 233 |
score = 0
|
|
|
|
| 243 |
logs = sanitize_input(logs)
|
| 244 |
qa_report = sanitize_input(qa_report)
|
| 245 |
punch_list_text = sanitize_input(punch_list_text)
|
| 246 |
+
log_keywords = sanitize_input(log_keywords)
|
| 247 |
|
| 248 |
# Process Project Logs (30% weight)
|
| 249 |
+
logs_pass = logs and log_keywords and re.search(log_keywords, logs.lower())
|
|
|
|
| 250 |
if logs_pass:
|
| 251 |
score += LOGS_WEIGHT
|
| 252 |
checklist_details.append("Logs: Completed")
|
|
|
|
| 381 |
)
|
| 382 |
with gr.Row():
|
| 383 |
with gr.Column(scale=2):
|
| 384 |
+
logs_input = gr.Textbox(label="Project Logs", lines=5, placeholder="Enter project logs (e.g., 'Project is not completed')")
|
| 385 |
+
log_keywords_input = gr.Textbox(label="Log Keywords (Regex)", placeholder="Enter keywords or regex (e.g., 'complete|finished|done')")
|
| 386 |
qa_input = gr.Dropdown(
|
| 387 |
label="QA Report",
|
| 388 |
choices=["Approved", "Passed", "Cleared", "Pending", "Not Started"],
|
|
|
|
| 412 |
# Chain the evaluation, PDF generation, and Salesforce record creation
|
| 413 |
submit_btn.click(
|
| 414 |
fn=evaluate_readiness,
|
| 415 |
+
inputs=[logs_input, qa_input, punch_input, log_keywords_input],
|
| 416 |
outputs=[
|
| 417 |
score_output, checklist_output, missing_output, status_output, progress_output,
|
| 418 |
gr.State(), gr.State(), gr.State(), gr.State(), open_punch_items_output, status_output
|