Dineshpopuri commited on
Commit
16e19c2
·
verified ·
1 Parent(s): a93deaa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -147,14 +147,19 @@ def create_salesforce_record(score, checklist_summary, missing_summary, status,
147
  # Explicitly convert escalated to lowercase boolean string for Escalation_Flag__c
148
  escalation_flag = str(bool(escalated)).lower() # Ensure this is also a proper boolean string
149
 
150
- # Check if pdf_path is a valid URL
151
  pdf_url = ""
152
  if pdf_path:
153
- # In a real environment, you'd need to upload the PDF to a publicly accessible location
154
- # For now, we'll log a warning and set the URL to empty to avoid Salesforce validation errors
155
- logging.warning(f"PDF path provided: {pdf_path}. However, this is a local file path, not a valid URL.")
156
- logging.warning("To set Client_PDF_Pack_URL__c, the PDF must be hosted publicly (e.g., via S3 or another service).")
157
- logging.warning("Setting Client_PDF_Pack_URL__c to empty string to avoid Salesforce validation error.")
 
 
 
 
 
158
 
159
  # Create a record in the custom object Project_Closure_Handover__c
160
  record = {
@@ -164,7 +169,7 @@ def create_salesforce_record(score, checklist_summary, missing_summary, status,
164
  "Status__c": status,
165
  "Summarized_Missing_Items__c": summarized_missing,
166
  "Alert_Sent__c": alert_sent,
167
- "Client_PDF_Pack_URL__c": pdf_url, # Set to empty string to avoid validation error
168
  "Closure_Pack_URL__c": "", # Placeholder; update if you have a closure pack URL
169
  "Escalation_Flag__c": escalation_flag,
170
  "Evaluated_At__c": evaluated_at,
 
147
  # Explicitly convert escalated to lowercase boolean string for Escalation_Flag__c
148
  escalation_flag = str(bool(escalated)).lower() # Ensure this is also a proper boolean string
149
 
150
+ # Handle the PDF URL for Client_PDF_Pack_URL__c
151
  pdf_url = ""
152
  if pdf_path:
153
+ # In Hugging Face Spaces, the pdf_path is a local filepath (e.g., readiness_report.pdf)
154
+ # Gradio may serve this file, but we don't have a direct public URL
155
+ # For demonstration, we'll construct a placeholder URL assuming the file is hosted
156
+ # In a real production environment, you'd need to upload the PDF to a public location (e.g., S3)
157
+ logging.info(f"PDF path provided: {pdf_path}")
158
+ # Simulate a URL for Hugging Face Spaces (this is a placeholder and may not work)
159
+ # Replace 'your-huggingface-space-url' with the actual Space URL if known
160
+ pdf_url = f"https://your-huggingface-space-url.hf.space/file={pdf_path}"
161
+ logging.warning("Using a placeholder URL for Client_PDF_Pack_URL__c. In a production environment, upload the PDF to a publicly accessible location (e.g., AWS S3) and use that URL.")
162
+ logging.warning(f"Generated placeholder URL: {pdf_url}")
163
 
164
  # Create a record in the custom object Project_Closure_Handover__c
165
  record = {
 
169
  "Status__c": status,
170
  "Summarized_Missing_Items__c": summarized_missing,
171
  "Alert_Sent__c": alert_sent,
172
+ "Client_PDF_Pack_URL__c": pdf_url, # Use the placeholder URL
173
  "Closure_Pack_URL__c": "", # Placeholder; update if you have a closure pack URL
174
  "Escalation_Flag__c": escalation_flag,
175
  "Evaluated_At__c": evaluated_at,