Dineshpopuri commited on
Commit
b1396ef
·
verified ·
1 Parent(s): bf158ca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -12
app.py CHANGED
@@ -223,12 +223,11 @@ def sanitize_input(text):
223
  return ""
224
  return bleach.clean(text.strip())
225
 
226
- # Rule-based completeness engine with weighted scoring, updated to make log_keywords optional
227
- def evaluate_readiness(logs, qa_report, punch_list_text, log_keywords=None):
228
  try:
229
- # Use default regex if log_keywords is not provided
230
- if not log_keywords:
231
- log_keywords = r"complete|handover done|finished|closed|successful"
232
 
233
  # Log inputs for debugging
234
  logging.info(f"Inputs - Logs: {logs}, QA Report: {qa_report}, Punch List: {punch_list_text}, Log Keywords: {log_keywords}")
@@ -250,7 +249,8 @@ def evaluate_readiness(logs, qa_report, punch_list_text, log_keywords=None):
250
  log_keywords = sanitize_input(log_keywords)
251
 
252
  # Process Project Logs (30% weight)
253
- logs_pass = logs and log_keywords and re.search(log_keywords, logs.lower())
 
254
  if logs_pass:
255
  score += LOGS_WEIGHT
256
  checklist_details.append("Logs: Completed")
@@ -386,11 +386,6 @@ with gr.Blocks(css="""
386
  with gr.Row():
387
  with gr.Column(scale=2):
388
  logs_input = gr.Textbox(label="Project Logs", lines=5, placeholder="Enter project logs (e.g., 'Project complete, handover done')")
389
- log_keywords_input = gr.Textbox(
390
- label="Log Keywords (Regex, Optional)",
391
- placeholder="Enter keywords or regex (e.g., 'project is not completed' or 'complete|finished|done')",
392
- value=""
393
- )
394
  qa_input = gr.Dropdown(
395
  label="QA Report",
396
  choices=["Approved", "Passed", "Cleared", "Pending", "Not Started"],
@@ -420,7 +415,7 @@ with gr.Blocks(css="""
420
  # Chain the evaluation, PDF generation, and Salesforce record creation
421
  submit_btn.click(
422
  fn=evaluate_readiness,
423
- inputs=[logs_input, qa_input, punch_input, log_keywords_input],
424
  outputs=[
425
  score_output, checklist_output, missing_output, status_output, progress_output,
426
  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
227
+ def evaluate_readiness(logs, qa_report, punch_list_text):
228
  try:
229
+ # Hardcode log_keywords to check for incomplete status
230
+ log_keywords = r"project is not completed"
 
231
 
232
  # Log inputs for debugging
233
  logging.info(f"Inputs - Logs: {logs}, QA Report: {qa_report}, Punch List: {punch_list_text}, Log Keywords: {log_keywords}")
 
249
  log_keywords = sanitize_input(log_keywords)
250
 
251
  # Process Project Logs (30% weight)
252
+ # Check should fail if log_keywords match (indicating incomplete)
253
+ logs_pass = logs and log_keywords and not re.search(log_keywords, logs.lower())
254
  if logs_pass:
255
  score += LOGS_WEIGHT
256
  checklist_details.append("Logs: Completed")
 
386
  with gr.Row():
387
  with gr.Column(scale=2):
388
  logs_input = gr.Textbox(label="Project Logs", lines=5, placeholder="Enter project logs (e.g., 'Project complete, handover done')")
 
 
 
 
 
389
  qa_input = gr.Dropdown(
390
  label="QA Report",
391
  choices=["Approved", "Passed", "Cleared", "Pending", "Not Started"],
 
415
  # Chain the evaluation, PDF generation, and Salesforce record creation
416
  submit_btn.click(
417
  fn=evaluate_readiness,
418
+ inputs=[logs_input, qa_input, punch_input],
419
  outputs=[
420
  score_output, checklist_output, missing_output, status_output, progress_output,
421
  gr.State(), gr.State(), gr.State(), gr.State(), open_punch_items_output, status_output