Rekham1110 commited on
Commit
54e0609
·
verified ·
1 Parent(s): 45365c7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -59,7 +59,7 @@ def mock_ai_model(image):
59
  return milestone, completion_percent, confidence_score
60
 
61
  # Image processing and Salesforce upload
62
- def process_image(image, project_name):
63
  try:
64
  if image is None:
65
  return "Error: Please upload an image to proceed.", "Pending", "", "", 0
@@ -89,7 +89,7 @@ def process_image(image, project_name):
89
  'Title': image_filename,
90
  'PathOnClient': image_filename,
91
  'VersionData': encoded_image, # Using the base64-encoded image data
92
- 'FirstPublishLocationId': 'your_sobject_id', # Replace with the appropriate Salesforce object ID (e.g., Project or Construction)
93
  }
94
  content_version = sf.ContentVersion.create(content_version_data)
95
 
@@ -134,6 +134,7 @@ with gr.Blocks(css=".gradio-container {background-color: #f0f4f8; font-family: A
134
  with gr.Row():
135
  image_input = gr.Image(type="filepath", label="Upload Construction Site Photo (JPG/PNG, ≤ 20MB)")
136
  project_name_input = gr.Textbox(label="Project Name (Required)", placeholder="e.g. Project_12345")
 
137
 
138
  submit_button = gr.Button("Process Image")
139
  output_text = gr.Textbox(label="Result")
@@ -144,7 +145,7 @@ with gr.Blocks(css=".gradio-container {background-color: #f0f4f8; font-family: A
144
 
145
  submit_button.click(
146
  fn=process_image,
147
- inputs=[image_input, project_name_input],
148
  outputs=[output_text, upload_status, milestone, confidence, progress]
149
  )
150
 
 
59
  return milestone, completion_percent, confidence_score
60
 
61
  # Image processing and Salesforce upload
62
+ def process_image(image, project_name, sobject_id):
63
  try:
64
  if image is None:
65
  return "Error: Please upload an image to proceed.", "Pending", "", "", 0
 
89
  'Title': image_filename,
90
  'PathOnClient': image_filename,
91
  'VersionData': encoded_image, # Using the base64-encoded image data
92
+ 'FirstPublishLocationId': sobject_id, # Use the actual Salesforce object ID here
93
  }
94
  content_version = sf.ContentVersion.create(content_version_data)
95
 
 
134
  with gr.Row():
135
  image_input = gr.Image(type="filepath", label="Upload Construction Site Photo (JPG/PNG, ≤ 20MB)")
136
  project_name_input = gr.Textbox(label="Project Name (Required)", placeholder="e.g. Project_12345")
137
+ sobject_id_input = gr.Textbox(label="Salesforce Record ID (Required)", placeholder="Enter Salesforce Record ID here")
138
 
139
  submit_button = gr.Button("Process Image")
140
  output_text = gr.Textbox(label="Result")
 
145
 
146
  submit_button.click(
147
  fn=process_image,
148
+ inputs=[image_input, project_name_input, sobject_id_input],
149
  outputs=[output_text, upload_status, milestone, confidence, progress]
150
  )
151