pavansuresh commited on
Commit
883e33e
·
verified ·
1 Parent(s): 1ab2895

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -19,11 +19,9 @@ def upload_pdfs(files):
19
  file_name = os.path.basename(file.name)
20
  file_path = f"uploads/{file_name}"
21
  try:
22
- # Handle NamedString or file-like object
23
  if hasattr(file, 'read'):
24
  content = file.read()
25
  else:
26
- # Assume NamedString; convert string content to bytes
27
  content = str(file).encode('utf-8')
28
  with open(file_path, "wb") as f:
29
  f.write(content)
@@ -49,20 +47,20 @@ def upload_pdfs(files):
49
  def fetch_objects():
50
  sf, error = get_salesforce_client()
51
  if error:
52
- return gr.Dropdown.update(choices=[]), f"Error: {error}"
53
  objects, error = get_salesforce_objects(sf)
54
  if error:
55
- return gr.Dropdown.update(choices=[]), f"Error: {error}"
56
- return gr.Dropdown.update(choices=objects), "Objects fetched successfully"
57
 
58
  def fetch_fields(object_name):
59
  sf, error = get_salesforce_client()
60
  if error:
61
- return gr.CheckboxGroup.update(choices=[]), f"Error: {error}"
62
  fields, error = get_object_fields(sf, object_name)
63
  if error:
64
- return gr.CheckboxGroup.update(choices=[]), f"Error: {error}"
65
- return gr.CheckboxGroup.update(choices=fields), "Fields fetched successfully"
66
 
67
  def process_pdf(pdf_path):
68
  text_data, error = extract_text_from_pdf(pdf_path)
 
19
  file_name = os.path.basename(file.name)
20
  file_path = f"uploads/{file_name}"
21
  try:
 
22
  if hasattr(file, 'read'):
23
  content = file.read()
24
  else:
 
25
  content = str(file).encode('utf-8')
26
  with open(file_path, "wb") as f:
27
  f.write(content)
 
47
  def fetch_objects():
48
  sf, error = get_salesforce_client()
49
  if error:
50
+ return gr.update(choices=[]), f"Error: {error}"
51
  objects, error = get_salesforce_objects(sf)
52
  if error:
53
+ return gr.update(choices=[]), f"Error: {error}"
54
+ return gr.update(choices=objects), "Objects fetched successfully"
55
 
56
  def fetch_fields(object_name):
57
  sf, error = get_salesforce_client()
58
  if error:
59
+ return gr.update(choices=[]), f"Error: {error}"
60
  fields, error = get_object_fields(sf, object_name)
61
  if error:
62
+ return gr.update(choices=[]), f"Error: {error}"
63
+ return gr.update(choices=fields), "Fields fetched successfully"
64
 
65
  def process_pdf(pdf_path):
66
  text_data, error = extract_text_from_pdf(pdf_path)